def restore_item(self): backup_path = Functions.home + "/" + Functions.bd + "/" + self.backs.get_active_text() + "/" treeselect = self.treeView2.get_selection() (model, pathlist) = treeselect.get_selected_rows() if len(pathlist) > 0: GLib.idle_add(setProgress, self.progressbar, 0.1) GLib.idle_add(self.progressbar.set_pulse_step, 0.2) timeout_id = None timeout_id = GLib.timeout_add(100, do_pulse, None, self, self.progressbar) for path in pathlist : tree_iter = model.get_iter(path) value = model.get_value(tree_iter,0) file_path = backup_path + value if value.__len__() > 0: if os.path.isfile(file_path): Functions.copy_func(file_path, Functions.home + "/" + value.split("-backup")[0]) Functions.permissions(Functions.home + "/" + value.split("-backup")[0]) elif os.path.isdir(file_path): dirs = Functions.home + "/" + value.split("-backup")[0] # old_dir = Functions.home + "/" + value GLib.idle_add(setMessage,self.label_info, "Removing Existing Destination Folder ...") Functions.subprocess.call(["rm", "-rf", dirs]) GLib.idle_add(setMessage,self.label_info, "Copying " + value + " to " + value.split("-backup")[0]) Functions.copy_func(file_path, dirs, True) Functions.permissions(dirs) GLib.source_remove(timeout_id) timeout_id = None GLib.idle_add(button_toggles, self, True) GLib.idle_add(setMessage,self.label_info, "Idle ...") GLib.idle_add(setProgress, self.progressbar, 0)
def processing(self, active_text, label, progress): now = datetime.datetime.now() Functions.check_backups(now) GLib.idle_add(setProgress, progress, 0.1) GLib.idle_add(self.progressbar.set_pulse_step, 0.2) timeout_id = None timeout_id = GLib.timeout_add(100, do_pulse, None, self, progress) # ============================ # CONFIG # ============================ GLib.idle_add(setMessage, label, "Backing up .config") Functions.copy_func( Functions.home + '/.config', Functions.home + '/' + Functions.bd + "/Backup-" + now.strftime("%Y-%m-%d %H") + '/.config-backup-' + now.strftime("%Y-%m-%d %H:%M:%S"), True) Functions.permissions(Functions.home + '/' + Functions.bd + "/Backup-" + now.strftime("%Y-%m-%d %H") + '/.config-backup-' + now.strftime("%Y-%m-%d %H:%M:%S")) # GLib.idle_add(setProgress, self, 0.3) GLib.source_remove(timeout_id) timeout_id = None GLib.idle_add(setProgress, progress, 0.5) # ============================ # LOACAL # ============================ GLib.idle_add(setMessage, label, "Backing up .local") Functions.copy_func( Functions.home + '/.local', Functions.home + '/' + Functions.bd + "/Backup-" + now.strftime("%Y-%m-%d %H") + '/.local-backup-' + now.strftime("%Y-%m-%d %H:%M:%S"), True) Functions.permissions(Functions.home + '/' + Functions.bd + "/Backup-" + now.strftime("%Y-%m-%d %H") + '/.local-backup-' + now.strftime("%Y-%m-%d %H:%M:%S")) GLib.idle_add(setProgress, progress, 0.7) # ============================ # BASH # ============================ if os.path.isfile(Functions.home + '/.bashrc'): GLib.idle_add(setMessage, label, "Backing up .bashrc") Functions.copy_func( Functions.home + '/.bashrc', Functions.home + "/" + Functions.bd + "/Backup-" + now.strftime("%Y-%m-%d %H") + "/.bashrc-backup-" + now.strftime("%Y-%m-%d %H:%M:%S")) Functions.permissions(Functions.home + "/" + Functions.bd + "/Backup-" + now.strftime("%Y-%m-%d %H") + "/.bashrc-backup-" + now.strftime("%Y-%m-%d %H:%M:%S")) GLib.idle_add(setProgress, progress, 0.8) # ============================ # ZSH # ============================ if os.path.isfile(Functions.home + '/.zshrc'): GLib.idle_add(setMessage, label, "Backing up .zshrc") Functions.copy_func( Functions.home + '/.zshrc', Functions.home + "/" + Functions.bd + "/Backup-" + now.strftime("%Y-%m-%d %H") + "/.zshrc-backup-" + now.strftime("%Y-%m-%d %H:%M:%S")) Functions.permissions(Functions.home + "/" + Functions.bd + "/Backup-" + now.strftime("%Y-%m-%d %H") + "/.zshrc-backup-" + now.strftime("%Y-%m-%d %H:%M:%S")) GLib.idle_add(setProgress, progress, 0.9) # ============================ # CONKY # ============================ if os.path.exists(Functions.home + '/.lua'): GLib.idle_add(setMessage, label, "Backing up .lua") Functions.copy_func( Functions.home + '/.lua', Functions.home + '/' + Functions.bd + "/Backup-" + now.strftime("%Y-%m-%d %H") + '/.lua-backup-' + now.strftime("%Y-%m-%d %H:%M:%S"), True) Functions.permissions(Functions.home + '/' + Functions.bd + "/Backup-" + now.strftime("%Y-%m-%d %H") + '/.lua-backup-' + now.strftime("%Y-%m-%d %H:%M:%S")) if os.path.isfile(Functions.home + '/.conkyrc'): GLib.idle_add(setMessage, label, "Backing up .cokyrc") Functions.copy_func( Functions.home + '/.conkyrc', Functions.home + "/" + Functions.bd + "/Backup-" + now.strftime("%Y-%m-%d %H") + "/.conkyrc-backup-" + now.strftime("%Y-%m-%d %H:%M:%S")) Functions.permissions(Functions.home + "/" + Functions.bd + "/Backup-" + now.strftime("%Y-%m-%d %H") + "/.conkyrc-backup-" + now.strftime("%Y-%m-%d %H:%M:%S")) GLib.idle_add(setProgress, progress, 1.0) GLib.idle_add(setMessage, label, "Done") if not active_text == "BACKUP": pass GLib.idle_add(setMessage, label, "Running Skel") GLib.idle_add(skel_run, self, active_text) else: GLib.idle_add(button_toggles, self, True) GLib.idle_add(setMessage, label, "Idle...") GLib.idle_add(setProgress, progress, 0) GLib.idle_add(refresh, self) GLib.idle_add(refresh_inner, self)