Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions src/vorta/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ def __init__(self, args_raw, single_app=False):
elif args.profile:
self.sendMessage(f"create {args.profile}")
logger.info('Creating backup using existing Vorta instance.')
sys.exit()
elif args.profile:
sys.exit('Vorta must already be running for --create to work')

Expand Down Expand Up @@ -92,7 +91,7 @@ def create_backups_cmdline(self, profile_name):
if profile is not None:
if profile.repo is None:
logger.warning(f"Add a repository to {profile_name}")
self.create_backup_action(profile_id=profile.id)
self.create_backup_action(profile_id=profile.id, cmd_line=True)
else:
logger.warning(f"Invalid profile name {profile_name}")

Expand All @@ -103,14 +102,16 @@ def quit_app_action(self):
del self.tray
cleanup_db()

def create_backup_action(self, profile_id=None):
def create_backup_action(self, profile_id=None, cmd_line=False):
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)
if cmd_line:
job.result.connect(self.create_backup_cmdline_response)
self.jobs_manager.add_job(job)
else:
notifier = VortaNotifications.pick()
Expand All @@ -122,6 +123,9 @@ def create_backup_action(self, profile_id=None):
self.backup_progress_event.emit(translate('messages', msg['message']))
return None

def create_backup_cmdline_response(self, result):
self.reply(f"created {result['data']['archive']['name']}")

def open_main_window_action(self):
self.main_window.show()
self.main_window.raise_()
Expand All @@ -147,6 +151,9 @@ def backup_cancelled_event_response(self):
def message_received_event_response(self, message):
if message == "open main window":
self.open_main_window_action()
elif message.startswith("created"):
logger.debug(f"Backup created: {message[8:]}")
Comment thread
diivi marked this conversation as resolved.
Outdated
sys.exit()
elif message.startswith("create"):
message = message[7:] # Remove create
if self.jobs_manager.is_worker_running():
Expand Down
13 changes: 13 additions & 0 deletions src/vorta/qt_single_application.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ def __init__(self, id, *argv):
# Yes, there is.
self._outStream = QTextStream(self._outSocket)
self._outStream.setCodec('UTF-8')
self._outSocket.readyRead.connect(self._onReadyReply)
else:
# No, there isn't.
self._outSocket = None
Expand Down Expand Up @@ -93,3 +94,15 @@ def _onReadyRead(self):
if not msg:
break
self.message_received_event.emit(msg)

def _onReadyReply(self):
while True:
msg = self._outStream.readLine()
if not msg:
break
self.message_received_event.emit(msg)

def reply(self, msg):
self._inStream << msg << '\n'
self._inStream.flush()
self._inSocket.waitForBytesWritten()