Esempio n. 1
0
def main():
    try:
        locale.setlocale(locale.LC_ALL, '')
    except locale.Error:
        print('No locale available')
        sys.exit(2)

    py3 = None
    try:
        py3 = Py3statusWrapper()
        py3.setup()
    except (IOPipeError, KeyboardInterrupt):
        if py3:
            py3.notify_user('Setup interrupted')
        sys.exit(0)
    except Exception:
        if py3 and not py3.config.get('cli_command'):
            py3.report_exception('Setup error')
        else:
            # we cannot report this Exception
            raise
        sys.exit(2)

    try:
        py3.run()
    except (IOPipeError, KeyboardInterrupt):
        pass
    except Exception:
        py3.report_exception('Runtime error')
        sys.exit(3)
    finally:
        py3.stop()
        sys.exit(0)
Esempio n. 2
0
def main():
    try:
        locale.setlocale(locale.LC_ALL, '')
    except locale.Error:
        print('No locale available')
        sys.exit(2)

    py3 = None
    try:
        py3 = Py3statusWrapper()
        py3.setup()
    except KeyboardInterrupt:
        if py3:
            py3.notify_user('Setup interrupted (KeyboardInterrupt).')
        sys.exit(0)
    except Exception as e:
        if py3:
            py3.report_exception('Setup error')
        else:
            # we cannot report this Exception
            raise e
        sys.exit(2)

    try:
        py3.run()
    except Exception:
        py3.report_exception('Runtime error')
        sys.exit(3)
    except KeyboardInterrupt:
        pass
    finally:
        py3.stop()
        sys.exit(0)
Esempio n. 3
0
def main():
    from py3status.cli import parse_cli

    options = parse_cli()
    # detect gevent option early because monkey patching should be done before
    # everything else starts kicking
    if options.gevent:
        try:
            from gevent import monkey

            monkey.patch_all()
        except Exception:
            # user will be notified when we start
            pass

    from py3status.core import Py3statusWrapper

    try:
        locale.setlocale(locale.LC_ALL, "")
    except locale.Error:
        print("No locale available")
        sys.exit(2)

    py3 = None
    try:
        py3 = Py3statusWrapper(options)
        py3.setup()
    except (IOPipeError, KeyboardInterrupt):
        if py3:
            py3.notify_user("Setup interrupted")
        sys.exit(0)
    except Exception:
        if py3 and not py3.config.get("cli_command"):
            py3.report_exception("Setup error")
        else:
            # we cannot report this Exception
            raise
        sys.exit(2)

    try:
        py3.run()
    except (IOPipeError, KeyboardInterrupt):
        pass
    except Exception:
        py3.report_exception("Runtime error")
        sys.exit(3)
    finally:
        py3.stop()
        sys.exit(0)
Esempio n. 4
0
def main():
    from py3status.argparsers import parse_cli_args

    options = parse_cli_args()
    # detect gevent option early because monkey patching should be done before
    # everything else starts kicking
    if options.gevent:
        try:
            from gevent import monkey

            monkey.patch_all()
        except Exception:
            # user will be notified when we start
            pass

    from py3status.core import Py3statusWrapper

    try:
        locale.setlocale(locale.LC_ALL, "")
    except locale.Error as err:
        print(f"No locale available ({err})")
        sys.exit(2)

    py3 = None
    try:
        py3 = Py3statusWrapper(options)
        py3.setup()
    except (BrokenPipeError, KeyboardInterrupt) as err:
        if py3:
            py3.notify_user(f"Setup interrupted ({err})")
        sys.exit(0)
    except Exception as err:
        if py3:
            py3.report_exception(f"Setup error ({err})")
        else:
            # we cannot report this Exception
            raise
        sys.exit(2)

    try:
        py3.run()
    except (BrokenPipeError, KeyboardInterrupt):
        pass
    except Exception as err:
        py3.report_exception(f"Runtime error ({err})")
        sys.exit(3)
    finally:
        py3.stop()
        sys.exit(0)
Esempio n. 5
0
def main():
    # detect gevent option early because monkey patching should be done before
    # everything else starts kicking
    if '-g' in sys.argv or '--gevent' in sys.argv:
        try:
            from gevent import monkey
            monkey.patch_all()
        except Exception:
            # user will be notified when we start
            pass

    from py3status.core import Py3statusWrapper
    try:
        locale.setlocale(locale.LC_ALL, '')
    except locale.Error:
        print('No locale available')
        sys.exit(2)

    py3 = None
    try:
        py3 = Py3statusWrapper()
        py3.setup()
    except (IOPipeError, KeyboardInterrupt):
        if py3:
            py3.notify_user('Setup interrupted')
        sys.exit(0)
    except Exception:
        if py3 and not py3.config.get('cli_command'):
            py3.report_exception('Setup error')
        else:
            # we cannot report this Exception
            raise
        sys.exit(2)

    try:
        py3.run()
    except (IOPipeError, KeyboardInterrupt):
        pass
    except Exception:
        py3.report_exception('Runtime error')
        sys.exit(3)
    finally:
        py3.stop()
        sys.exit(0)
Esempio n. 6
0
def main():
    try:
        locale.setlocale(locale.LC_ALL, '')
        py3 = Py3statusWrapper()
        py3.setup()
    except KeyboardInterrupt:
        py3.notify_user('Setup interrupted (KeyboardInterrupt).')
        sys.exit(0)
    except Exception:
        py3.report_exception('Setup error')
        sys.exit(2)

    try:
        py3.run()
    except Exception:
        py3.report_exception('Runtime error')
        sys.exit(3)
    except KeyboardInterrupt:
        pass
    finally:
        py3.stop()
        sys.exit(0)
Esempio n. 7
0
def make_status_wrapper():
    args = argparse.Namespace()
    status_wrapper = Py3statusWrapper(args)
    return status_wrapper