def task_log(self, task_id, subtask=None, workunit_id=None): """ Returns the logfile for the given task. @param task - id of task @param subtask - task path to subtask, default = None @param workunut - workunit key, default = None """ from pydra.logs.logger import task_log_path if subtask: dir, logfile = task_log_path(task_id, subtask, workunit_id) else: dir, logfile = task_log_path(task_id) fp = open(logfile, 'r') log = fp.read() fp.close() return log
def task_log(self, task_id, subtask=None, workunit_id=None): """ Return the log file for the given task. :Parameters: task_id ID of the task. subtask Path to subtask, or None for no subtask. workunit_id Workunit key, or None for no workunit. """ if subtask: dir, logfile = task_log_path(task_id, subtask, workunit_id) else: dir, logfile = task_log_path(task_id) fp = open(logfile, 'r') log = fp.read() fp.close() return log
def print_logs(ids): ts = {} for id in ids: try: # look up log dir and main task.log file dir, logfile = task_log_path(id) # get all extra workunit files in dir files = os.listdir(dir) files.sort() files.remove('task.log') for f in files: file = open(dir+f, 'r') line = file.readline() line = line.split(' ', 2) line = "%s %s" % (line[0], line[1]) file.seek(0) ts[line] = file file = open(logfile, 'r') print_header(id, logfile) for line in file: timestamp = line.split(' ', 2) timestamp = "%s %s" % (timestamp[0], timestamp[1]) for key in ts.keys(): if key < timestamp: print "\t************" print "\tWorkunit Log" print "\t************" for l in ts[key]: print "\t"+l, del ts[key] print line, except IOError: print "FILE NOT FOUND!!!" print "Are the logs aggregated? Is the task ID correct?\n"