Ejemplo n.º 1
0
    def execute(self, server, options_dict, non_option_args):

        no_abbrev = options_dict.has_key("no-abbrev") or \
                    options_dict.has_key("terse")

        min_importance = None
        if options_dict.has_key("importance"):
            if not rcpackageutils.update_importances.has_key(
                    options_dict["importance"]):
                rctalk.warning("Invalid importance: " +
                               options_dict["importance"])
            else:
                min_importance = rcpackageutils.update_importances[
                    options_dict["importance"]]

        update_list = rcpackageutils.get_updates(server,
                                                 non_option_args,
                                                 allow_dups=1)

        if min_importance != None:
            up = []
            for u in update_list:
                # higher priorities have lower numbers... i know, i know...
                if u[1]["importance_num"] <= min_importance:
                    up.append(u)
        else:
            up = update_list

        if not up:
            if non_option_args:
                rctalk.message(
                    "No updates are available in the specified channels.")
            else:
                rctalk.message("No updates are available.")

                if not filter(lambda x: x["subscribed"],
                              rcchannelutils.get_channels(server)):
                    rctalk.message("")
                    rctalk.warning(
                        "Updates are only visible when you are subscribed to a channel."
                    )
            sys.exit(0)

        if rctalk.show_verbose:
            verbose_updates_list(server, up)
        elif rctalk.be_terse:
            terse_updates_table(server, up)
        else:
            exploded_updates_table(server, up, no_abbrev)
Ejemplo n.º 2
0
def filter_visible_channels(server, packages):
    visible_channels = map(lambda c:c["id"],
                           filter(lambda c:not c["hidden"],
                                  rcchannelutils.get_channels(server)))

    # Return a filtered list of packages, each of which:
    #
    #  (a) is in a visible channel.
    #  (b) is not in a visible channel, but doesn't have a guessed channel
    #      (indicating that it's a system package and we don't know what
    #      channel it came from)

    return filter(lambda p:p["channel"] in visible_channels
                  or not p.has_key("channel_guess"),
                  packages)
Ejemplo n.º 3
0
    def execute(self, server, options_dict, non_option_args):

        service = None
        if options_dict.has_key("service"):
            services = rcserviceutils.get_services(server)
            service = rcserviceutils.find_service(services,
                                                  options_dict["service"])

            if not service:
                rctalk.error("Unknown service '%s'" % options_dict["service"])
                sys.exit(1)

        failed = 0
        to_do = []
        if options_dict.has_key("all"):
            to_do = filter(lambda c:not c["hidden"],
                           rcchannelutils.get_channels(server))
            if service:
                to_do = filter(lambda c,s=service:c.get("service") == s["id"],
                               to_do)
        else:
            for a in non_option_args:
                clist = rcchannelutils.get_channels_by_name(server, a, service)
                if not rcchannelutils.validate_channel_list(a, clist):
                    failed = 1
                else:
                    c = clist[0]
                    to_do.append(c)
                    if options_dict.has_key("strict") and not c["subscribed"]:
                        rctalk.error("Not subscribed to channel " + \
                                     rcchannelutils.channel_to_str(c))
                        failed = 1

        if failed:
            sys.exit(1)

        for c in to_do:
            if c:
                if server.rcd.packsys.unsubscribe(c["id"]):
                    rctalk.message("Unsubscribed from channel " + \
                                   rcchannelutils.channel_to_str(c))
                else:
                    rctalk.warning("Attempt to unsubscribe to channel " + \
                                   rcchannelutils.channel_to_str(c) + " failed")
Ejemplo n.º 4
0
    def execute(self, server, options_dict, non_option_args):

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

        path = os.path.abspath(non_option_args[0])
        path_base = os.path.basename(path)

        aliases = map(rcchannelutils.get_channel_alias,
                      rcchannelutils.get_channels(server))

        complain_about_collision = 0
        alias = string.lower(path_base)
        if options_dict.has_key("alias"):
            alias = options_dict["alias"]
            complain_about_collision = 1

        # Ensure we don't have an alias collision
        old_alias = alias
        count = 1
        while alias in aliases:
            alias = "%s-%d" % (old_alias, count)
            count = count + 1

        if old_alias != alias and complain_about_collision:
            rctalk.warning("Alias '%s' already in use.  Using '%s' instead." %
                           (old_alias, alias))

        name = options_dict.get("name", path)
        if options_dict.has_key("recurse"):
            recursive = 1
        else:
            recursive = 0

        try:
            server.rcd.packsys.mount_directory(path, name, alias, recursive)
        except ximian_xmlrpclib.Fault, f:
            if f.faultCode == rcfault.invalid_service:
                rctalk.error(f.faultString)
                sys.exit(1)
            else:
                raise
