def start_app(options): # pragma: no cover """Main application entry point.""" # Setup logger setup_logger(options.log_level) # Monkey patching sys.excepthook to avoid crashes in PyQt 5.5+ if PYQT5: sys.excepthook = except_hook # Clean old style logs clean_logs() global app app = qapplication(test_time=60) set_application_icon() load_fonts(app) signal.signal(signal.SIGINT, signal.SIG_DFL) # Create file lock lock = filelock.FileLock(LOCKFILE) try: load_pid = misc.load_pid() # This means a PSutil Access Denied error was raised if load_pid is False: msgbox = MessageBoxInformation( title="Anaconda Navigator Startup Error", text=( "Navigator failed to start due to an incorrect shutdown. " "<br><br>" "We were unable to remove the pid & lock files. " "Please manually remove the following files and restart " "Anaconda Navigator:<br><ul>" "<li><pre>{}</pre></li><li><pre>{}</pre></li></ul>" "".format(LOCKFILE, PIDFILE))) sys.exit(msgbox.exec_()) elif load_pid is None: # A stale lock might be around misc.remove_lock() with lock.acquire(timeout=3.0): # timeout in seconds misc.save_pid() splash = SplashScreen() splash.show_message("Initializing...") window = run_app(splash) app.window = window event_eater = EventEater(app) app.installEventFilter(event_eater) sys.exit(app.exec_()) except filelock.Timeout: msgbox = MessageBoxInformation(title="Anaconda Navigator Information", text=("There is an instance of " "Anaconda Navigator already " "running.")) sys.exit(msgbox.exec_())
def start_app(options): # pragma: no cover """Main application entry point.""" # Setup logger setup_logger(options.log_level) # Monkey patching sys.excepthook to avoid crashes in PyQt 5.5+ if PYQT5: sys.excepthook = except_hook # Clean old style logs clean_logs() global app app = qapplication(test_time=60) set_application_icon() load_fonts(app) signal.signal(signal.SIGINT, signal.SIG_DFL) # Create file lock lock = filelock.FileLock(LOCKFILE) try: if misc.load_pid() is None: # A stale lock might be around misc.remove_lock() with lock.acquire(timeout=3.0): # timeout in seconds misc.save_pid() splash = SplashScreen() splash.show_message("Initializing...") window = run_app(splash) app.window = window event_eater = EventEater(app) app.installEventFilter(event_eater) sys.exit(app.exec_()) except filelock.Timeout: msgbox = MessageBoxInformation( title="Anaconda Navigator Information", text=( "There is an instance of " "Anaconda Navigator already " "running." ) ) sys.exit(msgbox.exec_())