Exemplo n.º 1
0
    def __init__(self, parent=None):
        QtGui.QWidget.__init__(self, parent)
        self.ui = Ui_QYolk()
        self.ui.setupUi(self)
        self.ui.info_label.setText("")

        # set Column Width
        self.ui.all_list.setColumnWidth(0, 200)
        self.ui.all_list.setColumnWidth(1, 200)
        self.ui.active_list.setColumnWidth(0, 200)
        self.ui.active_list.setColumnWidth(1, 200)
        self.ui.not_active_list.setColumnWidth(0, 200)
        self.ui.not_active_list.setColumnWidth(1, 200)
        self.ui.update_list.setColumnWidth(0, 200)
        self.ui.update_list.setColumnWidth(1, 200)

        QtCore.QObject.connect(self.ui.tab_widget,
                               QtCore.SIGNAL("currentChanged(int)"),
                               self.tab_changed)

        packages = get_distributions('all')
        for pkg in packages:
            newItem = QtGui.QTreeWidgetItem(self.ui.all_list)
            pk = str(pkg[0]).split(' ')
            if pkg[1]:
                status = 'Active'
            else:
                status = 'Not Active'
                newItem.setTextColor(0, QtGui.QColor(128, 128, 128))
                newItem.setTextColor(1, QtGui.QColor(128, 128, 128))
                newItem.setTextColor(2, QtGui.QColor(128, 128, 128))

            newItem.setText(0, pk[0])
            newItem.setText(1, pk[1])
            newItem.setText(2, status)

        for pkg in get_distributions('active'):
            newItem = QtGui.QTreeWidgetItem(self.ui.active_list)
            pk = str(pkg[0]).split(' ')
            newItem.setText(0, pk[0])
            newItem.setText(1, pk[1])
            newItem.setText(2, 'Active')

        for pkg in get_distributions('nonactive'):
            newItem = QtGui.QTreeWidgetItem(self.ui.not_active_list)
            pk = str(pkg[0]).split(' ')
            newItem.setText(0, pk[0])
            newItem.setText(1, pk[1])
            newItem.setText(2, 'Not Active')
Exemplo n.º 2
0
    def installed(self):

        names = []
        for dist, active in yolklib.get_distributions('active'):
            if dist.project_name in names:
                continue
            names.append(dist.project_name)
            yield Package.from_dist(self, dist)
Exemplo n.º 3
0
    def location(self):

        if self._location is None:
            try:
                dist, active = yolklib.get_distributions('active',
                                                         self._name).send(None)
            except StopIteration:
                self._location = LOCATION_NOT_INSTALLED
            else:
                self._location = dist.location
        return self._location
Exemplo n.º 4
0
def get_pkglist():
    """Return list of all installed packages.

    Note: It returns one project name per pkg no matter how many versions
    of a particular package is installed

    @returns: list of project name strings for every installed pkg

    """
    projects = []
    for (dist, _) in yolklib.get_distributions('all'):
        if dist.project_name not in projects:
            projects.append(dist.project_name)
    return projects
Exemplo n.º 5
0
def get_pkglist():
    """Return list of all installed packages.

    Note: It returns one project name per pkg no matter how many versions
    of a particular package is installed

    @returns: list of project name strings for every installed pkg

    """
    projects = []
    for (dist, _) in yolklib.get_distributions('all'):
        if dist.project_name not in projects:
            projects.append(dist.project_name)
    return projects
Exemplo n.º 6
0
    def worker_function(pkg):
        for (dist, active) in yolklib.get_distributions(
                'all', pkg, yolklib.get_highest_installed(pkg)):

            if exception:
                return

            width = terminal_width()
            if width:
                print(u'\rChecking {}'.format(dist.project_name).ljust(width),
                      end='',
                      file=sys.stderr)

            (project_name,
             versions) = pypi.query_versions_pypi(dist.project_name)
        return (pkg, dist, project_name, versions)
Exemplo n.º 7
0
def get_fresh_updates(package_name="", version=""):
    ret = []
    pypi = CheeseShop()
    for pkg in get_pkglist():
        for (dist, active) in get_distributions("all", pkg,
                                                get_highest_installed(pkg)):
            (project_name,
             versions) = pypi.query_versions_pypi(dist.project_name)
            if versions:
                newest = get_highest_version(versions)
                if newest != dist.version:
                    if pkg_resources.parse_version(
                            dist.version) < pkg_resources.parse_version(
                                newest):
                        ret.append([project_name, dist.version, newest])

    return ret
Exemplo n.º 8
0
    def worker_function(pkg):
        for (dist, active) in yolklib.get_distributions(
                'all', pkg,
                yolklib.get_highest_installed(pkg)):

            if exception:
                return

            width = terminal_width()
            if width:
                print('\rChecking {}'.format(dist.project_name).ljust(width),
                      end='',
                      file=sys.stderr)

            (project_name, versions) = pypi.query_versions_pypi(
                dist.project_name)
        return (pkg, dist, project_name, versions)
Exemplo n.º 9
0
    def test_latest_vulndb(self):
        pkg = 'vulndb'
        found = None
        pypi = CheeseShop(False)
        all_dists = get_distributions('all', pkg,
                                      get_highest_installed(pkg))

        for dist, active in all_dists:
            project_name, versions = pypi.query_versions_pypi(dist.project_name)

            if versions:
                # PyPI returns them in chronological order,
                # but who knows if its guaranteed in the API?
                # Make sure we grab the highest version:
                newest = get_highest_version(versions)
                if newest != dist.version:

                    # We may have newer than what PyPI knows about
                    if pkg_resources.parse_version(dist.version) < \
                    pkg_resources.parse_version(newest):
                        found = True

        if found:
            self.assertTrue(False, MESSAGE)
