Beispiel #1
0
def verbose_updates_list(server, update_list):

    update_list.sort(lambda x, y:cmp(x[1]["importance_num"], y[1]["importance_num"]) \
                     or cmp(string.lower(x[1]["name"]), string.lower(y[1]["name"])))

    for update_item in update_list:

        old_pkg, new_pkg, descriptions = update_item

        ch = rcchannelutils.get_channel_by_id(server, new_pkg["channel"])
        
        rctalk.message("        Name: " + new_pkg["name"])
        rctalk.message("     Channel: " + ch["name"])
        rctalk.message("     Urgency: " + new_pkg["importance_str"])
        rctalk.message("Current Vers: " + rcformat.evr_to_str(old_pkg))
        rctalk.message(" Update Vers: " + rcformat.evr_to_str(new_pkg))

        header = "Enhancements: "
        last_desc = None
        for d in descriptions:
            if last_desc != d: # don't print the same damn message many times
                rctalk.message(header + d)
            last_desc = d
            header = "              "

        rctalk.message("")
Beispiel #2
0
def log_entries_to_table(entries):

    log_table = []

    for x in entries:

        pkg_initial = "-"
        if x.has_key("pkg_initial"):
            pkg_initial = rcformat.evr_to_str(x["pkg_initial"])

        pkg_final = "-"
        if x.has_key("pkg_final"):
            pkg_final = rcformat.evr_to_str(x["pkg_final"])

        if x.has_key("pkg_final"):
            pkg = x["pkg_final"]
        else:
            pkg = x["pkg_initial"]
                
        log_table.append([x["time_str"],
                          x["host"],
                          x["user"],
                          x["action"],
                          pkg["name"],
                          pkg_initial,
                          pkg_final])

    if log_table:
        rcformat.tabular(["Time", "Host", "User", "Action", "Package", "Initial", "Final"], log_table)
    else:
        rctalk.message("No matches.")
Beispiel #3
0
def log_entries_list(entries):

    for item in entries:

        user_str = format_user_str(item)

        rctalk.message("   Time: " + item["time_str"])
        rctalk.message("   User: "******" Action: " + item["action"])

        if item.has_key("pkg_initial") and item.has_key("pkg_final"):
            init = item["pkg_initial"]
            rctalk.message(" Before: " + init["name"] + " " + \
                           rcformat.evr_to_str(init))

            fin = item["pkg_final"]
            rctalk.message("  After: " + fin["name"] + " " + \
                           rcformat.evr_to_str(fin))

        else:

            if item.has_key("pkg_initial"):
                pkg = item["pkg_initial"]
            else:
                pkg = item["pkg_final"]

            if pkg:
                rctalk.message("Package: " + pkg["name"] + " " + \
                               rcformat.evr_to_str(pkg))


        rctalk.message("")
Beispiel #4
0
def log_entries_to_table(entries):

    log_table = []

    for x in entries:

        pkg_initial = "-"
        if x.has_key("pkg_initial"):
            pkg_initial = rcformat.evr_to_str(x["pkg_initial"])

        pkg_final = "-"
        if x.has_key("pkg_final"):
            pkg_final = rcformat.evr_to_str(x["pkg_final"])

        if x.has_key("pkg_final"):
            pkg = x["pkg_final"]
        else:
            pkg = x["pkg_initial"]

        log_table.append([
            x["time_str"], x["host"], x["user"], x["action"], pkg["name"],
            pkg_initial, pkg_final
        ])

    if log_table:
        rcformat.tabular(
            ["Time", "Host", "User", "Action", "Package", "Initial", "Final"],
            log_table)
    else:
        rctalk.message("No matches.")
Beispiel #5
0
def log_entries_list(entries):

    for item in entries:

        user_str = format_user_str(item)

        rctalk.message("   Time: " + item["time_str"])
        rctalk.message("   User: "******" Action: " + item["action"])

        if item.has_key("pkg_initial") and item.has_key("pkg_final"):
            init = item["pkg_initial"]
            rctalk.message(" Before: " + init["name"] + " " + \
                           rcformat.evr_to_str(init))

            fin = item["pkg_final"]
            rctalk.message("  After: " + fin["name"] + " " + \
                           rcformat.evr_to_str(fin))

        else:

            if item.has_key("pkg_initial"):
                pkg = item["pkg_initial"]
            else:
                pkg = item["pkg_final"]

            if pkg:
                rctalk.message("Package: " + pkg["name"] + " " + \
                               rcformat.evr_to_str(pkg))

        rctalk.message("")
