def main(argv=None): args = None cmd = None try: args = parse_args(argv) # Init loglevel early in case we'll run # into errors before setting it properly CmdBase._set_loglevel(args) cmd = args.func(args) ret = cmd.run_cmd() except KeyboardInterrupt as ex: logger.error("Interrupted by the user", ex) ret = 252 except NotDvcProjectError as ex: logger.error("", ex) ret = 253 except DvcParserError: ret = 254 except Exception as ex: logger.error('Unexpected error', ex) ret = 255 Analytics().send_cmd(cmd, args, ret) return ret
def setUp(self): super(TestLoggerQuiet, self).setUp() class A(object): quiet = True verbose = False CmdBase._set_loglevel(A())
def test(self): class A(object): quiet = True verbose = False args = A() CmdBase._set_loglevel(args) self.assertEqual(Logger.logger().getEffectiveLevel(), logging.CRITICAL) args.quiet = False args.verbose = True CmdBase._set_loglevel(args) self.assertEqual(Logger.logger().getEffectiveLevel(), logging.DEBUG)
def main(argv=None): Logger.init() args = parse_args(argv) # Init loglevel early in case we'll run # into errors before setting it properly CmdBase._set_loglevel(args) try: cmd = args.func(args) except Exception as ex: Logger.error('Initialization error', ex) return 255 try: ret = cmd.run_cmd() except Exception as ex: Logger.error('Unexpected error', ex) return 254 return ret