Beispiel #1
0
def main():
    args = parse_args()
    signal.signal(signal.SIGINT, signal.SIG_DFL)  # catch ctrl-c and exit

    frozen_binary = getattr(sys, 'frozen', False)
    want_version = getattr(args, 'version', False)
    want_foreground = getattr(args, 'foreground', False)

    if want_version:
        print(f"Vorta {__version__}")
        sys.exit()

    # We assume that a frozen binary is a fat single-file binary made with
    # PyInstaller. These are not compatible with forking into background here:
    if not (want_foreground or frozen_binary):
        if os.fork():
            sys.exit()

    init_logger(foreground=want_foreground)

    # Init database
    sqlite_db = peewee.SqliteDatabase(os.path.join(SETTINGS_DIR,
                                                   'settings.db'))
    init_db(sqlite_db)

    # Init app after database is available
    from vorta.application import VortaApp
    app = VortaApp(sys.argv, single_app=True)
    app.updater = get_updater()

    # Force fusion style on Linux
    if sys.platform.startswith('linux'):
        app.setStyle('Fusion')

    sys.exit(app.exec_())
Beispiel #2
0
def main():
    args = parse_args()

    frozen_binary = getattr(sys, 'frozen', False)

    # Don't fork if user specifies it or when running from onedir app bundle on macOS.
    if hasattr(args, 'foreground') or (frozen_binary
                                       and sys.platform == 'darwin'):
        pass
    else:
        print('Forking to background (see system tray).')
        if os.fork():
            sys.exit()

    # Init database
    sqlite_db = peewee.SqliteDatabase(os.path.join(SETTINGS_DIR,
                                                   'settings.db'))
    init_db(sqlite_db)

    # Send crashes to Sentry.
    if SettingsModel.get(key='send_sentry_reports').value:
        vorta.sentry.init()

    app = VortaApp(sys.argv, single_app=True)
    app.updater = get_updater()

    sys.exit(app.exec_())
Beispiel #3
0
    def __init__(self, args_raw, single_app=False):

        super().__init__(APP_ID, args_raw)
        if self.isRunning() and single_app:
            self.sendMessage("open main window")
            print('An instance of Vorta is already running. Opening main window.')
            sys.exit()

        init_translations(self)

        self.setQuitOnLastWindowClosed(False)
        self.scheduler = VortaScheduler(self)

        # Prepare system tray icon
        self.tray = TrayMenu(self)

        args = parse_args()
        if getattr(args, 'daemonize', False):
            pass
        elif SettingsModel.get(key='foreground').value:
            self.open_main_window_action()

        self.backup_started_event.connect(self.backup_started_event_response)
        self.backup_finished_event.connect(self.backup_finished_event_response)
        self.backup_cancelled_event.connect(self.backup_cancelled_event_response)
        self.message_received_event.connect(self.message_received_event_response)
        self.set_borg_details_action()
        self.installEventFilter(self)
Beispiel #4
0
def main():
    args = parse_args()
    signal.signal(signal.SIGINT, signal.SIG_DFL)  # catch ctrl-c and exit

    want_version = getattr(args, 'version', False)
    want_background = getattr(args, 'daemonize', False)

    if want_version:
        print(f"Vorta {__version__}")
        sys.exit()

    if want_background:
        if os.fork():
            sys.exit()

    init_logger(background=want_background)

    # Init database
    sqlite_db = peewee.SqliteDatabase(os.path.join(SETTINGS_DIR,
                                                   'settings.db'))
    init_db(sqlite_db)

    # Init app after database is available
    from vorta.application import VortaApp
    app = VortaApp(sys.argv, single_app=True)
    app.updater = get_updater()

    sys.exit(app.exec_())
Beispiel #5
0
def main():
    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)

    sys.excepthook = exception_handler
    app = None

    args = parse_args()
    signal.signal(signal.SIGINT, signal.SIG_DFL)  # catch ctrl-c and exit

    want_version = getattr(args, 'version', False)
    want_background = getattr(args, 'daemonize', False)

    if want_version:
        print(f"Vorta {__version__}")
        sys.exit()

    if want_background:
        if os.fork():
            sys.exit()

    init_logger(background=want_background)

    # Init database
    sqlite_db = peewee.SqliteDatabase(os.path.join(SETTINGS_DIR,
                                                   'settings.db'),
                                      pragmas={
                                          'journal_mode': 'wal',
                                      })
    init_db(sqlite_db)

    # Init app after database is available
    from vorta.application import VortaApp
    app = VortaApp(sys.argv, single_app=args.profile is None)
    app.updater = get_updater()

    sys.exit(app.exec())