Beispiel #6
0
def verbose_updates_list(server, update_list):

    update_list.sort(lambda x, y:cmp(x[1]["importance_num"], y[1]["importance_num"]) \
                     or cmp(string.lower(x[1]["name"]), string.lower(y[1]["name"])))

    for update_item in update_list:

        old_pkg, new_pkg, descriptions = update_item

        ch = rcchannelutils.get_channel_by_id(server, new_pkg["channel"])

        rctalk.message("        Name: " + new_pkg["name"])
        rctalk.message("     Channel: " + ch["name"])
        rctalk.message("     Urgency: " + new_pkg["importance_str"])
        rctalk.message("Current Vers: " + rcformat.evr_to_str(old_pkg))
        rctalk.message(" Update Vers: " + rcformat.evr_to_str(new_pkg))

        header = "Enhancements: "
        last_desc = None
        for d in descriptions:
            if last_desc != d:  # don't print the same damn message many times
                rctalk.message(header + d)
            last_desc = d
            header = "              "

        rctalk.message("")
Beispiel #7
0
def terse_updates_table(server, update_list):

    update_table = []

    for update_item in update_list:

        old_pkg, new_pkg, descriptions = update_item

        urgency = "?"
        if new_pkg.has_key("importance_str"):
            urgency = new_pkg["importance_str"]

        channel_name = rcchannelutils.channel_id_to_name(
            server, new_pkg["channel"])

        old_ver = rcformat.evr_to_str(old_pkg)
        new_ver = rcformat.evr_to_str(new_pkg)

        update_table.append(
            [urgency, channel_name, new_pkg["name"], old_ver, new_ver])


    update_table.sort(lambda x,y:cmp(string.lower(x[1]), string.lower(y[1])) or \
                      cmp(string.lower(x[2]), string.lower(y[2])))

    rcformat.tabular([], update_table)
Beispiel #8
0
def display_match(server, match, extra_head=[], extra_tail=[]):
    table = []

    if match.has_key("glob"):
        table.append(("Name Pattern:", match["glob"]))

    if match.has_key("dep"): # looks like a RCPackageDep
        dep = match["dep"]
        table.append(("Name:", dep["name"]))
        vers  = rcformat.rel_str(dep) + rcformat.evr_to_str(dep)
        table.append(("Version:", vers))

    if match.has_key("channel"):
        str = rcchannelutils.channel_id_to_name(server, match["channel"])
        if not str:
            return 0
        table.append(("Channel:", str))

    if match.has_key("importance_num"):
        str = rcformat.importance_num_to_str(match["importance_num"])
        op = (match["importance_gteq"] and "<=") or ">="
        table.append(("Importance:", "%s %s" % (op, str)))

    table = extra_head + table + extra_tail

    maxlen = apply(max, map(lambda x:len(x[0]), table) + [0,])

    for label, val in table:
        rctalk.message("%s%s %s" % (" " * (maxlen - len(label)),
                                    label, val))
    return 1
Beispiel #9
0
    def execute(self, server, options_dict, non_option_args):

        if len(non_option_args) < 1:
            self.usage()
            sys.exit(1)

        plist = []

        for a in non_option_args:
            plist = plist + rcpackageutils.find_package(server, a, 1)

        if not plist:
            rctalk.message("--- No packages found ---")
            sys.exit(1)

        for pkg in plist:
            dep_info = server.rcd.packsys.package_dependency_info(pkg)

            if not dep_info.has_key("provides"):
                continue

            rctalk.message("--- %s %s ---" %
                           (pkg["name"], rcformat.evr_to_str(pkg)))

            for dep in dep_info["provides"]:
                rctalk.message(rcformat.dep_to_str(dep))

            rctalk.message("")
