def _main(argv): from gevent.monkey import patch_all patch_all(subprocess=True) # We do the imports here so that Ctrl+C doesn't show any ugly traceback import sys import optparse import logging import atexit from yaybu.core.util import version from yaybu.core import command parser = optparse.OptionParser(version=version(), usage=usage) parser.disable_interspersed_args() parser.add_option("-p", "--ypath", default=[], action="append") parser.add_option("", "--log-facility", default="2", help="the syslog local facility number to which to write the audit trail") parser.add_option("", "--log-level", default="info", help="the minimum log level to write to the audit trail") parser.add_option("-d", "--debug", default=False, action="store_true", help="switch all logging to maximum, and write out to the console") parser.add_option("-l", "--logfile", default=None, help="The filename to write the audit log to, instead of syslog. Note: the standard console log will still be written to the console.") parser.add_option("-v", "--verbose", default=2, action="count", help="Write additional informational messages to the console log. repeat for even more verbosity.") parser.add_option("-C", "--config", default=None, action="store", help="Path to main yay config file") opts, args = parser.parse_args(argv or sys.argv[1:]) # we need to revisit how logging is handled logging.basicConfig( format="%(asctime)s %(name)s %(levelname)s %(message)s") if opts.debug: root = logging.getLogger() root.setLevel(logging.DEBUG) opts.logfile = "-" opts.verbose = 2 logging.getLogger("paramiko.transport").setLevel(logging.CRITICAL) atexit.register(logging.shutdown) com = command.YaybuCmd(config=opts.config, verbose=opts.verbose, ypath=opts.ypath, logfile=opts.logfile, debug=opts.debug) if args: com.interactive_shell = False sys.exit(com.onecmd(" ".join(args)) or 0) else: com.cmdloop()
def preloop(self): print util.version() print ""
def _main(argv): from gevent.monkey import patch_all patch_all(subprocess=True) # We do the imports here so that Ctrl+C doesn't show any ugly traceback import sys import optparse import logging import atexit from yaybu.core.util import version from yaybu.core import command parser = optparse.OptionParser(version=version(), usage=usage) parser.disable_interspersed_args() parser.add_option("-p", "--ypath", default=[], action="append") parser.add_option( "", "--log-facility", default="2", help="the syslog local facility number to which to write the audit trail" ) parser.add_option("", "--log-level", default="info", help="the minimum log level to write to the audit trail") parser.add_option( "-d", "--debug", default=False, action="store_true", help="switch all logging to maximum, and write out to the console", ) parser.add_option( "-l", "--logfile", default=None, help="The filename to write the audit log to, instead of syslog. Note: the standard console log will still be written to the console.", ) parser.add_option( "-v", "--verbose", default=2, action="count", help="Write additional informational messages to the console log. repeat for even more verbosity.", ) parser.add_option("-C", "--config", default=None, action="store", help="Path to main yay config file") opts, args = parser.parse_args(argv or sys.argv[1:]) # we need to revisit how logging is handled logging.basicConfig(format="%(asctime)s %(name)s %(levelname)s %(message)s") if opts.debug: root = logging.getLogger() root.setLevel(logging.DEBUG) opts.logfile = "-" opts.verbose = 2 logging.getLogger("paramiko.transport").setLevel(logging.CRITICAL) atexit.register(logging.shutdown) com = command.YaybuCmd( config=opts.config, verbose=opts.verbose, ypath=opts.ypath, logfile=opts.logfile, debug=opts.debug ) if args: com.interactive_shell = False sys.exit(com.onecmd(" ".join(args)) or 0) else: com.cmdloop()
def preloop(self): print util.version() print ""