Hi,
I began to write a new module. First it showed no help. Then I wrote this line in: pywikibot.handleArgs() #for help Now it displays global help, the contents between the first """ pair after coding (that's OK), and below it:
Sorry, no help available for apispec
Why does it write this once it has displayed help? My other script behaves normally. I can't guess the difference.
On 29 January 2012 20:16, Bináris wikiposta@gmail.com wrote:
I began to write a new module. First it showed no help. Then I wrote this line in: pywikibot.handleArgs() #for help Now it displays global help, the contents between the first """ pair after coding (that's OK), and below it:
Sorry, no help available for apispec
What is apispec? The name of your module?
Check wikipedia.py:7853-7858 (r9841) for the code that determines what gets output on -help. Try using pdb and check what happens. Maybe something with the text encoding, or a broken docuReplacements?
Best, Merlijn
2012/1/29 Merlijn van Deen valhallasw@arctus.nl
What is apispec? The name of your module?
Yes, it is. I finally began to write the library for special pages since noone else did it.
Check wikipedia.py:7853-7858 (r9841) for the code that determines what gets output on -help. Try using pdb and check what happens. Maybe something with the text encoding, or a broken docuReplacements?
None of them. I tried to comment out .decode('utf-8') (nothing changes, encoding is fine), tried to insert prints to various places including the last line of try clause and they appear properly. There are no docureplacements at all. The next idea is to mine into except clause, but I forgot the code that displays the error message for a general "except". I saw it somewhere a few days ago...
On 29 January 2012 21:12, Bináris wikiposta@gmail.com wrote:
The next idea is to mine into except clause, but I forgot the code that displays the error message for a general "except". I saw it somewhere a few days ago...
Just add 'raise' inside the except clause. This will cause the interpreter to dump a stack trace and stop.
Merlijn
2012/1/29 Bináris wikiposta@gmail.com
The next idea is to mine into except clause, but I forgot the code that displays the error message for a general "except". I saw it somewhere a few days ago...
I found it in archivebot.py: import traceback traceback.print_exc()
The exception is SystemExit: 0 It is caused by line 7813 in the current version: http://svn.wikimedia.org/viewvc/pywikipedia/trunk/pywikipedia/wikipedia.py?r...
This part of handleArgs: 7811 if do_help: 7812 showHelp() 7813 sys.exit(0) 7814 return nonGlobalArgs If I comment 7813 out, it works properly.
On 29 January 2012 21:40, Bináris wikiposta@gmail.com wrote:
The exception is SystemExit: 0 It is caused by line 7813 in the current version:
http://svn.wikimedia.org/viewvc/pywikipedia/trunk/pywikipedia/wikipedia.py?r...
As I mentioned in the previous mail: use 'raise', so that we have the /entire/ stack trace.
This part of handleArgs:
7811 if do_help: 7812 showHelp() 7813 sys.exit(0) 7814 return nonGlobalArgs If I comment 7813 out, it works properly.
Which is incredibly weird, considering the try-except block is inside showHelp, which is a line *above* the sys.exit().
Possibly the problem is caused by a double import - i.e. apispec is first loaded directly, and /then/ as a module (from showHelp), which causes a call to pywikibot.handleArgs() from within the first one.
Again, to confirm this, please post the *entire* stack trace. The solution would then be to make sure pywikibot.handleArgs() is only called when the script runs from the command like (i.e. use a __name__=="__main__" block).
Best, Merlijn
2012/1/29 Merlijn van Deen valhallasw@arctus.nl
Which is incredibly weird, considering the try-except block is inside showHelp, which is a line *above* the sys.exit().
I realized that myself after sending mail. :-)
Possibly the problem is caused by a double import
Exactly that's what happened!
The solution would then be to make sure pywikibot.handleArgs() is only called when the script runs from the command like (i.e. use a __name__=="__main__" block).
Thank you, this solved the problem finally! I had this block but I didn't know that handleArgs had to be there. Now I understand.
pywikipedia-l@lists.wikimedia.org