Ejemplo n.º 5
0
    def execute(self, server, options_dict, non_option_args):

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

        path = os.path.abspath(non_option_args[0])
        path_base = os.path.basename(path)

        aliases = map(rcchannelutils.get_channel_alias,
                      rcchannelutils.get_channels(server))

        complain_about_collision = 0
        alias = string.lower(path_base)
        if options_dict.has_key("alias"):
            alias = options_dict["alias"]
            complain_about_collision = 1

        # Ensure we don't have an alias collision
        old_alias = alias
        count = 1
        while alias in aliases:
            alias = "%s-%d" % (old_alias, count)
            count = count + 1

        if old_alias != alias and complain_about_collision:
            rctalk.warning("Alias '%s' already in use.  Using '%s' instead." %
                           (old_alias, alias))

        name = options_dict.get("name", path)
        if options_dict.has_key("recurse"):
            recursive = 1
        else:
            recursive = 0

        try:
            server.rcd.packsys.mount_directory(path, name, alias, recursive)
        except ximian_xmlrpclib.Fault, f:
            if f.faultCode == rcfault.invalid_service:
                rctalk.error(f.faultString)
                sys.exit(1)
            else:
                raise
Ejemplo n.º 6
0
    def execute(self, server, options_dict, non_option_args):

        no_abbrev = options_dict.has_key("no-abbrev") or \
                    options_dict.has_key("terse")

        min_importance = None
        if options_dict.has_key("importance"):
            if not rcpackageutils.update_importances.has_key(options_dict["importance"]):
                rctalk.warning("Invalid importance: " +
                               options_dict["importance"])
            else:
                min_importance = rcpackageutils.update_importances[options_dict["importance"]]

        update_list = rcpackageutils.get_updates(server, non_option_args,
                                                 allow_dups=1)

        if min_importance != None:
            up = []
            for u in update_list:
                # higher priorities have lower numbers... i know, i know...
                if u[1]["importance_num"] <= min_importance:
                    up.append(u)
        else:
            up = update_list
        
        if not up:
            if non_option_args:
                rctalk.message("No updates are available in the specified channels.")
            else:
                rctalk.message("No updates are available.")

                if not filter(lambda x:x["subscribed"], rcchannelutils.get_channels(server)):
                    rctalk.message("")
                    rctalk.warning("Updates are only visible when you are subscribed to a channel.")
            sys.exit(0)

        if rctalk.show_verbose:
            verbose_updates_list(server, up)
        elif rctalk.be_terse:
            terse_updates_table(server, up)
        else:
            exploded_updates_table(server, up, no_abbrev)
Ejemplo n.º 7
0
    def execute(self, server, options_dict, non_option_args):

        channels = rcchannelutils.get_channels(server)
        channel_table = []

        if options_dict.has_key("service"):
            services = rcserviceutils.get_services(server)
            service = rcserviceutils.find_service(services,
                                                  options_dict["service"])

            if not service:
                rctalk.error("Unknown service '%s'" % options_dict["service"])
                sys.exit(1)

            channels = filter(lambda c,s=service:c.get("service") == s["id"],
                              channels)

        headers = ["subd?", "Alias", "Name"]
        if options_dict.has_key("show-ids"):
            headers.insert(2, "ID")
        if options_dict.has_key("show-services"):
            headers.append("Service")

        for c in channels:

            show = 1

            if c["hidden"]:
                show = 0

            if c["subscribed"]:
                if rctalk.be_terse:
                    subflag = "Yes"
                else:
                    subflag = " Yes "
                if options_dict.has_key("unsubscribed"):
                    show = 0
            else:
                subflag = ""
                if options_dict.has_key("subscribed"):
                    show = 0

            if options_dict.has_key("mounted") and not c["mounted"]:
                show = 0

            if show:
                row = [subflag, rcchannelutils.get_channel_alias(c), c["name"]]
                if options_dict.has_key("show-ids"):
                    row.insert(2, c["id"])
                if options_dict.has_key("show-services"):
                    services = rcserviceutils.get_services(server)
                    service = rcserviceutils.find_service(services, c["service"])
                    row.append(service["name"])
                channel_table.append(row)

        if channel_table:
            channel_table.sort(lambda x, y:cmp(x[2],y[2]))
            rcformat.tabular(headers, channel_table)
        else:
            if options_dict.has_key("unsubscribed"):
                rctalk.message("--- No unsubscribed channels ---")
            elif options_dict.has_key("subscribed"):
                rctalk.message("--- No subscribed channels ---")
            elif options_dict.has_key("mounted"):
                rctalk.message("--- No mounted channels ---")
            else:
                rctalk.warning("--- No channels available ---")