Exemple #1
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)))
Exemple #2
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)))
Exemple #3
0
def log_entries_to_quick_table(entries):

    log_table = []

    for item in entries:

        date_str = time.strftime("%Y-%m-%d", time.localtime(item["timestamp"]))

        if item.has_key("pkg_final"):
            pkg = item["pkg_final"]
        else:
            pkg = item["pkg_initial"]
        
        log_table.append([date_str, item["action"], pkg["name"],
                          rcformat.evr_to_abbrev_str(pkg)])

    if log_table:
        rcformat.tabular(["Date", "Action", "Package", "Version"], log_table)
    else:
        rctalk.message("No matches.")
Exemple #4
0
def log_entries_to_quick_table(entries):

    log_table = []

    for item in entries:

        date_str = time.strftime("%Y-%m-%d", time.localtime(item["timestamp"]))

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

        log_table.append([
            date_str, item["action"], pkg["name"],
            rcformat.evr_to_abbrev_str(pkg)
        ])

    if log_table:
        rcformat.tabular(["Date", "Action", "Package", "Version"], log_table)
    else:
        rctalk.message("No matches.")
Exemple #5
0
    def execute(self, server, options_dict, non_option_args):

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

        if options_dict.has_key("allow-unsubscribed"):
            allow_unsub = 1
        else:
            allow_unsub = 0

        plist = []

        for a in non_option_args:
            inform = 0
            channel = None
            package = None

            plist = plist + rcpackageutils.find_package(server, a, allow_unsub)

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

        for p in plist:
            pinfo = server.rcd.packsys.package_info(p)

            rctalk.message("")
            rctalk.message("Name: " + p["name"])
            rctalk.message("Version: " + p["version"])
            rctalk.message("Release: " + p["release"])
            if p["installed"]:
                rctalk.message("Installed: Yes")
                update = rcpackageutils.find_latest_package(server, a, allow_unsub, 1)
                if not len(update):
                    rctalk.message("Status: up-to-date")
                else:
                    rctalk.message("Status: update available (%s)" % update[0]["version"])
            else:
                rctalk.message("Installed: No")
            if pinfo.get("file_size", 0):
                rctalk.message("Package size: " + str(pinfo["file_size"]))
            if pinfo.get("installed_size", 0):
                rctalk.message("Installed size: " + str(pinfo["installed_size"]))
            rctalk.message("Summary: " + pinfo["summary"])
            rctalk.message("Description: ")
            rctalk.message(pinfo["description"])

            log_entries = server.rcd.log.query_log([["name", "=", p["name"]]])
            if log_entries:

                # Reverse chronological order
                log_entries.sort(lambda x,y:cmp(y["timestamp"], x["timestamp"]))

                act_len_list = map(lambda x:len(x["action"]), log_entries)
                if len(act_len_list) > 1:
                    act_len = apply(max, act_len_list)
                else:
                    act_len = act_len_list[0]
                
                rctalk.message("\nHistory:")
                                
                for item in log_entries:

                    init_str = ""
                    fin_str = ""

                    if item.has_key("pkg_initial"):
                        init_str = rcformat.evr_to_abbrev_str(item["pkg_initial"])
                    if item.has_key("pkg_final"):
                        fin_str = rcformat.evr_to_abbrev_str(item["pkg_final"])

                    if init_str and fin_str:
                        pkg_str = init_str + " => " + fin_str
                    elif init_str:
                        pkg_str = init_str
                    elif fin_str:
                        pkg_str = fin_str

                    time_str = time.strftime("%Y-%m-%d %H:%M,",
                                             time.localtime(item["timestamp"]))

                    action_str = string.ljust(item["action"] + ",", act_len+1)

                    if pkg_str:
                        rctalk.message(time_str + " " + action_str + " " + pkg_str)
Exemple #6
0
    def execute(self, server, options_dict, non_option_args):

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

        if options_dict.has_key("allow-unsubscribed"):
            allow_unsub = 1
        else:
            allow_unsub = 0

        plist = []

        for a in non_option_args:
            inform = 0
            channel = None
            package = None

            plist = plist + rcpackageutils.find_package(server, a, allow_unsub)

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

        for p in plist:
            pinfo = server.rcd.packsys.package_info(p)

            rctalk.message("")
            rctalk.message("Name: " + p["name"])
            rctalk.message("Version: " + p["version"])
            rctalk.message("Release: " + p["release"])
            if p["installed"]:
                rctalk.message("Installed: Yes")
                update = rcpackageutils.find_latest_package(
                    server, a, allow_unsub, 1)
                if not len(update):
                    rctalk.message("Status: up-to-date")
                else:
                    rctalk.message("Status: update available (%s)" %
                                   update[0]["version"])
            else:
                rctalk.message("Installed: No")
            if pinfo.get("file_size", 0):
                rctalk.message("Package size: " + str(pinfo["file_size"]))
            if pinfo.get("installed_size", 0):
                rctalk.message("Installed size: " +
                               str(pinfo["installed_size"]))
            rctalk.message("Summary: " + pinfo["summary"])
            rctalk.message("Description: ")
            rctalk.message(pinfo["description"])

            log_entries = server.rcd.log.query_log([["name", "=", p["name"]]])
            if log_entries:

                # Reverse chronological order
                log_entries.sort(
                    lambda x, y: cmp(y["timestamp"], x["timestamp"]))

                act_len_list = map(lambda x: len(x["action"]), log_entries)
                if len(act_len_list) > 1:
                    act_len = apply(max, act_len_list)
                else:
                    act_len = act_len_list[0]

                rctalk.message("\nHistory:")

                for item in log_entries:

                    init_str = ""
                    fin_str = ""

                    if item.has_key("pkg_initial"):
                        init_str = rcformat.evr_to_abbrev_str(
                            item["pkg_initial"])
                    if item.has_key("pkg_final"):
                        fin_str = rcformat.evr_to_abbrev_str(item["pkg_final"])

                    if init_str and fin_str:
                        pkg_str = init_str + " => " + fin_str
                    elif init_str:
                        pkg_str = init_str
                    elif fin_str:
                        pkg_str = fin_str

                    time_str = time.strftime("%Y-%m-%d %H:%M,",
                                             time.localtime(item["timestamp"]))

                    action_str = string.ljust(item["action"] + ",",
                                              act_len + 1)

                    if pkg_str:
                        rctalk.message(time_str + " " + action_str + " " +
                                       pkg_str)