]> git.donarmstrong.com Git - deb_pkgs/autorandr.git/commitdiff
Wrap ifmain code in a function
authorPhillip Berndt <phillip.berndt@googlemail.com>
Wed, 30 Nov 2016 11:48:20 +0000 (12:48 +0100)
committerPhillip Berndt <phillip.berndt@googlemail.com>
Wed, 30 Nov 2016 11:48:33 +0000 (12:48 +0100)
autorandr.py

index af1c8c3becda2fd7c7c67bd2f93b042ffb54816c..aa4b8f2483169ac1c38175c7a630c21e462291f3 100755 (executable)
@@ -1040,7 +1040,7 @@ def main(argv):
 
     sys.exit(0)
 
-if __name__ == '__main__':
+def exception_handled_main(argv=sys.argv):
     try:
         main(sys.argv)
     except AutorandrException as e:
@@ -1053,3 +1053,6 @@ if __name__ == '__main__':
 
         print("Unhandled exception ({0}). Please report this as a bug at https://github.com/phillipberndt/autorandr/issues.".format(e), file=sys.stderr)
         raise
+
+if __name__ == '__main__':
+    exception_handled_main()