Пример #1
0
 def open_login_page(self):
     """
     """
     conda_url = CONF.get('main', 'conda_url')
     url = "{0}/{1}".format(conda_url, self.username)
     qurl = QUrl(url)
     QDesktopServices.openUrl(qurl)
     self.tracker.track_event('content', 'clicked', url)
Пример #2
0
    def show_welcome_screen(self):
        if getattr(self, 'showme', True) and CONF.get('main', 'show_startup',
                                                      True):
            from anaconda_navigator.widgets.splash import FirstSplash

            self.showme = False
            self.splash.hide()
            dlg = FirstSplash()
            dlg.raise_()
            dlg.exec_()
Пример #3
0
    def __init__(self, parent=None, analytics=True):
        super(FirstSplash, self).__init__()

        text = """
        Thanks for installing Anaconda!

        Anaconda Navigator helps you easily start important Python applications
        and manage the packages in your local Anaconda installation. It also
        connects you to online resources for learning and engaging with the
        Python, SciPy, and PyData community.

        To help us improve Anaconda Navigator, fix bugs, and make it even easier
        for everyone to use Python, we gather anonymized usage information,
        just like most web browsers and mobile apps.

        To opt out of this, please uncheck below (You can always change this
        setting in the Preferences menu).
        """

        # Widgets
        self.button_ok = QPushButton('Ok')
        self.button_ok_dont_show = QPushButton("Ok, and don't show again")
        self.buttonbox = QDialogButtonBox(Qt.Horizontal)
        self.checkbox_track = QCheckBox("Yes, I'd like to help improve "
                                        "Anaconda.")
        self.label_about = QLabel(text)
        self.label_icon = QLabel()

        # Widget setup
        self.buttonbox.addButton(self.button_ok, QDialogButtonBox.ActionRole)
        self.buttonbox.addButton(self.button_ok_dont_show,
                                 QDialogButtonBox.ActionRole)
        self.checkbox_track.setChecked(analytics)
        self.checkbox_track.setChecked(
            CONF.get('main', 'provide_analytics', True))
        self.frame_title_bar.hide()
        self.label_icon.setPixmap(QPixmap(ANACONDA_NAVIGATOR_LOGO))

        # Layouts
        layout = QVBoxLayout()
        layout.addWidget(self.label_icon, 0, Qt.AlignCenter)
        layout.addWidget(self.label_about)
        layout.addWidget(self.checkbox_track, 0, Qt.AlignCenter)
        layout.addSpacing(20)
        layout.addWidget(self.buttonbox)
        self.setLayout(layout)

        # Signals
        self.button_ok.clicked.connect(lambda: self.accept(show_startup=True))
        self.button_ok_dont_show.clicked.connect(
            lambda: self.accept(show_startup=False))
Пример #4
0
    def update_login_status(self, user_data=None):
        """
        Update login button and information.
        """
        if user_data:
            self.username = user_data.get('login', '')
            self.logged = True

        if self.logged:
            username = self.username
            anaconda_api_url = CONF.get('main', 'anaconda_api_url')
            token = self.api.client_load_token(anaconda_api_url)
            self.button_logged_text.setText('Signed in as')
            self.button_logged_username.setText(username)
            url = "{0}/{1}".format(CONF.get('main', 'conda_url'), username)
            self.button_logged_username.setToolTip(url)
            self.button_login.setText('Sign out')
            self.environments_tab.packages_widget.set_token(token)
        else:
            self.button_logged_text.setText('')
            self.button_logged_username.setText('')
            self.button_login.setText(self._login_text)
        QApplication.restoreOverrideCursor()
Пример #5
0
    def closeEvent(self, event):
        """
        Catch close event.
        """
        # TODO: check if an update is not in progress or things might break!!
        #        if self.busy:
        show_dialog = not CONF.get('main', 'hide_quit_dialog')
        if show_dialog:
            if self.tracker:
                self.tracker.track_page('/quit', pagetitle='Quit dialog')
            dlg = QuitApplicationDialog()
            reply = dlg.exec_()

            if not reply:
                event.ignore()
                self._track_tab()
