Page MenuHomePhabricator

pywikibot upload.py failing for me on toolforge
Closed, ResolvedPublic

Description

I am trying to move a file from Commons to enWS and using syntax that I have used successfully before. When it is trying to handle the description component it is running into troubles.

If I say y to change it then I get the error with retry

ERROR: no display name and no $DISPLAY environment variable

If I say n to accept it, then it throws out an error and dies

all below

billinghurst@tools-sgebastion-07:~$ python3 scripts/upload.py -descfile:desc
No input filename given.
URL, file or directory where files are now: https://upload.wikimedia.org/wikipedia/commons/5/54/Alice_in_Wonderland_%281903%29_-_yt.webm
The filename on the target wiki will default to: Alice_in_Wonderland_%281903%29_-_yt.webm
Enter a better name, or press enter to accept: Alice_in_Wonderland_%281903%29_-_yt2.webm
The suggested description is:

{{do not move to Commons|expiry=2023}}
== {{int:filedesc}} ==
{{Information
|Description    ={{en|1=1903 silent film}}
|Source         =[https://www.youtube.com/watch?v=JuNVHPUxKLI YouTube]
|Author         =[[author:Cecil Hepworth|Cecil Hepworth]] and [[author:Percy Stow|Percy Stow]]
|Date           =1903
|Permission     ={{PD/US|1953}}
|other_versions =
}}
<!-- [[Category:Video display resolution 480 x 360]]
[[Category:WebM videos]]
[[Category:Videos of 1903]]
[[Category:Silent films videos]]
[[Category:Videos from Edison Manufacturing]]
[[Category:Black and white videos]]
[[Category:Alice in Wonderland films]] -->

Do you want to change this description? ([y]es, [N]o, [q]uit): y
ERROR: no display name and no $DISPLAY environment variable
Do you want to change this description? ([y]es, [N]o, [q]uit): n
Uploading file to wikisource:en...
Reading file https://upload.wikimedia.org/wikipedia/commons/5/54/Alice_in_Wonderland_%281903%29_-_yt.webm

0 pages read
0 pages written
0 pages skipped
Script terminated by exception:

ERROR: TypeError: invalid file: PosixPath('/tmp/tmptfd_ykgi')
Traceback (most recent call last):

File "scripts/upload.py", line 224, in <module>
  main()
File "scripts/upload.py", line 220, in main
  bot.run()
File "/data/project/shared/pywikibot/stable/pywikibot/specialbots/_upload.py", line 445, in run
  self.upload_file(file_url)
File "/data/project/shared/pywikibot/stable/pywikibot/specialbots/_upload.py", line 391, in upload_file
  file_url = self.read_file_content(file_url)
File "/data/project/shared/pywikibot/stable/pywikibot/specialbots/_upload.py", line 132, in read_file_content
  with open(path, 'ab') as fd:

TypeError: invalid file: PosixPath('/tmp/tmptfd_ykgi')
CRITICAL: Exiting due to uncaught exception <class 'TypeError'>
billinghurst@tools-sgebastion-07:~$

Event Timeline

Restricted Application added subscribers: pywikibot-bugs-list, Aklapper. · View Herald Transcript
Billinghurst renamed this task from mywikibot upload.py failing for me on toolforge to pywikibot upload.py failing for me on toolforge.Jan 19 2021, 9:54 AM
Xqt triaged this task as High priority.

Change 657098 had a related patch set uploaded (by Xqt; owner: Xqt):
[pywikibot/core@master] [bugfix] use string instead of Path-like object with "open" function

https://gerrit.wikimedia.org/r/657098

I assume Python 3.5 is used. Can you please review this patch?

Change 657098 merged by jenkins-bot:
[pywikibot/core@master] [bugfix] use string instead of Path-like object with "open" function

https://gerrit.wikimedia.org/r/657098

Still failing

billinghurst@tools-sgebastion-07:~$ python3 -V
Python 3.5.3

billinghurst@tools-sgebastion-07:~$ ls -l scripts/up*
-rwxr-xr-x 1 tools.pywikibot tools.pywikibot 7906 Jan 22 01:01 scripts/upload.py

Here is the console ...

File with name Alice_in_Wonderland_%281903%29_-_yt.webm already exists. Would
you like to change the name? (Otherwise file will be overwritten.) ([Y]es,
[n]o): n
The suggested description is:

{{do not move to Commons|expiry=2023}}
 == {{int:filedesc}} ==
 {{Information
 |Description    ={{en|1=1903 silent film}}
 |Source         =[https://www.outube.com/watch?v=JuNVHPUxKLI YouTube]
 |Author         =[[author:Cecil Hepworth|Cecil Hepworth]] and [[author:Percy Stow|Percy Stow]]
 |Date           =1903
 |Permission     ={{PD/US|1953}}
 |other_versions =
 }}

<!-- [[Category:Video display resolution 480 x 360]]
[[Category:WebM videos]]
[[Category:Videos of 1903]]
[[Category:Silent films videos]]
[[Category:Videos from Edison Manufacturing]]
[[Category:Black and white videos]]
[[Category:Alice in Wonderland films]] -->

Do you want to change this description? ([y]es, [N]o, [q]uit): y
ERROR: no display name and no $DISPLAY environment variable
Do you want to change this description? ([y]es, [N]o, [q]uit): y
ERROR: no display name and no $DISPLAY environment variable
Do you want to change this description? ([y]es, [N]o, [q]uit): n
Uploading file to wikisource:en...
Reading file https://upload.wikimedia.org/wikipedia/commons/5/54/Alice_in_Wonderland_%281903%29_-_yt.webm

0 pages read
0 pages written
0 pages skipped
Script terminated by exception:

ERROR: TypeError: invalid file: PosixPath('/tmp/tmpm2hcnhno')
Traceback (most recent call last):

File "scripts/upload.py", line 224, in <module>
  main()
File "scripts/upload.py", line 220, in main
  bot.run()
File "/data/project/shared/pywikibot/stable/pywikibot/specialbots/_upload.py", line 445, in run
  self.upload_file(file_url)
File "/data/project/shared/pywikibot/stable/pywikibot/specialbots/_upload.py", line 391, in upload_file
  file_url = self.read_file_content(file_url)
File "/data/project/shared/pywikibot/stable/pywikibot/specialbots/_upload.py", line 132, in read_file_content
  with open(path, 'ab') as fd:

TypeError: invalid file: PosixPath('/tmp/tmpm2hcnhno')
CRITICAL: Exiting due to uncaught exception <class 'TypeError'>

This issue is solved with Pywikibot 5.6. stable release based on 5.6 was deployed 5 hours ago. Please try again.

@Xqt success! Thanks. Then just the usual hassle of parantheses in filenames and my forgetfulness of which ways they are handled, and fighting Commons existing filename blocking upload., but only after it has taken all the time to upload the file before it says YEAHNAH