Пример #1
0
    def add_license(self, v=None, path=None):
        """Add license file."""
        if path is None:
            filename, selected_filter = getopenfilename(
                self,
                'Select license file',
                filters='License files (*.txt)',
                basedir=get_home_dir(),
            )

            if filename:
                paths = [filename]
            else:
                paths = []
        else:
            paths = [path]

        valid_licenses, invalid_licenses = self.api.add_license(paths)

        for path in invalid_licenses:
            text = ('File: <b>"{0}"</b>'
                    '<br>is not a valid license file.').format(path)
            self.message_box = MessageBoxInformation(
                text=text, title="Invalid license file")
            self.message_box.exec_()

        if valid_licenses:
            self.load_licenses()
Пример #2
0
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_())
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_())
Пример #4
0
 def _update_application(self, worker, output, error):
     self.button_update_available.setDisabled(False)
     if error:
         text = 'Anaconda Navigator Update error:'
         dlg = MessageBoxError(text=text,
                               error=error,
                               title='Application Update Error')
         self.tracker.track_page('/update/error',
                                 pagetitle='Update Application Error '
                                 'Message Box')
         dlg.exec_()
     else:
         text = ('Anaconda Navigator Updated succefully.\n\n'
                 'Please restart the application')
         dlg = MessageBoxInformation(text=text, title='Application Update')
         self.tracker.track_page('/update/successful',
                                 pagetitle='Application Update Succesful '
                                 'Message Box')
         dlg.exec_()
     self._track_tab()