Пример #6
0
    def _create_worker(self, method, *args, **kwargs):
        """Create a worker for this client to be run in a separate thread."""
        provide_analytics = CONF.get('main', 'provide_analytics')

        thread = QThread()
        worker = AnalyticsWorker(method, args, kwargs)

        if provide_analytics:
            worker.moveToThread(thread)
            worker.sig_finished.connect(self._start)
            worker.sig_finished.connect(thread.quit)
            thread.started.connect(worker.start)
            self._queue.append(thread)
            self._threads.append(thread)
            self._workers.append(worker)
            self._start()

        return worker
Пример #7
0
    def __init__(self, *args, **kwargs):
        super(QuitApplicationDialog, self).__init__(*args, **kwargs)
        self.label_icon = QLabel()
        self.label_about = QLabel('Quit Anaconda Navigator?')
        self.button_ok = QPushButton('Yes')
        self.button_cancel = ButtonCancel('No')
        self.buttonbox = QDialogButtonBox(Qt.Horizontal)
        self.checkbox = QCheckBox("Don't show again")

        # Widget setup
        if CONF.get('main', 'hide_quit_dialog'):
            hide_dialog = Qt.Checked
        else:
            hide_dialog = Qt.Unchecked

        self.checkbox.setChecked(hide_dialog)
        self.buttonbox.addButton(self.button_ok, QDialogButtonBox.ActionRole)
        self.buttonbox.addButton(self.button_cancel,
                                 QDialogButtonBox.ActionRole)
        self.label_icon.setPixmap(QPixmap(images.ANACONDA_ICON_64_PATH))
        self.setWindowTitle("Quit application")

        # Layouts
        h_layout = QHBoxLayout()
        h_layout.addWidget(self.label_icon, 0, Qt.AlignTop)
        h_layout.addSpacing(10)
        h_layout.addWidget(self.label_about)

        main_layout = QVBoxLayout()
        main_layout.addLayout(h_layout)
        main_layout.addWidget(self.checkbox, 0, Qt.AlignRight)
        main_layout.addSpacing(24)
        main_layout.addWidget(self.buttonbox)
        self.setLayout(main_layout)

        # Signals
        self.button_ok.clicked.connect(self.accept)
        self.button_cancel.clicked.connect(self.reject)

        # Setup
        self.update_style_sheet()
Пример #8
0
    def _metadata_updated(self, worker, path, error):
        self.set_splash('Updating repodata...')
        if error:
            logger.error(str(error))

        if path and os.path.isfile(path):
            with open(path, 'r') as f:
                data = f.read()
        try:
            self._metadata = json.loads(data)
        except Exception:
            self._metadata = {}

        channels = CONF.get('main', 'conda_channels', default=tuple())
        if not channels:
            channels = self.api.conda_get_condarc_channels()
            CONF.set('main', 'conda_channels', channels)
            CONF.set('main', 'conda_active_channels', channels)

        self.api.update_repodata(channels=channels)
        self.api.sig_repodata_updated.connect(self._repodata_updated)
Пример #9
0
                                       UBUNTU)
from anaconda_navigator.external import filelock
from anaconda_navigator.static import images
from anaconda_navigator.static.fonts import load_fonts
from anaconda_navigator.utils import misc
from anaconda_navigator.utils.logs import clean_logs, setup_logger
from anaconda_navigator.utils.qthelpers import qapplication
from anaconda_navigator.widgets.dialogs import MessageBoxInformation
from anaconda_navigator.widgets.dialogs.splash import SplashScreen
from anaconda_navigator.widgets.main_window import MainWindow


# yapf: enable

# For retina displays on qt5
if CONF.get('main', 'enable_high_dpi_scaling'):
    if hasattr(Qt, 'AA_UseHighDpiPixmaps'):
        QCoreApplication.setAttribute(Qt.AA_UseHighDpiPixmaps)

    if hasattr(Qt, 'AA_EnableHighDpiScaling'):
        QCoreApplication.setAttribute(Qt.AA_EnableHighDpiScaling)


def except_hook(cls, exception, traceback):
    """Custom except hook to avoid crashes on PyQt5."""
    sys.__excepthook__(cls, exception, traceback)


def set_application_icon():
    """Set application icon."""
    global app
