Home » Eclipse Projects » Eclipse Platform » Python debugging - problem with command line arguments(Debugger stops in runfiles.py raising GetoptError)
Python debugging - problem with command line arguments [message #694117] |
Thu, 07 July 2011 20:51 |
So 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 ============================
|
|
| | | | |
Goto Forum:
Current Time: Thu Mar 28 10:31:16 GMT 2024
Powered by FUDForum. Page generated in 0.24365 seconds
|