Beispiel #1
0
    def _process_conda_info(info):
        """Process conda info output and add some extra keys."""
        logger.debug('info: {}'.format(info))
        processed_info = info.copy()

        # Add a key for writable environment directories
        envs_dirs_writable = []
        for env_dir in info['envs_dirs']:
            if path_is_writable(env_dir):
                envs_dirs_writable.append(env_dir)
        processed_info['__envs_dirs_writable'] = envs_dirs_writable

        # Add a key for writable environment directories
        pkgs_dirs_writable = []
        for pkg_dir in info['pkgs_dirs']:
            if path_is_writable(pkg_dir):
                pkgs_dirs_writable.append(pkg_dir)
        processed_info['__pkgs_dirs_writable'] = pkgs_dirs_writable

        # Add a key for all environments
        root_prefix = info['root_prefix']
        environments = OrderedDict()
        environments[root_prefix] = 'root'
        envs = info['envs']
        envs_names = [os.path.basename(env) for env in envs]
        for env_name, env_prefix in sorted(zip(envs_names, envs)):
            environments[env_prefix] = env_name
        processed_info['__environments'] = environments

        return processed_info
Beispiel #2
0
 def is_valid_path(self):
     """Check that entered path is valid."""
     check = False
     error = ''
     path = self.text_path.text().strip()
     if bool(path) and os.path.isdir(path):
         if ' ' in path:
             error = '<b>Please select a path without spaces</b>'
         elif path == HOME_PATH:
             error = ('<b>Please select a path different to the home '
                      'directory.</b>')
         elif not path_is_writable(path):
             error = ('<b>Please select a path that has write access.</b>')
         check = (' ' not in path and path != HOME_PATH
                  and path_is_writable(path))
     return check, error
Beispiel #3
0
    def __init__(self, channel=None, location=None):
        """Conda channels list widget item used in CSS styling."""
        super(ListWidgetItemChannel, self).__init__()
        self.channel = channel if channel else ''
        self.location = location if location else ''

        # Widgets
        self.widget = FrameChannels()
        self.label_location = LabelConfigLocation(location)
        self.text_channel = LineEditChannel()
        self.label_info = LabelChannelInfo()
        self.button_remove = ButtonRemoveChannel()

        # Widgets setup
        self.button_remove.setVisible(path_is_writable(location))
        self.text_channel.setText(channel)

        # Layouts
        layout_name = QVBoxLayout()
        layout_name.addWidget(self.text_channel)
        layout_name.addWidget(self.label_location)
        self.label_location.setToolTip(location)

        layout_frame = QHBoxLayout()
        layout_frame.addLayout(layout_name)
        layout_frame.addStretch()
        layout_frame.addWidget(self.label_info)
        layout_frame.addWidget(self.button_remove)
        self.widget.setLayout(layout_frame)
        self.setSizeHint(self.widget_size())