Пример #10
0
    def __init__(self, splash=None):
        super(MainWindow, self).__init__()
        self.tracker = None
        self.splash = splash

        # Anaconda API
        self.api = AnacondaAPI()
        self.busy = False
        self.logged = False
        self.username = ''
        self._login_text = 'Sign in to Anaconda Cloud'
        self.first_run = CONF.get('main', 'first_run')
        self.application_update_version = None

        # Widgets
        self.frame_header = FrameHeader(self)
        self.frame_body = FrameBody(self)
        self.label_logo = LabelHeaderLogo('ANACONDA NAVIGATOR')
        self.button_logged_text = ButtonLabelLogin('')
        self.button_logged_username = ButtonLinkLogin('')
        self.label_update_available = LabelHeaderUpdate('Update available!')
        self.button_update_available = ButtonHeaderUpdate('Update')
        self.button_login = ButtonLogin(self._login_text)
        self.central_widget = QWidget()
        self.statusbar = self.statusBar()
        self.progressbar = QProgressBar()

        self.stack = TabWidgetBody(self)
        self.home_tab = HomeTab(parent=self)
        self.environments_tab = EnvironmentsTab(parent=self)
        self.learning_tab = CommunityTab(
            parent=self,
            tags=['webinar', 'documentation', 'video', 'training'],
            content_urls=[self.VIDEOS_URL, self.WEBINARS_URL])
        self.community_tab = CommunityTab(parent=self,
                                          tags=['event', 'forum', 'social'],
                                          content_urls=[self.EVENTS_URL])

        #        self.projects_tab = ProjectsTab(parent=self)

        # Note: Icons are set in CSS
        self.stack.addTab(self.home_tab, text='Home')
        self.stack.addTab(self.environments_tab, text='Environments')
        self.stack.addTab(self.learning_tab, text='Learning')
        self.stack.addTab(self.community_tab, text='Community')
        #        self.stack.addTab(self.projects_tab, 'Projects')

        # Widget setup
        self.button_login.setDefault(True)
        self.label_logo.setPixmap(QPixmap(images.ANACONDA_NAVIGATOR_LOGO))
        self.setWindowTitle("Anaconda Navigator")
        self.statusbar.addPermanentWidget(self.progressbar)
        self.progressbar.setVisible(False)

        # Layout
        header_layout = QHBoxLayout()
        header_layout.addWidget(self.label_logo)
        header_layout.addSpacing(18)
        header_layout.addWidget(self.label_update_available, 0, Qt.AlignCenter)
        header_layout.addWidget(self.button_update_available, 0,
                                Qt.AlignCenter)
        header_layout.addStretch()
        header_layout.addWidget(self.button_logged_text, 0, Qt.AlignTrailing)
        header_layout.addWidget(self.button_logged_username, 0,
                                Qt.AlignTrailing)
        header_layout.addWidget(self.button_login, 0, Qt.AlignTrailing)
        header_layout.setContentsMargins(0, 0, 0, 0)
        self.frame_header.setLayout(header_layout)

        body_layout = QHBoxLayout()
        body_layout.addWidget(self.stack)
        body_layout.setContentsMargins(0, 0, 0, 0)
        self.frame_body.setLayout(body_layout)

        main_layout = QVBoxLayout()
        main_layout.addWidget(self.frame_header)
        main_layout.addWidget(self.frame_body)
        main_layout.setContentsMargins(0, 0, 0, 0)
        main_layout.setSpacing(0)
        self.central_widget.setLayout(main_layout)
        self.setContentsMargins(0, 0, 0, 0)
        self.setCentralWidget(self.central_widget)

        # Signals
        self.button_login.clicked.connect(self.login)
        self.button_logged_username.clicked.connect(self.open_login_page)
        self.button_update_available.clicked.connect(self.update_application)
        self.stack.currentChanged.connect(self._track_tab)

        # This needs to be reworked!
        #        self.projects_tab.sig_apps_updated.connect(
        #            self.home_tab.set_applications)
        #        self.projects_tab.sig_apps_changed.connect(
        #            self.home_tab.set_applications)
        #        self.projects_tab.sig_project_updated.connect(
        #            self.home_tab.set_applications)
        #        self.projects_tab.sig_status_updated.connect(self.update_status_bar)

        # Setup
        self.api.set_data_directory(CHANNELS_PATH)
        self.update_style_sheet()
