mirror of
https://github.com/borgbase/vorta
synced 2025-02-26 16:12:35 +00:00
Allow only one profile with --create. By @samuel-w (#744)
This commit is contained in:
parent
dae35bf4c7
commit
bbc5b85b81
2 changed files with 14 additions and 22 deletions
|
@ -2,7 +2,6 @@
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
import ast
|
|
||||||
|
|
||||||
from PyQt5 import QtCore
|
from PyQt5 import QtCore
|
||||||
from PyQt5.QtWidgets import QMessageBox
|
from PyQt5.QtWidgets import QMessageBox
|
||||||
|
@ -50,7 +49,7 @@ def __init__(self, args_raw, single_app=False):
|
||||||
sys.exit()
|
sys.exit()
|
||||||
elif args.profile:
|
elif args.profile:
|
||||||
self.sendMessage(f"create {args.profile}")
|
self.sendMessage(f"create {args.profile}")
|
||||||
print('Creating backups using existing Vorta instance.')
|
print('Creating backup using existing Vorta instance.')
|
||||||
sys.exit()
|
sys.exit()
|
||||||
elif args.profile:
|
elif args.profile:
|
||||||
sys.exit('Vorta must already be running for --create to work')
|
sys.exit('Vorta must already be running for --create to work')
|
||||||
|
@ -78,16 +77,11 @@ def __init__(self, args_raw, single_app=False):
|
||||||
self.set_borg_details_action()
|
self.set_borg_details_action()
|
||||||
self.installEventFilter(self)
|
self.installEventFilter(self)
|
||||||
|
|
||||||
def create_backups_cmdline(self, profiles):
|
def create_backups_cmdline(self, profile_name):
|
||||||
self.completedProfiles = []
|
|
||||||
self.validProfiles = []
|
|
||||||
for profile_name in profiles:
|
|
||||||
profile = BackupProfileModel.get_or_none(name=profile_name)
|
profile = BackupProfileModel.get_or_none(name=profile_name)
|
||||||
if profile is not None:
|
if profile is not None:
|
||||||
if profile.repo is None:
|
if profile.repo is None:
|
||||||
logger.warning(f"Add a repository to {profile_name}")
|
logger.warning(f"Add a repository to {profile_name}")
|
||||||
continue
|
|
||||||
self.validProfiles.append(profile_name)
|
|
||||||
# Wait a bit in case something is running
|
# Wait a bit in case something is running
|
||||||
while BorgThread.is_running():
|
while BorgThread.is_running():
|
||||||
time.sleep(0.1)
|
time.sleep(0.1)
|
||||||
|
@ -144,11 +138,10 @@ def message_received_event_response(self, message):
|
||||||
self.open_main_window_action()
|
self.open_main_window_action()
|
||||||
elif message.startswith("create"):
|
elif message.startswith("create"):
|
||||||
message = message[7:] # Remove create
|
message = message[7:] # Remove create
|
||||||
profiles = ast.literal_eval(message) # Safely parse string array
|
|
||||||
if BorgThread.is_running():
|
if BorgThread.is_running():
|
||||||
logger.warning("Cannot run while backups are already running")
|
logger.warning("Cannot run while backups are already running")
|
||||||
else:
|
else:
|
||||||
self.create_backups_cmdline(profiles)
|
self.create_backups_cmdline(message)
|
||||||
|
|
||||||
def set_borg_details_action(self):
|
def set_borg_details_action(self):
|
||||||
params = BorgVersionThread.prepare()
|
params = BorgVersionThread.prepare()
|
||||||
|
|
|
@ -240,9 +240,8 @@ def parse_args():
|
||||||
help="Fork to background and don't open window on startup.")
|
help="Fork to background and don't open window on startup.")
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--create',
|
'--create',
|
||||||
nargs='+',
|
|
||||||
dest='profile',
|
dest='profile',
|
||||||
help='Create a backup in the background using the given profile(s). '
|
help='Create a backup in the background using the given profile. '
|
||||||
'Vorta must already be running for this to work.')
|
'Vorta must already be running for this to work.')
|
||||||
|
|
||||||
return parser.parse_known_args()[0]
|
return parser.parse_known_args()[0]
|
||||||
|
|
Loading…
Reference in a new issue