Page MenuHomePhabricator

make pwb.py cwd-insensitive
Closed, ResolvedPublic

Description

(pywikibot)valhallasw@tools-bastion-01:~/pywikibot$ /shared/pywikipedia/core/pwb.py login
NOTE: 'user-config.py' was not found!
Please follow the prompts to create it:
Traceback (most recent call last):
  File "/shared/pywikipedia/core/pwb.py", line 164, in <module>
    [])
  File "/shared/pywikipedia/core/pwb.py", line 85, in run_python_file
    with open(filename, 'rb') as f:
IOError: [Errno 2] No such file or directory: u'generate_user_files.py'

this should Just Work(tm).

Event Timeline

valhallasw raised the priority of this task from to Needs Triage.
valhallasw updated the task description. (Show Details)
valhallasw added a project: Pywikibot.
valhallasw subscribed.
Restricted Application added subscribers: Aklapper, Unknown Object (MLST). · View Herald TranscriptJun 9 2015, 12:50 PM

Why “case insensitive”? The file's name is 'generate_user_files.py'.

EDIT: Okay it's cwd not case ;)

Xqt changed the task status from Open to Stalled.May 17 2018, 12:21 PM
Xqt subscribed.

Is this still valid? I canot reproduce it after this long time.

Dvorapa changed the task status from Stalled to Open.May 17 2018, 9:12 PM
Dvorapa added a project: Toolforge.
Dvorapa subscribed.

Still reproducible

Still reproducible

Could you explain. Sorry I've no glue what is the problem. Seems a Linux issue.

Still reproducible

Could you explain. Sorry I've no glue what is the problem. Seems a Linux issue.

I could reproduce it both on Toolforge and on my PC (Linux) too. Steps to reproduce:

  1. Open a command line (terminal)
  2. Navigate to the whatever directory, but not pywikibot directory (for example cd Downloads)
  3. Run pywikibot script (here pwb.py login) using absolute path (from root; /............/pwb.py login)
  4. If there is no user config file, it tries to call generate_user_files from the directory you are currently in (current working directory - Downloads), not in the directory where pwb.py is located (/.........../pwb.py).

Not sure if this is the only case or there are more cases like that. Basically the title of this task says: Make pywikibot work independently on current working directory, but better would be: Don't assume pywikibot is launched from its directory.

Is this really a Linux issue only?

Change 433729 had a related patch set uploaded (by Framawiki; owner: Framawiki):
[pywikibot/core@master] [bugfix] Use absolute path for generate_user_files.py

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

I made a proposition, as this patch worked for me.

Ah, I understand but I guess PYWIKIBOT2_DIR_PWB must has been set otherwise the pwb.py wrapper will not be found, right?

Xqt triaged this task as Low priority.May 18 2018, 3:40 PM

Change 433729 merged by jenkins-bot:
[pywikibot/core@master] [bugfix] Use absolute path for generate_user_files.py

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