예제 #1
0
    def execute(self, options_dict, non_option_args):

        if not non_option_args:
            self.usage()
            sys.exit(1)

        pkcon = self.pkcon()

        for a in non_option_args:

            inform = 0
            channel = None
            package = None

            plist = pkcon.resolve("none", a)

            if plist == None or len(plist) == 0:
                rucktalk.message("--- No packages found ---")
                sys.exit(1)

            ## Find the latest version
            latest_ver, latest_id = None, None
            for pkg in plist:
                row = ruckformat.package_to_row(pkg, False, ['version'])
                if latest_ver == None or row[0] > latest_ver:
                    latest_ver= row[0]
                    latest_id = pkg

            latest = pkcon.get_details(latest_id['id'])[0]
            details = ruckformat.package_to_row(latest, False, ['name', 'version', 'repo', 'installed'])
            latest['name'] = details[0]
            latest['version'] = details[1]
            latest['repo'] = details[2]
            latest['installed'] = (details[3] == 'I')

            rucktalk.message("")
            rucktalk.message("Name: " + latest['name'])
            rucktalk.message("Version: " + latest['version'])

            if latest_id['installed']:
                rucktalk.message("Installed: Yes")
            else:
                rucktalk.message("Installed: No")

            rucktalk.message("Package size: " + str(latest['size']))

            rucktalk.message("Group: " + latest['group'])
            rucktalk.message("Homepage: " + latest['url'])
            rucktalk.message("Description: " + latest['detail'])
예제 #2
0
    def execute(self, options_dict, non_option_args):
        size = len(non_option_args)
        if size < 1:
            self.usage()
            return False

        table_rows = []
        yum = self.yum()

        for file in non_option_args:
            if not os.access (file, os.F_OK):
                rucktalk.error("File %s does not exist" % file)
                continue

            matches = yum.rpmdb.searchFiles (file);
            if not matches:
                rucktalk.message("No package owns file %s" % file)
                continue

            for pkg in matches:
                row = ruckformat.package_to_row(yum, pkg, False, ["name", "version"])
                if size > 1:
                    row.insert (0, file)
                table_rows.append (row)

        if len(table_rows):
            if size == 1:
                ruckformat.tabular(["Name", "Version"], table_rows)
            else:
                ruckformat.tabular(["File", "Name", "Version"], table_rows)
예제 #3
0
    def execute(self, options_dict, non_option_args):
        no_abbrev = options_dict.has_key("no-abbrev") or \
                    options_dict.has_key("terse")

        pkcon = self.pkcon()

        table_keys = ["repo", "name", "version"]
        table_rows = []

        updates = pkcon.get_updates()

        for new_pkg in updates:
            row = ruckformat.package_to_row(new_pkg, no_abbrev, table_keys)
            table_rows.append(row)

        if len(table_rows):
            if options_dict.has_key("sort-by-repo"):
                table_rows.sort(lambda x,y:cmp(string.lower(x[0]), string.lower(y[0])) or\
                                cmp(string.lower(x[1]), string.lower(y[1])))
            else:
                table_rows.sort(lambda x,y:cmp(string.lower(x[1]), string.lower(y[1])))

            ruckformat.tabular(["Repository", "Name",
                               "Version"],
                              table_rows)
        else:
            rucktalk.message("--- No updates found ---")
예제 #4
0
    def execute(self, options_dict, non_option_args):
        pkcon = self.pkcon()

        searchlist = ['name']
        if options_dict.has_key('search-descriptions'):
            method = pkcon.search_details
        else:
            method = pkcon.search_name

        filter = pkenums.FILTER_NONE
        if options_dict.has_key('installed-only'):
            filter = pkenums.FILTER_INSTALLED
        elif options_dict.has_key('uninstalled-only'):
            filter = pkenums.FILTER_NOT_INSTALLED

        result = {}
        matches = method(non_option_args[0], filter)
        if len(matches) > 0:
            table_keys = ["installed", "repo", "name", "version"]
            table_rows = []
            no_abbrev = options_dict.has_key("no-abbrev")

            for pkg in matches:
                row = ruckformat.package_to_row(pkg, no_abbrev, table_keys)
                table_rows.append(row)

            if options_dict.has_key("sort-by-repo"):
                table_rows.sort(lambda x,y:cmp(string.lower(x[1]), string.lower(y[1])) or\
                                cmp(string.lower(x[2]), string.lower(y[2])))
            else:
                table_rows.sort(lambda x,y:cmp(string.lower(x[2]), string.lower(y[2])))
            ruckformat.tabular(["S", "Repository", "Name", "Version"], table_rows)
        else:
            rucktalk.message("--- No packages found ---")