Beispiel #10
0
    def execute(self, server, options_dict, non_option_args):
        if len(non_option_args) == 0:
            self.usage()
            sys.exit(1)

        error_flag = 0
        for filename in non_option_args:

            full_fn = os.path.abspath(filename)

            try:
                plist = server.rcd.packsys.find_package_for_file(full_fn)
            except ximian_xmlrpclib.Fault, f:
                if f.faultCode == rcfault.package_not_found:
                    rctalk.error("No package owns file '%s'" % full_fn)
                    error_flag = 1
                    continue
                else:
                    raise

            prefix = ""
            if len(non_option_args) > 1:
                prefix = "%s: " % full_fn

            for p in plist:
                if options_dict.has_key("no-abbrev"):
                    rctalk.message("%s%s %s" %
                                   (prefix, p["name"], rcformat.evr_to_str(p)))
                else:
                    rctalk.message(
                        "%s%s %s" %
                        (prefix, p["name"], rcformat.evr_to_abbrev_str(p)))
Beispiel #11
0
    def execute(self, server, options_dict, non_option_args):
        if len(non_option_args) == 0:
            self.usage()
            sys.exit(1)

        error_flag = 0
        for filename in non_option_args:

            full_fn = os.path.abspath(filename)

            try:
                plist = server.rcd.packsys.find_package_for_file(full_fn)
            except ximian_xmlrpclib.Fault, f:
                if f.faultCode == rcfault.package_not_found:
                    rctalk.error("No package owns file '%s'" % full_fn)
                    error_flag = 1
                    continue
                else:
                    raise

            prefix = ""
            if len(non_option_args) > 1:
                prefix = "%s: " % full_fn

            for p in plist:
                if options_dict.has_key("no-abbrev"):
                    rctalk.message("%s%s %s" % (prefix,
                                                p["name"],
                                                rcformat.evr_to_str(p)))
                else:
                    rctalk.message("%s%s %s" % (prefix,
                                                p["name"],
                                                rcformat.evr_to_abbrev_str(p)))
Beispiel #12
0
def display_match(server, match, extra_head=[], extra_tail=[]):
    table = []

    if match.has_key("glob"):
        table.append(("Name Pattern:", match["glob"]))

    if match.has_key("dep"):  # looks like a RCPackageDep
        dep = match["dep"]
        table.append(("Name:", dep["name"]))
        vers = rcformat.rel_str(dep) + rcformat.evr_to_str(dep)
        table.append(("Version:", vers))

    if match.has_key("channel"):
        str = rcchannelutils.channel_id_to_name(server, match["channel"])
        if not str:
            return 0
        table.append(("Channel:", str))

    if match.has_key("importance_num"):
        str = rcformat.importance_num_to_str(match["importance_num"])
        op = (match["importance_gteq"] and "<=") or ">="
        table.append(("Importance:", "%s %s" % (op, str)))

    table = extra_head + table + extra_tail

    maxlen = apply(max,
                   map(lambda x: len(x[0]), table) + [
                       0,
                   ])

    for label, val in table:
        rctalk.message("%s%s %s" % (" " * (maxlen - len(label)), label, val))
    return 1
Beispiel #13
0
    def execute(self, server, options_dict, non_option_args):

        if len(non_option_args) < 1:
            self.usage()
            sys.exit(1)

        plist = []

        for a in non_option_args:
            plist = plist + rcpackageutils.find_package(server, a, 1)

        if not plist:
            rctalk.message("--- No packages found ---")
            sys.exit(1)

        for pkg in plist:
            dep_info = server.rcd.packsys.package_dependency_info(pkg)

            if not dep_info.has_key("provides"):
                continue

            rctalk.message("--- %s %s ---" %
                           (pkg["name"], rcformat.evr_to_str(pkg)))

            for dep in dep_info["provides"]:
                rctalk.message(rcformat.dep_to_str(dep))

            rctalk.message("")
