Last modified: 2014-11-12 21:07:21 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T74290, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 72290 - tilde in argument to -dir causes exception
tilde in argument to -dir causes exception
Status: RESOLVED FIXED
Product: Pywikibot
Classification: Unclassified
General (Other open bugs)
core-(2.0)
All All
: Unprioritized trivial
: ---
Assigned To: Pywikipedia bugs
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2014-10-21 01:17 UTC by John Mark Vandenberg
Modified: 2014-11-12 21:07 UTC (History)
2 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description John Mark Vandenberg 2014-10-21 01:17:45 UTC
If the directory ~/.pywikibot2 doesnt exist

/path/to/current/dir/ $ python pwb.py -dir:~/.pywikibot2 version
NOTE: ~/.pywikibot2/user-config.py was not found
Please follow the prompts to create it:
Traceback (most recent call last):
  File "pwb.py", line 149, in <module>
    run_python_file(path, [path], [path.decode('ascii')])
  File "pwb.py", line 69, in run_python_file
    exec(compile(source, filename, "exec"), main_mod.__dict__)
  File "generate_user_files.py", line 19, in <module>
    import pywikibot
  File "pywikibot/__init__.py", line 29, in <module>
    from pywikibot import config2 as config
  File "pywikibot/config2.py", line 209, in <module>
    _base_dir = get_base_dir()
  File "pywikibot/config2.py", line 195, in get_base_dir
    raise RuntimeError("Directory '%s' does not exist." % base_dir)
RuntimeError: Directory '/path/to/current/dir/~/.pywikibot2' does not exist.

(that path.decode('ascii') looks defective too)
Comment 1 Mpaa 2014-10-23 21:26:08 UTC
Now ~ in argument is resolved.
The exception is raised because the directory does not exist.
But I think this is the wanted behaviour (*).

python pwb.py version -dir:~/.pywikibot2
NOTE: 'user-config.py' was not found!
Please follow the prompts to create it:
Traceback (most recent call last):
  File "pwb.py", line 162, in <module>
    [])
  File "pwb.py", line 75, in run_python_file
    exec(compile(source, filename, "exec"), main_mod.__dict__)
  File "generate_user_files.py", line 19, in <module>
    import pywikibot
  File "pywikibot/__init__.py", line 29, in <module>
    from pywikibot import config2 as config
  File "pywikibot/config2.py", line 224, in <module>
    _base_dir = get_base_dir()
  File "pywikibot/config2.py", line 210, in get_base_dir
    raise RuntimeError("Directory '%s' does not exist." % base_dir)
RuntimeError: Directory '/home/user/.pywikibot2' does not exist.

Note that in you example, it also fails even if the directory exists as -dir: comes before the expected script name.

python pwb.py -dir:~/.pywikibot version
Traceback (most recent call last):
  File "pwb.py", line 166, in <module>
    if len(sys.argv) > 1:
OSError: -dir:~/.pywikibot.py not found!
<type 'exceptions.OSError'>


But if you put it in the expected order, which I guess is the wanted behaviour (**), then this is OK:

python pwb.py version -dir:~/.pywikibot
Pywikibot: [ssh] pywikibot-core.git (182616b, g4347, 2014/10/20, 19:36:09, OUTDATED)
...
Python: 2.7.6 (default, Mar 22 2014, 22:59:38) 
[GCC 4.8.2]
  unicode test: ok


I think this bug can be closed unless (*) and (**) are not as we would like this to work.
Comment 2 Fabian 2014-10-24 22:44:16 UTC
(In reply to Mpaa from comment #1) 
> Note that in you example, it also fails even if the directory exists as
> -dir: comes before the expected script name.
> 
> python pwb.py -dir:~/.pywikibot version
> Traceback (most recent call last):
>   File "pwb.py", line 166, in <module>
>     if len(sys.argv) > 1:
> OSError: -dir:~/.pywikibot.py not found!
> <type 'exceptions.OSError'>

This is 'intentional'. The first parameter after 'pwb.py' MUST be the script you want to execute. Similar to how 'commit' must be directly after 'git' but '--amend' and '-a' after that can be swapped as you like.
Comment 3 Mpaa 2014-10-24 23:11:31 UTC
Then, as I said, this can be closed.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links