mechanic_command.py 文件源码

python
阅读 29 收藏 0 点赞 0 评论 0

项目:mechanic 作者: server-mechanic 项目源码 文件源码
def run(self):
    args = self.mechanic.commandLine
    if args.verbose:
      self.logger.setLevel(logging.DEBUG)
    else:
      self.logger.setLevel(logging.INFO)
    if not self.mechanic.config.getLogFile() in [ "", "/dev/stderr", "stderr" ]:
      makeparentdirs(self.mechanic.config.getLogFile()) 
      self.logger.addHandler(logging.FileHandler(self.mechanic.config.getLogFile()))

    command = self.mechanic.commands.get(args.commandName)
    try:
      if command is not None:
        command.run(args)
      else:
        self.mechanic.defaultCommand.run(args)
    except MigrationFailedException as e:
      self.logger.error(e.message)
      return 2
    except FollowUpCommandFailedException as e:
      self.logger.error(e.message)
      return 3
    except MechanicException as e:
      self.logger.error(e.message)
      return 1
    except Exception as e:
      self.logger.error(e)
      return 1
    finally:
      logging.shutdown()
    return 0
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号