def create_backup(self, profile_id): notifier = VortaNotifications.pick() profile = BackupProfileModel.get(id=profile_id) logger.info('Starting background backup for %s', profile.name) notifier.deliver(self.tr('Vorta Backup'), self.tr('Starting background backup for %s.') % profile.name, level='info') msg = BorgCreateThread.prepare(profile) if msg['ok']: logger.info('Preparation for backup successful.') thread = BorgCreateThread(msg['cmd'], msg) thread.start() thread.wait() if thread.process.returncode in [0, 1]: notifier.deliver(self.tr('Vorta Backup'), self.tr('Backup successful for %s.') % profile.name, level='info') logger.info('Backup creation successful.') self.post_backup_tasks(profile_id) else: notifier.deliver(self.tr('Vorta Backup'), self.tr('Error during backup creation.'), level='error') logger.error('Error during backup creation.') else: logger.error('Conditions for backup not met. Aborting.') logger.error(msg['message']) notifier.deliver(self.tr('Vorta Backup'), translate('messages', msg['message']), level='error')
def create_backup_action(self, profile_id=None): if not profile_id: profile_id = self.main_window.current_profile.id profile = BackupProfileModel.get(id=profile_id) msg = BorgCreateJob.prepare(profile) if msg['ok']: job = BorgCreateJob(msg['cmd'], msg, profile.repo.id) self.jobs_manager.add_job(job) else: notifier = VortaNotifications.pick() notifier.deliver(self.tr('Vorta Backup'), translate('messages', msg['message']), level='error') self.backup_progress_event.emit( translate('messages', msg['message'])) return None
def exception_handler(type, value, tb): from traceback import format_exception from PyQt5.QtWidgets import QMessageBox logger.critical( "Uncaught exception, file a report at https://github.com/borgbase/vorta/issues/new", exc_info=(type, value, tb)) full_exception = ''.join(format_exception(type, value, tb)) title = trans_late('app', 'Fatal Error') error_message = trans_late( 'app', 'Uncaught exception, please file a report with this text at\n' 'https://github.com/borgbase/vorta/issues/new\n') if app: QMessageBox.critical( None, translate('app', title), translate('app', error_message) + full_exception) else: # Crashed before app startup, cannot translate sys.exit(1)
def password_listener(self): ''' Validates passwords only if its going to be used ''' if self.values['encryption'] == 'none': self.passwordLabel.setText("") return True else: firstPass = self.passwordLineEdit.text() secondPass = self.confirmLineEdit.text() msg = validate_passwords(firstPass, secondPass) self.passwordLabel.setText(translate('utils', msg)) return not bool(msg)
def receive(): extraction_folder = dialog.selectedFiles() if extraction_folder: params = BorgExtractThread.prepare( self.profile(), archive.name, window.selected, extraction_folder[0]) if params['ok']: self._toggle_all_buttons(False) thread = BorgExtractThread(params['cmd'], params, parent=self) thread.updated.connect(self.mountErrors.setText) thread.result.connect(self.extract_archive_result) thread.start() else: self._set_status(translate(params['message']))
def __init__(self, parent=None): super().__init__(parent) self.setupUi(parent) self.versionLabel.setText(__version__) self.logLink.setText(f'<a href="file://{LOG_DIR}"><span style="text-decoration:' 'underline; color:#0984e3;">Log</span></a>') for setting in SettingsModel.select().where(SettingsModel.type == 'checkbox'): x = filter(lambda s: s['key'] == setting.key, get_misc_settings()) if not list(x): # Skip settings that aren't specified in vorta.models. continue b = QCheckBox(translate('settings', setting.label)) b.setCheckState(setting.value) b.setTristate(False) b.stateChanged.connect(lambda v, key=setting.key: self.save_setting(key, v)) self.checkboxLayout.addWidget(b)
def __init__(self, parent=None): super().__init__(parent) self.setupUi(parent) self.versionLabel.setText(__version__) for setting in SettingsModel.select().where( SettingsModel.type == 'checkbox'): x = filter(lambda s: s['key'] == setting.key, get_misc_settings()) if not list( x): # Skip settings that aren't specified in vorta.models. continue b = QCheckBox(translate('settings', setting.label)) b.setCheckState(setting.value) b.setTristate(False) b.stateChanged.connect( lambda v, key=setting.key: self.save_setting(key, v)) self.checkboxLayout.addWidget(b)
def check_action(self): params = BorgCheckThread.prepare(self.profile()) if not params['ok']: self._set_status(translate(params['message'])) return # Conditions are met (borg binary available, etc) row_selected = self.archiveTable.selectionModel().selectedRows() if row_selected: archive_cell = self.archiveTable.item(row_selected[0].row(), 4) if archive_cell: archive_name = archive_cell.text() params['cmd'][-1] += f'::{archive_name}' thread = BorgCheckThread(params['cmd'], params, parent=self) thread.updated.connect(self._set_status) thread.result.connect(self.check_result) self._toggle_all_buttons(False) thread.start()
def populate(self): # clear layout while self.checkboxLayout.count(): child = self.checkboxLayout.takeAt(0) if child.widget(): child.widget().deleteLater() # dynamically add widgets for settings for setting in SettingsModel.select().where( SettingsModel.type == 'checkbox'): x = filter(lambda s: s['key'] == setting.key, get_misc_settings()) if not list( x): # Skip settings that aren't specified in vorta.models. continue b = QCheckBox(translate('settings', setting.label)) b.setCheckState(setting.value) b.setTristate(False) b.stateChanged.connect( lambda v, key=setting.key: self.save_setting(key, v)) self.checkboxLayout.addWidget(b)
def delete_action(self): params = BorgDeleteThread.prepare(self.profile()) if not params['ok']: self._set_status(translate(params['message'])) return archive_name = self.selected_archive_name() if archive_name is not None: if not self.confirm_dialog( trans_late('ArchiveTab', "Confirm deletion"), trans_late( 'ArchiveTab', "Are you sure you want to delete the archive?")): return params['cmd'][-1] += f'::{archive_name}' thread = BorgDeleteThread(params['cmd'], params, parent=self) thread.updated.connect(self._set_status) thread.result.connect(self.delete_result) self._toggle_all_buttons(False) thread.start() else: self._set_status(self.tr("No archive selected"))
def umount_action(self): archive_name = self.selected_archive_name() mount_point = self.mount_points.get(archive_name) if mount_point is not None: profile = self.profile() params = BorgUmountThread.prepare(profile) if not params['ok']: self._set_status(translate(params['message'])) return params['current_archive'] = archive_name if os.path.normpath(mount_point) in params['active_mount_points']: params['cmd'].append(mount_point) thread = BorgUmountThread(params['cmd'], params, parent=self) thread.updated.connect(self.mountErrors.setText) thread.result.connect(self.umount_result) thread.start() else: self._set_status(self.tr('Mount point not active.')) return
def tr(self, *args, **kwargs): scope = self.__class__.__name__ return translate(scope, *args, **kwargs)
def display_password_backend(self): self.passwordLabel.setText(translate('utils', display_password_backend(self.encryptionComboBox.currentData())))