Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Python debugging - problem with command line arguments(Debugger stops in runfiles.py raising GetoptError)
icon9.gif  Python debugging - problem with command line arguments [message #694117] Thu, 07 July 2011 20:51 Go to next message
So  is currently offline So Friend
Messages: 4
Registered: July 2011
Junior Member
I'm attempting to debug a python 2.6 project with Eclipse, but am having some difficulty. I've setup my debug project and given it a command line argument option of "-i <file_name>" (no quotes) expecting to be able to parse the command line arguments using OptionParser. When I attempt to run the debugger, the console starts reporting errors, even before it touches my first line of Python code (where I've set a breakpoint.

My first attempt at getting the command line args was to just try and grab lCommandLineArgs[1], without using switch flags on the command line, since I was expecting only a file name to be used as the only passed command line argument. While debugging that method, I saw that the command line arguments included a first argument of runfiles.py. This is a slight annoyance, since the command line args received from the debugger will never equal the command line args while running in normal usage. Rant aside, moving on.

To get around the issue above, I decided to attempt to make the command line parser more robust, so that there would appear to be no difference (to the code) whether I run in the debugger or out. To do this, I started to use the OptionParser and added the -i <file_name> approach. Now, the script is choking because it appears that runfiles.py also attempts to parse the command line arguments and dies if it does not receive a flag supported by the runfiles.py module; these are v:f:t.

Am I missing something? How am I supposed to add command line argument support (with flags) and still be able to debug the script without it halting in runfiles? I've attached the console window output below, if that helps.

Thanks in advance for your help,
So


============== Begin Console Output =========================
pydev debugger: starting
Traceback (most recent call last):
File "C:\Program Files\eclipse\plugins\org.python.pydev.debug_1.6.3.2010100513\pysrc\pydevd.py", line 1145, in <module>
debugger.run(setup['file'], None, None)
File "C:\Program Files\eclipse\plugins\org.python.pydev.debug_1.6.3.2010100513\pysrc\pydevd.py", line 916, in run
execfile(file, globals, locals) #execute the script
File "C:\Program Files\eclipse\plugins\org.python.pydev.debug_1.6.3.2010100513\pysrc\runfiles.py", line 529, in <module>
dirs, verbosity, test_filter, tests = parse_cmdline()
File "C:\Program Files\eclipse\plugins\org.python.pydev.debug_1.6.3.2010100513\pysrc\runfiles.py", line 207, in parse_cmdline
optlist, dirs = gnu_getopt(sys.argv[1:], "v:f:t:", ["verbosity=", "filter=", "tests="])
File "C:\Program Files\eclipse\plugins\org.python.pydev.debug_1.6.3.2010100513\pysrc\runfiles.py", line 106, in gnu_getopt
opts, args = do_shorts(opts, args[0][1:], shortopts, args[1:])
File "C:\Program Files\eclipse\plugins\org.python.pydev.debug_1.6.3.2010100513\pysrc\runfiles.py", line 163, in do_shorts
if short_has_arg(opt, shortopts):
File "C:\Program Files\eclipse\plugins\org.python.pydev.debug_1.6.3.2010100513\pysrc\runfiles.py", line 179, in short_has_arg
raise GetoptError('option -%s not recognized' % opt, opt)
__main__.GetoptError: option -i not recognized

===================== End Console Output ============================
Re: Python debugging - problem with command line arguments [message #694123 is a reply to message #694117] Thu, 07 July 2011 21:21 Go to previous messageGo to next message
David Wegener is currently offline David WegenerFriend
Messages: 1445
Registered: July 2009
Senior Member
Is this a question pertaining to PyDev? If so, you will need to pursue the problems through the PyDev support channels. PyDev is a separate product from Eclipse. It appears to run on Eclipse, but isn't supported by the Eclipse forums.
Re: Python debugging - problem with command line arguments [message #694133 is a reply to message #694117] Thu, 07 July 2011 21:56 Go to previous messageGo to next message
So  is currently offline So Friend
Messages: 4
Registered: July 2011
Junior Member
Okay. May have resolved my own problem above to be replaced by a new issue. I performed an update to Eclipse and the above no longer happens. However, now I can start to step through code, yet now when I try (options, args) = objParser.parse_args(), runfiles.py gives a new error: runfiles.py: error: no such option: --port .
Re: Python debugging - problem with command line arguments [message #694134 is a reply to message #694133] Thu, 07 July 2011 21:56 Go to previous messageGo to next message
So  is currently offline So Friend
Messages: 4
Registered: July 2011
Junior Member
No Message Body
Re: Python debugging - problem with command line arguments [message #694136 is a reply to message #694134] Thu, 07 July 2011 21:56 Go to previous message
So  is currently offline So Friend
Messages: 4
Registered: July 2011
Junior Member
Thank you for your reply. Yes, it appears this is a pydev error. My apologies. Will try to get answers from their forums. Appreciatively, So.
Previous Topic:Project type Vaadin Project disappear
Next Topic:Problem with installing new software on Eclipse Indigo
Goto Forum:
  


Current Time: Thu Mar 28 10:31:16 GMT 2024

Powered by FUDForum. Page generated in 0.24365 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top