rhoskal / crispy-fortnight

Custom Python 2.7 RAT
MIT License
11 stars 9 forks source link

cmd.cmdloop() -h bug #7

Closed rhoskal closed 8 years ago

rhoskal commented 8 years ago

prints help successfully but then immediately closes. that works for command line arg when running a program first from the terminal, but that doesn't work when we need it to keep looping. Maybe update custom Argparser class to override help()?

rhoskal commented 8 years ago

partially fixed... "sessions -h" throws new error

Traceback (most recent call last): File "crispyd.py", line 60, in main() File "crispyd.py", line 55, in main CrispyCLI(srv).cmdloop() File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/cmd.py", line 142, in cmdloop stop = self.onecmd(line) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/cmd.py", line 221, in onecmd return func(arg) File "...cli.py", line 175, in do_sessions if isinstance(pargs.interact, int): AttributeError: 'NoneType' object has no attribute 'interact'

jchristman commented 8 years ago

When the SystemExit is raised, None is returned. Therefore, check

if pargs is None:
    return

right before you check pargs.interact.

rhoskal commented 8 years ago

Absolutely! thanks. I also had to force a parser.print_help() when a user types just "sessions" w/ no args. For some odd reasons the argparse class wasn't behaving like the others. this class has frustrated me so much.