예제 #5
0
    def execute(self, options_dict, non_option_args):
        # FIXME: does not know about status, not sure all is right default
        pkcon = self.pkcon()

        table_rows = []
        no_abbrev = options_dict.has_key("no-abbrev")

        sort_idx = 2
        table_headers = ["S", "Repository", "Name", "Version"]
        table_keys = ["installed", "repo", "name", "version"]

        filter = pkenums.FILTER_NEWEST
        if options_dict.has_key("uninstalled-only"):
            filter = filter + pkenums.FILTER_NOT_INSTALLED
        elif options_dict.has_key("installed-only"):
            filter = pkenums.FILTER_INSTALLED

        filter = pkenums.FILTER_INSTALLED
        pkgs = pkcon.get_packages(filter)

        remote_tuples = {}

        for p in pkgs:
            row = ruckformat.package_to_row(p, no_abbrev, table_keys)
            table_rows.append(row)

        if table_rows:
            if options_dict.has_key("sort-by-repo"):
                table_rows.sort(lambda x,y:cmp(string.lower(x[1]), string.lower(y[1])) or\
                                cmp(string.lower(x[2]), string.lower(y[2])))
            else:
                table_rows.sort(lambda x,y:cmp(string.lower(x[sort_idx]), string.lower(y[sort_idx])))
            ruckformat.tabular(table_headers, table_rows)
        else:
            rucktalk.message("--- No packages found ---")
예제 #6
0
    def execute(self, options_dict, non_option_args):
        pkcon = self.pkcon()

        updates = pkcon.get_updates()
        if (len(updates) == 0):
            rucktalk.message("--- No updates found ---")
            exit()

        rucktalk.message("The following packages will be updated:")

        table_keys = ["repo", "name", "version"]
        table_rows = []
        for new_pkg in updates:
            row = ruckformat.package_to_row(new_pkg, False, table_keys)
            table_rows.append(row)

        table_rows.sort(lambda x,y:cmp(string.lower(x[1]), string.lower(y[1])))

        ruckformat.tabular(["Repository", "Name","Version"],
                          table_rows)
        # FIXME: this prompt is horrid
        resp = rucktalk.prompt("Continue? Y/[N]")
        if (resp == 'y'):
            # FIXME: needs to deal with progress better
            pkcon.update_packages(updates)
        else:
            rucktalk.message("Update aborted")
예제 #7
0
    def execute(self, options_dict, non_option_args):
        pkcon = self.pkcon()

        updates = pkcon.get_updates()
        repos = {}
        for pkg in updates:
            bits = ruckformat.package_to_row(pkg, False, ['repo'])
            if not repos.has_key(bits[0]):
                repos[bits[0]] = [bits[0], 0]
            repos[bits[0]][1] = str(int(repos[bits[0]][1])+1)

        repolist = []
        for repo in repos.keys():
            repolist.append(repos[repo])

        if len(repolist) > 0:
            repolist.sort(lambda x,y:cmp(y[1], x[1]))
            headers = ["Repository", "Total"]
            ruckformat.tabular(headers, repolist)
        else:
            rucktalk.message("--- No updates found ---")
예제 #8
0
    def execute(self, options_dict, non_option_args):
        if len(non_option_args) != 0:
            self.usage()
            return False

        table_headers = ["Name", "Version"]
        table_keys = ["name", "version"]
        table_rows = []

        no_abbrev = options_dict.has_key("no-abbrev")

        yum = self.yum()

        for installed in yum.rpmdb.returnPackages():
            matches = yum.pkgSack.searchNevra(name=installed.name)

            if len(matches) == 0:
                table_rows.append(ruckformat.package_to_row(yum, installed, no_abbrev, table_keys))

        if len(table_rows) > 0:
            ruckformat.tabular(table_headers, table_rows)
        else:
            rucktalk.message('--- No orphans found ---')
예제 #9
0
    def execute(self, options_dict, non_option_args):
        if len(non_option_args) < 1:
            self.usage()
            return False

        table_rows = []
        yum = self.yum()

        for dep in non_option_args:
            dep_info = self.parse_dep_str(dep)

            matches = []
            if not options_dict.has_key('installed-only'):
                matches = self.dep_search_uninstalled (dep_info["dep"]);

            if not options_dict.has_key('uninstalled-only'):
                matches += self.dep_search_installed (dep_info["dep"]);

            if dep_info.has_key("relation"):
                matches = [p for p in matches if self.check_relation (dep_info, p)]

            if not matches:
                rucktalk.message("--- No matches for %s ---" % dep)
                continue

            for pkg in matches:
                row = ruckformat.package_to_row(yum, pkg, False, ["name", "version"])

                repo = pkg.repoid
                if yum.rpmdb.installed(name=pkg.name, arch=pkg.arch):
                    repo = "installed"

                row.insert(0, repo)
                table_rows.append (row)

        if len(table_rows):
            ruckformat.tabular(["Repository", "Name", "Version"], table_rows)