Exemplo n.º 1
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 ---")
Exemplo n.º 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)
Exemplo n.º 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 ---")
Exemplo n.º 4
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 ---")
Exemplo n.º 5
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")
Exemplo n.º 6
0
    def execute(self, options_dict, non_option_args):
        yum = self.yum()

        table_rows = []

        locks = rucklocks.get_locks()

        i = 1
        for (repo, lock) in locks:
            if repo is None:
                repo = ''

            table_rows.append((str(i), repo, lock))
            i += 1

        if len(table_rows):
            ruckformat.tabular(["#", "Repository", "Lock"], table_rows)
        else:
            rucktalk.message("--- No locks found ---")
Exemplo n.º 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 ---")
Exemplo n.º 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 ---')
Exemplo n.º 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)
Exemplo n.º 10
0
    def execute(self, options_dict, non_option_args):
        pkcon = self.pkcon()

        enabled_only = not options_dict.has_key("disabled")
        repos = []
        for repo in pkcon.get_repo_list():
            if enabled_only:
                if repo['enabled']:
                    line = [repo['id'], repo['desc']]
                    repos.append(line)
            else:
                line = [repo['id'], ruckformat.bool_to_short_str(repo['enabled']), repo['desc']]
                repos.append(line)


        repos.sort(lambda x,y:cmp(x[0], y[0]))

        if len(repos):
            headers = ['Name', 'Description']
            if not enabled_only:
                headers.insert(1, 'Enabled')
            ruckformat.tabular(headers, repos)
        else:
            rucktalk.message("--- No repositories found ---")