def set_output_path(self, path): try: FGUtility.ensure_dir(path + "/" + self.filename) except: path = "./" self.filepath = path
def collect_files(self): """ this function gathers all eucalyptus log files that are located in all subdirectories starting from "from_path" and copies them into the specified backup directory. In addition all log file will be renamed based on the timestap in the last line of the log file. The fileame is date-time.cc.log where all items are separated with a "-". E.g. YYYY-MM-DD-HH-mm-ss-cc.log. If a logfile already exists with that name it will not be overwritten and the next file in the subdirectory will be attempted to be copied to backup. """ if not FGUtility.ensure_dir(self.output_dir + "/"): print "to_path '" + self.output_dir + "' doesn't exist" return if not os.path.exists(self.input_dir): print "from_path '" + self.input_dir + "' doesn't exist" return for file in self.file_list(): path = os.path.dirname(file) name = os.path.basename(file) new_name = os.path.basename(self.get_filename_from_date(path, name)) new_location = os.path.join(self.output_dir, new_name) if not os.path.exists(new_location): print new_name shutil.copy2(file, new_location) else: print new_name + ", WARNING: file exists, copy ignored" return
def set_output_path(self, directory): FGUtility.ensure_dir(directory + "/" + self.filename) self.filepath = directory