Beispiel #14
0
def find_package(server, str, allow_unsub, allow_system=1):

    channel = None
    package = None

    # Check if the string is a file on the local filesystem.
    p = find_local_package(server, str)
    if p:
        return [p]

    # Check if the string is a supported URL
    p = find_remote_package(server, str)
    if p:
        return [p]

    # Okay, try to split the string into "channel:package"
    channel_id, package = split_channel_and_name(server, str)

    # Channel is set, so just get the package(s) from the channel.
    if channel_id:
        plist = find_package_in_channel(server, channel_id,
                                        package, allow_unsub)

        return plist

    # Okay, that didn't work.  First try to get the package from the list
    # of system packages.  After that, try to get the latest available
    # package.
    plist = []

    if allow_system:
        plist = find_package_on_system(server, package)

    if plist:
        quiet = 1
    else:
        quiet = 0

    new_plist = find_latest_package(server,
                                    package,
                                    allow_unsub,
                                    quiet)

    # Filter out packages already on the system, so we don't get both
    # the installed version of a package and the newest available
    # version.
    for p in new_plist:
        if not filter(lambda x, my_p=p:x["name"] == my_p["name"],
                      plist):
            rctalk.message("Using " + p["name"] + " " +
                           rcformat.evr_to_str(p) + " from the '" +
                           rcchannelutils.channel_id_to_name(server, p["channel"]) +
                           "' channel")
            plist.append(p)

    return plist
Beispiel #15
0
def terse_updates_table(server, update_list):

    update_table = []

    for update_item in update_list:

        old_pkg, new_pkg, descriptions = update_item

        urgency = "?"
        if new_pkg.has_key("importance_str"):
            urgency = new_pkg["importance_str"]

        channel_name = rcchannelutils.channel_id_to_name(server, new_pkg["channel"])

        old_ver = rcformat.evr_to_str(old_pkg)
        new_ver = rcformat.evr_to_str(new_pkg)

        update_table.append([urgency, channel_name, new_pkg["name"], old_ver, new_ver])


    update_table.sort(lambda x,y:cmp(string.lower(x[1]), string.lower(y[1])) or \
                      cmp(string.lower(x[2]), string.lower(y[2])))

    rcformat.tabular([], update_table)
Beispiel #16
0
def find_patch(server, str, allow_unsub, allow_system=1):

    channel = None
    patch = None

    # Try to split the string into "channel:package"
    channel_id, patch = rcpackageutils.split_channel_and_name(server, str)

    # Channel is set, so just get the patch(es) from the channel.
    if channel_id:
        plist = find_patch_in_channel(server, channel_id,
                                      patch, allow_unsub)

        return plist

    # Okay, that didn't work.  First try to get the patch from the list
    # of system patches.
    plist = []

    if allow_system:
        plist = find_patch_on_system(server, patch)

    if plist:
        quiet = 1
    else:
        quiet = 0

    new_plist = find_latest_patch(server,
                                  patch,
                                  allow_unsub,
                                  quiet)


    # Filter out patches already on the system, so we don't get both
    # the installed version of a patch and the newest available
    # version.
    for p in new_plist:
        if not filter(lambda x, my_p=p:x["name"] == my_p["name"],
                      plist):
            rctalk.message("Using " + p["name"] + " " +
                           rcformat.evr_to_str(p) + " from the '" +
                           rcchannelutils.channel_id_to_name(server, p["channel"]) +
                           "' channel")
            plist.append(p)

    return plist
Beispiel #17
0
def find_patch(server, str, allow_unsub, allow_system=1):

    channel = None
    patch = None

    # Try to split the string into "channel:package"
    channel_id, patch = rcpackageutils.split_channel_and_name(server, str)

    # Channel is set, so just get the patch(es) from the channel.
    if channel_id:
        plist = find_patch_in_channel(server, channel_id, patch, allow_unsub)

        return plist

    # Okay, that didn't work.  First try to get the patch from the list
    # of system patches.
    plist = []

    if allow_system:
        plist = find_patch_on_system(server, patch)

    if plist:
        quiet = 1
    else:
        quiet = 0

    new_plist = find_latest_patch(server, patch, allow_unsub, quiet)

    # Filter out patches already on the system, so we don't get both
    # the installed version of a patch and the newest available
    # version.
    for p in new_plist:
        if not filter(lambda x, my_p=p: x["name"] == my_p["name"], plist):
            rctalk.message(
                "Using " + p["name"] + " " + rcformat.evr_to_str(p) +
                " from the '" +
                rcchannelutils.channel_id_to_name(server, p["channel"]) +
                "' channel")
            plist.append(p)

    return plist
