def greet(product, version, log_path, setup_status_program, status_program, login_program, terminfo): """Runs a custom greeter screen. PRODUCT is the product name to display VERSION is the product version to display LOG_PATH is a path to an error log in case the service is not running SETUP_STATUS_PROGRAM is a program with arguments to check if the service completed setup (exit 0 - setup complete, otherwise not launching yet) STATUS_PROGRAM is a program with arguments to check if the service is running (exit 0 - running, otherwise not) LOGIN_PROGRAM is the program to exec when the user chooses LOGIN """ with traceback_context(): try: if 'TERMINFO' not in os.environ: os.putenv('TERMINFO', terminfo) from . import greet return greet(product, version, log_path, setup_status_program, status_program, login_program) except: traceback.print_exc() os._exit(1)
def fire_actors(self): total = ActionResult(did_fire=False) with traceback_context(): for actor in self.actor_mgr.enabled_actors(): try: action_result = actor.fire() total.merge(action_result) except: _log.error('\n'.join(format_exception(sys.exc_type, sys.exc_value, sys.exc_traceback))) self.idle = not total.did_fire
def install(tty_dev, greeter_path): """Installs a greeter script for a specific tty. TTY_DEV is the tty device to install on (tty1, tty2, etc.). GREETER_PATH is a path to a greeter executable file (without arguments). """ with traceback_context(): try: from . import install install(tty_dev, greeter_path) except: traceback.print_exc() os._exit(1)
def decorator(*args, **kwargs): from logging import DEBUG, basicConfig, getLogger from datetime import datetime from infi.traceback import traceback_context from os import getpid, getuid basename = datetime.now().strftime("%Y-%m-%d.%H-%m-%S") filename = '/tmp/{}_{}_{}_{}.log'.format(func.__name__, basename, getpid(), getuid()) basicConfig(level=DEBUG, filemode='w', filename=filename) logger.info("Logging started") with traceback_context(): try: logger.info("Calling {}".format(func.__name__)) result = func(*args, **kwargs) logger.info("Call to {} returned {}".format(func.__name__, result)) return result except: logger.exception("Caught exception") raise finally: logger.info("Logging ended")
def decorator(*args, **kwargs): from infi.logging.wrappers import script_logging_context from logbook.concurrency import enable_gevent from infi.traceback import traceback_context from os import getpid, getuid from datetime import datetime from docopt import DocoptExit from sys import stderr import logbook if _bypass_console_script_logging: return f(*args, **kwargs) enable_gevent() filename = '/tmp/{}.log'.format(name if name else f.__name__) with script_logging_context( logfile_path=filename, logfile_max_size=20 * 1024 * 1024), traceback_context(), exception_handling_context(): logbook.set_datetime_format("local") logger.info("Calling {}".format(f.__name__)) result = f(*args, **kwargs) logger.info("Call to {} returned {}".format( f.__name__, result)) return result
def fire_actors(self, actor_ids=None): from infi.traceback import traceback_context traceback_context() return super(DebugScheduler, self).fire_actors(actor_ids)
def decorator(*args, **kwargs): from infi.logging.wrappers import script_logging_context from logbook.concurrency import enable_gevent from infi.traceback import traceback_context from os import getpid, getuid from datetime import datetime from docopt import DocoptExit from sys import stderr import logbook if _bypass_console_script_logging: return f(*args, **kwargs) enable_gevent() filename = '/tmp/{}.log'.format(name if name else f.__name__) with script_logging_context(logfile_path=filename, logfile_max_size=20 * 1024 * 1024), traceback_context(), exception_handling_context(): logbook.set_datetime_format("local") logger.info("Calling {}".format(f.__name__)) result = f(*args, **kwargs) logger.info("Call to {} returned {}".format(f.__name__, result)) return result
def test_context(): with traceback_context(): try: call() except: traceback.print_exc()