Example #1
0
def process_log_file(name, directory, start_time=None):
    # Find one log file #
    if not directory.endswith('/') : directory = directory + '/'
    logs = list(find_files_by_regex('mothur.[0-9]+.logfile'))
    if len(logs) > 1: raise Exception("Found more than one mothur log file in '%s'" % os.getcwd())
    path = logs[0]
    # Add time #
    prepend_to_file(path, "Start time: " + start_time + "\n")
    append_to_file(path, "\nEnd time: " + time.asctime())
    # Move it #
    destination = directory + name
    shutil.move(path, directory + name)
    # Check for error #
    raw = open(destination, 'r').read()
    if re.findall('\[ERROR\]', raw, re.M):
        shutil.move(destination, directory + name.upper())
        raise Exception("Mothur log file reports an error in step '%s'" % name)
    if os.path.exists(directory + name.upper()): os.remove(directory + name.upper())
Example #2
0
 def append(self, what):
     """Append some text or an other file to the current file"""
     if isinstance(what, FilePath): what = what.contents
     append_to_file(self.path, what)
Example #3
0
 def append(self, what):
     """Append some text or an other file to the current file"""
     if isinstance(what, FilePath): what = what.contents
     append_to_file(self.path, what)