Пример #11
0
    def __init__(self, parent=None):
        super(EnvironmentsTab, self).__init__(parent)

        self.api = AnacondaAPI()
        self.last_env_prefix = None
        self.last_env_name = None
        self.previous_environments = None
        self.tracker = GATracker()
        self.metadata = {}

        active_channels = CONF.get('main',  'conda_active_channels', tuple())
        channels = CONF.get('main',  'conda_channels', tuple())
        conda_url = CONF.get('main',  'conda_url',
                             'https:/conda.anaconda.org')
        conda_api_url = CONF.get('main',  'anaconda_api_url',
                                 'https://api.anaconda.org')

        # Widgets
        self.button_clone = ButtonEnvironmentPrimary("Clone")
        self.button_create = ButtonEnvironmentPrimary("Create")
        self.button_remove = ButtonEnvironmentCancel("Remove")
        self.frame_environments = FrameEnvironments(self)
        self.frame_environments_list = FrameEnvironmentsList(self)
        self.frame_environments_list_buttons = FrameEnvironmentsListButtons(self)
        self.frame_environments_packages = FrameEnvironmentsPackages(self)
        self.list_environments = ListWidgetEnvironment()
        self.packages_widget = CondaPackagesWidget(
            self,
            setup=False,
            active_channels=active_channels,
            channels=channels,
            data_directory=CHANNELS_PATH,
            conda_api_url=conda_api_url,
            conda_url=conda_url)
        self.menu_list = QMenu()
        self.text_search = LineEditSearch()
        self.timer_environments = QTimer()

        # Widgets setup
        self.list_environments.setAttribute(Qt.WA_MacShowFocusRect, False)
        self.list_environments.setContextMenuPolicy(Qt.CustomContextMenu)
        self.packages_widget.textbox_search.setAttribute(
            Qt.WA_MacShowFocusRect, False)
        self.packages_widget.textbox_search.set_icon_visibility(False)
        self.text_search.setPlaceholderText("Search Environments")
        self.text_search.setAttribute(Qt.WA_MacShowFocusRect, False)
        self.timer_environments.setInterval(5000)

        # Layouts
        environments_layout = QVBoxLayout()
        environments_layout.addWidget(self.text_search)

        buttons_layout = QHBoxLayout()
        buttons_layout.addWidget(self.button_create)
        buttons_layout.addWidget(self.button_clone)
        buttons_layout.addWidget(self.button_remove)
        buttons_layout.setContentsMargins(0, 0, 0, 0)

        list_buttons_layout = QVBoxLayout()
        list_buttons_layout.addWidget(self.list_environments)
        list_buttons_layout.addLayout(buttons_layout)
        self.frame_environments_list_buttons.setLayout(list_buttons_layout)
        list_buttons_layout.setContentsMargins(0, 0, 0, 0)
        environments_layout.addWidget(self.frame_environments_list_buttons)

        self.frame_environments_list.setLayout(environments_layout)

        packages_layout = QHBoxLayout()
        packages_layout.addWidget(self.packages_widget)
        packages_layout.setContentsMargins(0, 0, 0, 0)
        self.frame_environments_packages.setLayout(packages_layout)

        main_layout = QHBoxLayout()
        main_layout.addWidget(self.frame_environments_list, 1)
        main_layout.addWidget(self.frame_environments_packages, 3)
        main_layout.setContentsMargins(0, 0, 0, 0)
        self.frame_environments.setLayout(main_layout)

        layout = QHBoxLayout()
        layout.addWidget(self.frame_environments)
        self.setLayout(layout)

        # Signals
        self.button_clone.clicked.connect(self.clone_environment)
        self.button_create.clicked.connect(self.create_environment)
        self.button_remove.clicked.connect(self.remove_environment)
        self.list_environments.sig_item_selected.connect(
            self.load_environment)
        self.packages_widget.sig_packages_ready.connect(self.refresh)
        self.packages_widget.sig_channels_updated.connect(self.update_channels)
#        self.packages_widget.sig_environment_cloned.connect(
#            self._environment_created)
#        self.packages_widget.sig_environment_created.connect(
#            self._environment_created)
#        self.packages_widget.sig_environment_removed.connect(
#            self._environment_removed)
        self.text_search.textChanged.connect(self.filter_environments)
        self.timer_environments.timeout.connect(self.refresh_environments)
        self.packages_widget.sig_process_cancelled.connect(
            lambda: self.update_visibility(True))
Пример #12
0
 def get_option(self, option):
     return CONF.get('main', option, None)