Beispiel #18
0
def format_dependencies(server, dep_list):
    dep_list.sort(lambda x,y:cmp(string.lower(extract_package(x)["name"]),
                                 string.lower(extract_package(y)["name"])))

    dlist = []
    for d in dep_list:
        p = extract_package(d)

        c = rcchannelutils.channel_id_to_name(server, p["channel"])
        if c:
            c = "(" + c + ")"
        else:
            c = ""

        rctalk.message("  " + p["name"] + " " + rcformat.evr_to_str(p) +
                       " " + c)

        if d.has_key("details"):
            map(lambda x:rctalk.message("    " + x), d["details"])

    rctalk.message("")
Beispiel #19
0
def format_dependencies(server, dep_list):
    dep_list.sort(lambda x, y: cmp(string.lower(extract_package(x)["name"]),
                                   string.lower(extract_package(y)["name"])))

    dlist = []
    for d in dep_list:
        p = extract_package(d)

        c = rcchannelutils.channel_id_to_name(server, p["channel"])
        if c:
            c = "(" + c + ")"
        else:
            c = ""

        rctalk.message("  " + p["name"] + " " + rcformat.evr_to_str(p) + " " +
                       c)

        if d.has_key("details"):
            map(lambda x: rctalk.message("    " + x), d["details"])

    rctalk.message("")
Beispiel #20
0
    def execute(self, server, options_dict, non_option_args):

        if len(non_option_args) < 1:
            self.usage()
            sys.exit(1)

        plist = []

        for a in non_option_args:
            plist = plist + rcpackageutils.find_package(server, a, 1)

        if not plist:
            rctalk.message("--- No packages found ---")
            sys.exit(1)

        for pkg in plist:
            dep_info = server.rcd.packsys.package_dependency_info(pkg)

            if not dep_info.has_key("obsoletes"):
                continue

            table = []

            for dep in dep_info["obsoletes"]:
                provided_by = map(lambda x: x[0],
                                  server.rcd.packsys.what_provides(dep))
                ob_dict = {}

                name = rcformat.dep_to_str(dep)
                status = ""
                for provider in provided_by:
                    if provider["installed"]:
                        status = "*"

                count = 0
                for provider in provided_by:
                    # skip self-obsoletes
                    if evr_eq(provider, pkg):
                        continue

                    if provider["installed"]:
                        status = "*"
                    else:
                        status = ""

                    row = rcformat.package_to_row(
                        server, provider, 0, ["name", "installed", "channel"])
                    key = string.join(row)
                    if not ob_dict.has_key(key):
                        table.append([status, name] + row)
                        ob_dict[key] = 1
                        status = ""
                        name = ""
                        count = count + 1

                if count == 0:
                    table.append(["", name, "", "", ""])
                elif count > 1:
                    table.append(["", "", "", "", ""])

            if len(plist) > 1:
                rctalk.message("--- %s %s ---" %
                               (pkg["name"], rcformat.evr_to_str(pkg)))

            if not table:
                rctalk.message("--- No obsoletes ---")
            else:
                rcformat.tabular(
                    ["!", "Obsoletes", "Provided by", "S", "Channel"], table)

            if len(plist) > 1:
                rctalk.message("")
Beispiel #21
0
    def execute(self, server, options_dict, non_option_args):

        if len(non_option_args) < 1:
            self.usage()
            sys.exit(1)

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

        plist = []

        for a in non_option_args:
            plist = plist + rcpackageutils.find_package(server, a, 1)

        if not plist:
            rctalk.message("--- No packages found ---")
            sys.exit(1)

        for pkg in plist:
            dep_info = server.rcd.packsys.package_dependency_info(pkg)

            if not dep_info.has_key("children"):
                continue

            table = []

            row_spec = ["name", "channel"]
            row_headers = ["Provided By", "Channel"]
            pad = []

            if options_dict.has_key("show-versions"):
                row_spec.insert(1, "version")
                row_headers.insert(1, "Version")
                pad = pad + [""]

            if options_dict.has_key("all-providers"):
                row_spec.insert(2, "installed")
                row_headers.insert(2, "S")
                pad = pad + [""]

            for dep in dep_info["children"]:
                providers = map(lambda x: x[0],
                                server.rcd.packsys.what_provides(dep))
                prov_dict = {}

                name = rcformat.dep_to_str(dep)
                status = "*"
                for prov in providers:
                    if prov["installed"]:
                        status = ""

                if status == "" \
                       and not options_dict.has_key("all-providers"):
                    providers = filter(lambda x: x["installed"], providers)

                count = 0
                for prov in providers:
                    row = rcformat.package_to_row(server, prov, no_abbrev,
                                                  row_spec)
                    key = string.join(row)
                    if not prov_dict.has_key(key):
                        table.append([status, name] + row)
                        prov_dict[key] = 1
                        status = ""
                        name = ""
                        count = count + 1

                if count == 0:
                    table.append(["*", name, "(none)", "(none)"] + pad)
                elif count > 1 and not rctalk.be_terse:
                    table.append(["", "", "", ""] + pad)

            if len(plist) > 1:
                rctalk.message("--- %s %s ---" %
                               (pkg["name"], rcformat.evr_to_str(pkg)))

            if not table:
                rctalk.message("--- No Children ---")
            else:
                rcformat.tabular(["!", "Requirement"] + row_headers, table)

            if len(plist) > 1:
                rctalk.message("")
