Пример #1
0
 def open_log_file(self):
     current_item = self.backups_tree_widget.currentItem()
     if current_item is None:
         return
     backup_name = current_item.whatsThis(0)
     if sys.platform == "darwin":
         subprocess.call(["open", get_log_file_path(backup_name)])
     else:
         webbrowser.open(get_log_file_path(backup_name))
Пример #2
0
 def run(self):
     while not self.exit:
         if self.backup is None or not os.path.exists(
                 get_log_file_path(self.backup.name)):
             time.sleep(0.01)
             continue
         self.reset = False
         with open(get_log_file_path(self.backup.name), "r") as f:
             f.seek(0, 2)
             while not self.reset:
                 line = f.readline()
                 if not line:
                     time.sleep(0.01)
                     continue
                 self.updated.emit(line)
Пример #3
0
 def __init__(self, backup, item, debug=False):
     QThread.__init__(self)
     self.backup = backup
     self.item = item
     try:
         self.repo = Repo(
             Utils.get_backend(backup),
             callback=lambda message: self.updated.emit(self.item, message),
             thread_count=backup.thread_count,
             compression_level=backup.compression_level,
             logger=setup_logger(self.backup.name,
                                 get_log_file_path(self.backup.name),
                                 logging.DEBUG if debug else logging.INFO))
     except Exception as e:
         print(e)
         self.error.emit(e)
Пример #4
0
    def __init__(self, backup, snapshot_id, restore_dir, paths, debug=False):
        QThread.__init__(self)
        self.backup = backup
        self.snapshot_id = snapshot_id
        self.restore_dir = restore_dir
        self.paths = paths

        try:
            self.repo = Repo(Utils.get_backend(backup),
                             callback=self.updated.emit,
                             thread_count=self.backup.thread_count,
                             compression_level=self.backup.compression_level,
                             logger=setup_logger(
                                 backup.name, get_log_file_path(backup.name),
                                 logging.DEBUG if debug else logging.INFO))
        except Exception as e:
            self.error.emit(e)
Пример #5
0
 def run(self, lines=LINES, buffer=BUFFER):
     self.started.emit()
     lines_found = []
     try:
         with open(get_log_file_path(self.backup_name), "r") as f:
             block_counter = -1
             while len(lines_found) < lines:
                 try:
                     f.seek(block_counter * buffer, os.SEEK_END)
                 except IOError:
                     f.seek(0)
                     lines_found = f.readlines()
                     break
                 lines_found = f.readlines()
                 block_counter -= 1
     except FileNotFoundError:
         pass
     finally:
         self.result.emit(lines_found[-lines:])