class PyToApk(object): config = None commandArgs = None def __init__(self, cmdArgs): super(PyToApk, self).__init__() self.config = Config(os.path.dirname(os.path.realpath(__file__))) self.config.parseCmdArgs(cmdArgs) self.commandArgs = cmdArgs.commandArgs def executeTask(self, task): if not self.config.validateValues(): return False command = getattr(getattr(__import__('src.commands.' + task), 'commands'), task) success = False try: success = command.run(self.config, self.commandArgs) except KeyboardInterrupt: self.config.logger.error('Cancelling build due to interrupt.') except Exception as e: import traceback self.config.logger.error('Caught exception: ' + str(e)) output = self.config.logger.getOutput() output = sys.stderr if output == sys.stdout else output traceback.print_exception(*sys.exc_info(), file=output) finally: return success