Last modified: 2014-07-24 17:49:24 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
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$
Reproduced in compat, the code works perfectly fine in core though.