Beispiel #6
0
    def __init__(self, args_raw, single_app=False):
        super().__init__(APP_ID, args_raw)
        args = parse_args()
        if self.isRunning():
            if single_app:
                self.sendMessage("open main window")
                print(
                    'An instance of Vorta is already running. Opening main window.'
                )
                sys.exit()
            elif args.profile:
                self.sendMessage(f"create {args.profile}")
                print('Creating backup using existing Vorta instance.')
                sys.exit()
        elif args.profile:
            sys.exit('Vorta must already be running for --create to work')

        init_translations(self)

        self.setQuitOnLastWindowClosed(False)
        self.jobs_manager = JobsManager()
        self.scheduler = VortaScheduler()

        self.setApplicationName("Vorta")

        # Import profile from ~/.vorta-init.json or add empty "Default" profile.
        self.bootstrap_profile()

        # Prepare tray and main window
        self.tray = TrayMenu(self)
        self.main_window = MainWindow(self)

        if getattr(args, 'daemonize', False):
            pass
        elif SettingsModel.get(key='foreground').value:
            self.open_main_window_action()

        self.backup_started_event.connect(self.backup_started_event_response)
        self.backup_finished_event.connect(self.backup_finished_event_response)
        self.backup_cancelled_event.connect(
            self.backup_cancelled_event_response)
        self.message_received_event.connect(
            self.message_received_event_response)
        self.check_failed_event.connect(self.check_failed_response)
        self.backup_log_event.connect(self.react_to_log)
        self.aboutToQuit.connect(self.quit_app_action)
        self.set_borg_details_action()
        if sys.platform == 'darwin':
            self.check_darwin_permissions()

        self.installEventFilter(self)
Beispiel #7
0
    def __init__(self, args_raw, single_app=False):

        super().__init__(APP_ID, args_raw)
        args = parse_args()
        if self.isRunning():
            if single_app:
                self.sendMessage("open main window")
                print(
                    'An instance of Vorta is already running. Opening main window.'
                )
                sys.exit()
            elif args.profile:
                self.sendMessage(f"create {args.profile}")
                print('Creating backup using existing Vorta instance.')
                sys.exit()
        elif args.profile:
            sys.exit('Vorta must already be running for --create to work')

        init_translations(self)

        self.setQuitOnLastWindowClosed(False)
        self.scheduler = VortaScheduler(self)
        self.setApplicationName("Vorta")

        # Prepare tray and main window
        self.tray = TrayMenu(self)
        self.main_window = MainWindow(self)

        if getattr(args, 'daemonize', False):
            pass
        elif SettingsModel.get(key='foreground').value:
            self.open_main_window_action()

        self.backup_started_event.connect(self.backup_started_event_response)
        self.backup_finished_event.connect(self.backup_finished_event_response)
        self.backup_cancelled_event.connect(
            self.backup_cancelled_event_response)
        self.message_received_event.connect(
            self.message_received_event_response)
        self.aboutToQuit.connect(cleanup_db)
        self.set_borg_details_action()
        self.installEventFilter(self)
Beispiel #8
0
def main():
    args = parse_args()

    frozen_binary = getattr(sys, 'frozen', False)
    want_foreground = getattr(args, 'foreground', False)
    # We assume that a frozen binary is a fat single-file binary made with
    # PyInstaller. These are not compatible with forking into background here:
    if not (want_foreground or frozen_binary):
        print('Forking to background (see system tray).')
        if os.fork():
            sys.exit()

    init_logger(foreground=want_foreground)

    # Init database
    sqlite_db = peewee.SqliteDatabase(os.path.join(SETTINGS_DIR,
                                                   'settings.db'))
    init_db(sqlite_db)

    app = VortaApp(sys.argv, single_app=True)
    app.updater = get_updater()

    sys.exit(app.exec_())