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_())
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_())
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_())
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())
def main(): # Send crashes to Sentry. if not os.environ.get('NO_SENTRY', False): vorta.sentry.init() # 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_())
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_())