Exemplo n.º 10
0
    def test_latest_vulndb(self):
        pkg = 'vulndb'
        found = None
        pypi = CheeseShop(False)
        all_dists = get_distributions('all', pkg, get_highest_installed(pkg))

        for dist, active in all_dists:
            project_name, versions = pypi.query_versions_pypi(
                dist.project_name)

            if versions:
                # PyPI returns them in chronological order,
                # but who knows if its guaranteed in the API?
                # Make sure we grab the highest version:
                newest = get_highest_version(versions)
                if newest != dist.version:

                    # We may have newer than what PyPI knows about
                    if pkg_resources.parse_version(dist.version) < \
                    pkg_resources.parse_version(newest):
                        found = True

        if found:
            self.assertTrue(False, MESSAGE)
Exemplo n.º 11
0
	def __init__(self, parent=None):
		QtGui.QWidget.__init__(self, parent)
		self.ui = Ui_QYolk()
		self.ui.setupUi(self)

		# set Column Width
		self.ui.treeList.setColumnWidth(0, 200)
		self.ui.treeList.setColumnWidth(1, 200)

		packages = yolklib.get_distributions('all')
		for pkg in packages:
			newItem = QtGui.QTreeWidgetItem(self.ui.treeList)
			pk = str(pkg[0]).split(' ')
			if pkg[1]:
				status = 'Active'
			else:
				status = 'Not Active'
				newItem.setTextColor(0, QtGui.QColor(128, 128, 128))
				newItem.setTextColor(1, QtGui.QColor(128, 128, 128))
				newItem.setTextColor(2, QtGui.QColor(128, 128, 128))
				
			newItem.setText(0, pk[0])
			newItem.setText(1, pk[1])
			newItem.setText(2, status)
Exemplo n.º 12
0
    def show_distributions(self, show):
        """Show list of installed activated OR non-activated packages.

        @param show: type of pkgs to show (all, active or nonactive)
        @type show: string

        @returns: None or 2 if error

        """
        # Search for any plugins with active CLI options with add_column()
        # method.
        plugins = self.get_plugin('add_column')

        # Some locations show false positive for 'development' packages:
        ignores = ['/UNIONFS', '/KNOPPIX.IMG']

        # See http://cheeseshop.python.org/pypi/workingenv.py for details.
        workingenv = os.environ.get('WORKING_ENV')
        if workingenv:
            ignores.append(workingenv)

        results = None
        for (dist,
             active) in yolklib.get_distributions(show, self.project_name,
                                                  self.version):
            metadata = get_metadata(dist)
            for prefix in ignores:
                if dist.location.startswith(prefix):
                    dist.location = dist.location.replace(prefix, '')
            # Case-insensitive search because of Windows.
            if dist.location.lower().startswith(get_python_lib().lower()):
                develop = ''
            else:
                develop = dist.location
            if metadata:
                add_column_text = ''
                for my_plugin in plugins:
                    # See if package is 'owned' by a package manager such as
                    # portage, apt, rpm etc.
                    add_column_text += my_plugin.add_column(dist) + ' '
                self.print_metadata(metadata, develop, active, add_column_text)
            else:
                print(str(dist) + ' has no metadata')
            results = True
        if not results and self.project_name:
            if self.version:
                pkg_spec = '{}=={}'.format(self.project_name, self.version)
            else:
                pkg_spec = self.project_name
            if show == 'all':
                print(
                    u'There are no versions of {} installed'.format(pkg_spec),
                    file=sys.stderr)
            else:
                print(u'There are no {} versions of {} installed'.format(
                    show, pkg_spec),
                      file=sys.stderr)
            return 2
        elif show == 'all' and results and self.options.fields:
            print("Versions with '*' are non-active.")
            print("Versions with '!' are deployed in development mode.")
Exemplo n.º 13
0
    def show_distributions(self, show):
        """Show list of installed activated OR non-activated packages.

        @param show: type of pkgs to show (all, active or nonactive)
        @type show: string

        @returns: None or 2 if error

        """
        # Search for any plugins with active CLI options with add_column()
        # method.
        plugins = self.get_plugin('add_column')

        # Some locations show false positive for 'development' packages:
        ignores = ['/UNIONFS', '/KNOPPIX.IMG']

        # See http://cheeseshop.python.org/pypi/workingenv.py for details.
        workingenv = os.environ.get('WORKING_ENV')
        if workingenv:
            ignores.append(workingenv)

        results = None
        for (dist, active) in yolklib.get_distributions(show,
                                                        self.project_name,
                                                        self.version):
            metadata = get_metadata(dist)
            for prefix in ignores:
                if dist.location.startswith(prefix):
                    dist.location = dist.location.replace(prefix, '')
            # Case-insensitive search because of Windows.
            if dist.location.lower().startswith(get_python_lib().lower()):
                develop = ''
            else:
                develop = dist.location
            if metadata:
                add_column_text = ''
                for my_plugin in plugins:
                    # See if package is 'owned' by a package manager such as
                    # portage, apt, rpm etc.
                    add_column_text += my_plugin.add_column(dist) + ' '
                self.print_metadata(metadata, develop, active, add_column_text)
            else:
                print(str(dist) + ' has no metadata')
            results = True
        if not results and self.project_name:
            if self.version:
                pkg_spec = '{}=={}'.format(self.project_name, self.version)
            else:
                pkg_spec = self.project_name
            if show == 'all':
                print('There are no versions of {} installed'.format(pkg_spec),
                      file=sys.stderr)
            else:
                print(
                    'There are no {} versions of {} installed'.format(
                        show, pkg_spec),
                    file=sys.stderr)
            return 2
        elif show == 'all' and results and self.options.fields:
            print("Versions with '*' are non-active.")
            print("Versions with '!' are deployed in development mode.")