Last modified: 2014-07-24 17:49:24 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 T57262, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 55262 - -dir: parameter not working, variable _base_dir has unclear e
-dir: parameter not working, variable _base_dir has unclear e
Status: NEW
Product: Pywikibot
Classification: Unclassified
General (Other open bugs)
compat-(1.0)
All All
: Low normal
: ---
Assigned To: Pywikipedia bugs
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2013-10-05 04:53 UTC by Kunal Mehta (Legoktm)
Modified: 2014-07-24 17:49 UTC (History)
3 users (show)

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


Attachments

Description Kunal Mehta (Legoktm) 2013-10-05 04:53:28 UTC
Originally from: http://sourceforge.net/p/pywikipediabot/bugs/1224/
Reported by: purodha
Created on: 2010-08-22 21:57:45
Subject: -dir: paramter not working, variable _base_dir has unclear e
Assigned to: purodha
Original description:
In the current svn verision \(rev 8433\) there is a huge mess around the parameter -dir.
It is not processed in the place where all general parameters are - wikipedia.handleArgs\(\)
It is processed in wikipediatools an then deleted from the arguemnt list.
Since this code is executed multiple times \(e.g. 3 times in interwiki.py\) it does different
and unwanted things from the 2nd call on.
We see repeated error messages about missing config files being created where there
should be none. Login information is sought at the wrong place, requiring one to log
in for each change made by interwiki.py, e.g.

config.py processed the -dir parameter and puts it into a variable \_base\_dir
This variable is being used inconsistently as:
\- the directory where user\_config is sought \(only during the 1st trip through\),
\- the directory where family configurations are expected,
\- the directory where programs are to be found,
\- the directory where where a .svn subdirectory is expected,
which cannot be all identical if you are running multiple bots having
to have different user\_config.py files.

This all needs cleanup.

Since config data is processed before command line parameters are parsed,
this is not straigthforward. When there can be a -dir parameter, config processing
must not occur before it has been seen, or is known not to be used.

Since the current handling is not working anyways, and multiple processing is a waste
anyways, I suggest to move the entire config handling to wikipedia.handleArgs\(\)
and make sure, it only happens once. This would likely obsolete most or all of the
contents of wikipediatools.py
Comment 1 Kunal Mehta (Legoktm) 2013-10-05 04:53:30 UTC
Here is a sample session - there is no config in /tmp/


user@A1A:~/files/pywikipedia$ python interwiki.py -dir:/tmp/
No user-config.py found in directory '/tmp/'
Creating...

'user-config.py' already exists.
Traceback \(most recent call last\):
File "interwiki.py", line 337, in <module>
import wikipedia as pywikibot
File "/home/.../files/pywikipedia/wikipedia.py", line 143, in <module>
from pywikibot import \*
File "/home/.../files/pywikipedia/pywikibot/\_\_init\_\_.py", line 15, in <module>
from exceptions import \*
File "/home/.../files/pywikipedia/pywikibot/exceptions.py", line 13, in <module>
import config
File "/home/.../files/pywikipedia/config.py", line 90, in <module>
for \_filename in os.listdir\(os.path.join\(\_base\_dir, 'families'\)\):
OSError: \[Errno 2\] No such file or directory: '/tmp/families'
user@A1A:~/files/pywikipedia$
Comment 2 Amir Ladsgroup 2014-07-24 14:09:35 UTC
Reproduced in compat, the code works perfectly fine in core though.

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


Navigation
Links