[et-mgmt-tools] [PATCH] Fix traceback on commands run with -h

Jeremy Rosengren jeremy at rosengren.org
Tue Feb 19 16:12:56 UTC 2008


I compiled from latest git and am seeing what I've copied below.  
Stephen Smoogen also reported the problem using the latest published RPM 
version (which is also where I first saw it):  
https://www.redhat.com/archives/et-mgmt-tools/2008-February/msg00112.html

 From what I saw in cobbler.py from latest git, the conditional in 
main() was giving the traceback all the time.  The "else" case of print 
str(exc2)[1:-1] had flipped sides of the conditional statement from a 
couple of revisions back.

-- jeremy

[root at raid ~]# cobbler reposync -h
usage: cobbler reposync  [ARGS]

options:
  -h, --help   show this help message and exit
  --only=ONLY  update only this repository name
Traceback (most recent call last):
  File "/usr/lib/python2.4/site-packages/cobbler/cobbler.py", line 54, 
in main
    return BootCLI().run(sys.argv)
  File "/usr/lib/python2.4/site-packages/cobbler/cobbler.py", line 43, 
in run
    return self.loader.run(args)
  File "/usr/lib/python2.4/site-packages/cobbler/commands.py", line 66, 
in run
    loaded_ok = fn.parse_args(args)
  File "/usr/lib/python2.4/site-packages/cobbler/commands.py", line 190, 
in parse_args
    (self.options, self.args) = p.parse_args(args)
  File "/usr/lib/python2.4/optparse.py", line 1275, in parse_args
    stop = self._process_args(largs, rargs, values)
  File "/usr/lib/python2.4/optparse.py", line 1319, in _process_args
    self._process_short_opts(rargs, values)
  File "/usr/lib/python2.4/optparse.py", line 1426, in _process_short_opts
    option.process(opt, value, values, self)
  File "/usr/lib/python2.4/optparse.py", line 707, in process
    return self.take_action(
  File "/usr/lib/python2.4/optparse.py", line 729, in take_action
    parser.exit()
  File "/usr/lib/python2.4/optparse.py", line 1449, in exit
    sys.exit(status)
SystemExit: 0


Michael DeHaan wrote:
> Jeremy Rosengren wrote:
>> This patch should fix the traceback that occurs when you run a 
>> command with -h (cobbler reposync -h).  Looking back through the 
>> history of cobbler.py, it looked like a simple matter of the 
>> conditional expressions becoming reversed in a recent commit.
>
> cobbler reposync -h works for me as is, from latest git, and in the 
> released version.
>
> What version of Cobbler are you using (rpm -q cobbler)?
> The code in question below is already correct, because it prints the 
> traceback only for non-cobbler ("CX") exceptions.
>
> --Michael
>
>
>>
>> Thanks,
>>
>> -- jeremy
>>
>> ---
>> cobbler/cobbler.py |    4 ++--
>> 1 files changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/cobbler/cobbler.py b/cobbler/cobbler.py
>> index fb9b273..0f201f7 100755
>> --- a/cobbler/cobbler.py
>> +++ b/cobbler/cobbler.py
>> @@ -56,9 +56,9 @@ def main():
>>         print str(exc)[1:-1]  # remove framing air quotes
>>     except Exception, exc2:
>>         if str(type(exc2)).find("CX") == -1:
>> -            traceback.print_exc()
>> -        else:
>>             print str(exc2)[1:-1]  # remove framing air quotes
>> +        else:
>> +            traceback.print_exc()
>>         return 1
>>     return 1
>>
>> -- 
>> 1.5.2.1
>>
>> _______________________________________________
>> et-mgmt-tools mailing list
>> et-mgmt-tools at redhat.com
>> https://www.redhat.com/mailman/listinfo/et-mgmt-tools
>
> _______________________________________________
> et-mgmt-tools mailing list
> et-mgmt-tools at redhat.com
> https://www.redhat.com/mailman/listinfo/et-mgmt-tools




More information about the et-mgmt-tools mailing list