コード例 #1
0
ファイル: task.py プロジェクト: PaulSV123/CMB-cambio
 def run(self):
     try:
         if not os.path.exists(self.outputFile):
             Configs.log("Running a task, output file: {}".format(
                 self.outputFile))
             mod = importlib.import_module(
                 Task.functionModuleMap[self.taskType])
             func = getattr(mod, self.taskType)
             func(**self.taskArgs)
             Configs.log("Completed a task, output file: {}".format(
                 self.outputFile))
         else:
             Configs.log("File already exists: {}".format(self.outputFile))
     except Exception as exc:
         Configs.error("Task for {} threw an exception:\n{}".format(
             self.outputFile, exc))
         Configs.error(traceback.format_exc())
         raise
     finally:
         self.isFinished = True
コード例 #2
0
def main():
    '''
    Resolve the args/configs, spin up the task manager (which deals with worker threads and handles parallelism), 
    and get started on the main alignment task. 
    '''

    startTime = time.time()
    args = parseArgs()
    buildConfigs(args)
    Configs.log("MAGUS was run with: {}".format(" ".join(sys.argv)))

    try:
        manager.startTaskManager()
        mainAlignmentTask()
    except:
        Configs.error("MAGUS aborted with an exception..")
        Configs.error(traceback.format_exc())
    finally:
        manager.stopTaskManager()

    endTime = time.time()
    Configs.log("MAGUS finished in {} seconds..".format(endTime - startTime))
コード例 #3
0
def runCommand(**kwargs):
    command = kwargs["command"]
    Configs.log("Running an external tool, command: {}".format(command))
    runner = subprocess.run(command, shell = True, cwd = kwargs["workingDir"], universal_newlines = True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
    try:    
        runner.check_returncode()
    except:
        Configs.error("Command encountered error: {}".format(command))
        Configs.error("Exit code: {}".format(runner.returncode))
        Configs.error("Output: {}".format(runner.stdout))
        raise
    for srcPath, destPath in kwargs.get("fileCopyMap", {}).items():
        shutil.move(srcPath, destPath)
コード例 #4
0
def checkTaskManager():
    if not TaskManager.managerFuture.running():
        Configs.error("Task manager is dead for some reason..")
        TaskManager.managerFuture.result()
        raise Exception("Task manager is dead for some reason..")