Beispiel #22
0
    def execute(self, server, options_dict, non_option_args):
        locks = server.rcd.packsys.get_locks()

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

        if locks:
            table = []
            count = 1
            for l in locks:
                pkgs = []
                if matches:
                    pkgs = server.rcd.packsys.search_by_package_match(l)
                    pkgs = filter_package_dups(pkgs)

                visible = 1

                if verbose:
                    extra_head = [("Lock #:", str(count))]
                    extra_tail = []
                    if matches:
                        first = 1
                        for p in pkgs:
                            label = (first == 1 and "Matches:") or ""
                            first = 0
                            id = p.get("channel_guess", 0) or p["channel"]
                            if id:
                                channel = rcchannelutils.channel_id_to_name(
                                    server, id)
                                channel = "(%s)" % channel
                            else:
                                channel = ""
                            pkg_str = "%s %s %s" % (
                                p["name"], rcformat.evr_to_str(p), channel)

                            extra_tail.append((label, pkg_str))

                    if display_match(server, l, extra_head, extra_tail):
                        rctalk.message("")
                    else:
                        visible = 0

                else:
                    row = lock_to_table_row(server, l, no_abbrev)
                    if row is not None:
                        row.insert(0, str(count))
                        if matches:
                            row.append(str(len(pkgs)))
                        table.append(row)
                    else:
                        visible = 0

                if visible:
                    count = count + 1

            if not verbose:
                headers = ["#", "Pattern", "Channel", "Importance"]
                if matches:
                    headers.append("Matches")
                rcformat.tabular(headers, table)

        else:
            rctalk.message("--- No Locks Defined ---")
Beispiel #23
0
    def execute(self, server, options_dict, non_option_args):

        if len(non_option_args) < 1:
            self.usage()
            sys.exit(1)

        plist = []

        for a in non_option_args:
            plist = plist + rcpackageutils.find_package(server, a, 1)

        if not plist:
            rctalk.message("--- No packages found ---")
            sys.exit(1)

        for pkg in plist:
            dep_info = server.rcd.packsys.package_dependency_info(pkg)

            if not dep_info.has_key("obsoletes"):
                continue

            table = []

            for dep in dep_info["obsoletes"]:
                provided_by = map(lambda x:x[0], server.rcd.packsys.what_provides(dep))
                ob_dict = {}

                name = rcformat.dep_to_str(dep)
                status = ""
                for provider in provided_by:
                    if provider["installed"]:
                        status = "*"

                count = 0
                for provider in provided_by:
                    # skip self-obsoletes
                    if evr_eq(provider, pkg):
                        continue

                    if provider["installed"]:
                        status = "*"
                    else:
                        status = ""
                    
                    row = rcformat.package_to_row(server, provider, 0, ["name", "installed", "channel"])
                    key = string.join(row)
                    if not ob_dict.has_key(key):
                        table.append([status, name] + row)
                        ob_dict[key] = 1
                        status = ""
                        name = ""
                        count = count + 1

                if count == 0:
                    table.append(["", name, "", "", ""])
                elif count > 1:
                    table.append(["", "", "", "", ""])

            if len(plist) > 1:
                rctalk.message("--- %s %s ---" %
                               (pkg["name"], rcformat.evr_to_str(pkg)))

            if not table:
                rctalk.message("--- No obsoletes ---")
            else:
                rcformat.tabular(["!", "Obsoletes", "Provided by", "S", "Channel"], table)

            if len(plist) > 1:
                rctalk.message("")
