diff options
Diffstat (limited to 'extra/usb_serial/console.py')
-rwxr-xr-x | extra/usb_serial/console.py | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/extra/usb_serial/console.py b/extra/usb_serial/console.py index 36cd52c361..2494c59c79 100755 --- a/extra/usb_serial/console.py +++ b/extra/usb_serial/console.py @@ -242,7 +242,14 @@ parser.add_argument('-s', '--serialno', type=str, help="serial number of device", default="") -def main(): +def runconsole(): + """Run the usb console code + + Starts the pty thread, and idles until a ^C is caught. + + Raises: + KeyboardInterrupt on ^C. + """ args = parser.parse_args() vidstr, pidstr = args.device.split(':') @@ -264,7 +271,7 @@ def main(): while sobj.running(): time.sleep(.1) -if __name__ == '__main__': +def main(): global old_settings global fd try: @@ -274,7 +281,7 @@ if __name__ == '__main__': except: pass try: - main() + runconsole() except KeyboardInterrupt: sobj.exit() except Exception as e: @@ -285,3 +292,7 @@ if __name__ == '__main__': traceback.print_exc() finally: force_exit() + + +if __name__ == '__main__': + main() |