Beispiel #24
0
    def execute(self, server, options_dict, non_option_args):

        if len(non_option_args) < 1:
            self.usage()
            sys.exit(1)

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

        plist = []

        for a in non_option_args:
            plist = plist + rcpackageutils.find_package(server, a, 1)

        if not plist:
            rctalk.message("--- No packages found ---")
            sys.exit(1)

        for pkg in plist:
            dep_info = server.rcd.packsys.package_dependency_info(pkg)

            if not dep_info.has_key("children"):
                continue

            table = []

            row_spec = ["name", "channel"]
            row_headers = ["Provided By", "Channel"]
            pad = []

            if options_dict.has_key("show-versions"):
                row_spec.insert(1, "version")
                row_headers.insert(1, "Version")
                pad = pad + [""]

            if options_dict.has_key("all-providers"):
                row_spec.insert(2, "installed")
                row_headers.insert(2, "S")
                pad = pad + [""]

            for dep in dep_info["children"]:
                providers = map(lambda x:x[0], server.rcd.packsys.what_provides(dep))
                prov_dict = {}

                name = rcformat.dep_to_str(dep)
                status = "*"
                for prov in providers:
                    if prov["installed"]:
                        status = ""

                if status == "" \
                       and not options_dict.has_key("all-providers"):
                    providers = filter(lambda x:x["installed"], providers)


                count = 0
                for prov in providers:
                    row = rcformat.package_to_row(server, prov, no_abbrev, row_spec)
                    key = string.join(row)
                    if not prov_dict.has_key(key):
                        table.append([status, name] + row)
                        prov_dict[key] = 1
                        status = ""
                        name = ""
                        count = count + 1

                if count == 0:
                    table.append(["*", name, "(none)", "(none)"] + pad)
                elif count > 1 and not rctalk.be_terse:
                    table.append(["", "", "", ""] + pad)

            if len(plist) > 1:
                rctalk.message("--- %s %s ---" %
                               (pkg["name"], rcformat.evr_to_str(pkg)))

            if not table:
                rctalk.message("--- No Children ---")
            else:
                rcformat.tabular(["!", "Requirement"] + row_headers, table)

            if len(plist) > 1:
                rctalk.message("")
Beispiel #25
0
    def execute(self, server, options_dict, non_option_args):
        locks = server.rcd.packsys.get_locks()

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

        if locks:
            table = []
            count = 1
            for l in locks:
                pkgs = []
                if matches:
                    pkgs = server.rcd.packsys.search_by_package_match(l)
                    pkgs = filter_package_dups(pkgs)

                visible = 1

                if verbose:
                    extra_head = [("Lock #:", str(count))]
                    extra_tail = []
                    if matches:
                        first = 1
                        for p in pkgs:
                            label = (first == 1 and "Matches:") or ""
                            first = 0
                            id = p.get("channel_guess", 0) or p["channel"]
                            if id:
                                channel = rcchannelutils.channel_id_to_name(server, id)
                                channel = "(%s)" % channel
                            else:
                                channel = ""
                            pkg_str = "%s %s %s" % (p["name"],
                                                    rcformat.evr_to_str(p),
                                                    channel)

                            extra_tail.append((label, pkg_str))
                    
                    if display_match(server, l, extra_head, extra_tail):
                        rctalk.message("")
                    else:
                        visible = 0
                            
                else:
                    row = lock_to_table_row(server, l, no_abbrev)
                    if row is not None:
                        row.insert(0, str(count))
                        if matches:
                            row.append(str(len(pkgs)))
                        table.append(row)
                    else:
                        visible = 0

                if visible:
                    count = count + 1

            if not verbose:
                headers = ["#", "Pattern", "Channel", "Importance"]
                if matches:
                    headers.append("Matches")
                rcformat.tabular(headers, table)

        else:
            rctalk.message("--- No Locks Defined ---")