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

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

        if non_option_args:
            services = rcserviceutils.get_services(server)
            s = rcserviceutils.find_service(services, non_option_args[0])

            if not s:
                rctalk.error("No service matches '%s'" % non_option_args[0])
                sys.exit(1)

            rcchannelutils.refresh_channels(server, s["id"])
        else:
            rcchannelutils.refresh_channels(server)
Exemplo n.º 2
0
    def execute(self, server, options_dict, non_option_args):

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

        services = rcserviceutils.get_services(server)
        service = rcserviceutils.find_service(services, non_option_args[0])

        if not service:
            rctalk.error("No service matches '%s'" % non_option_args[0])
            sys.exit(1)

        verbose = options_dict.has_key("verbose")
        list_only = options_dict.has_key("list-only")

        select_str = ""

        show_list = 1
        allow_select = not list_only

        if len(non_option_args) > 1:
            show_list = 0
            allow_select = 0
            select_str = non_option_args[1]

        current_host = service["url"]

        def sort_cb(a, b):
            aname = string.lower(a["name"])
            bname = string.lower(b["name"])

            # "All Animals Are Equal / But Some Are More Equal Than Others."
            if aname[:6] == "ximian":
                aname = "a" * 10
            if bname[:6] == "ximian":
                bname = "a" * 10

            return cmp(aname, bname)

        try:
            mirrors = server.rcd.service.get_mirrors(service["id"])
        except ximian_xmlrpclib.Fault, f:
            if f.faultCode == rcfault.invalid_service:
                mirrors = None
Exemplo 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")
Exemplo n.º 4
0
    def execute(self, server, options_dict, non_option_args):
        if len(non_option_args) < 2:
            self.usage()
            sys.exit(1)

        err_str = None
        success = 0

        activation_info = {}
        activation_info["activation_code"] = non_option_args[0]
        activation_info["email"] = non_option_args[1]

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

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

            activation_info["service"] = s["id"]

        if options_dict.has_key("alias"):
            activation_info["alias"] = options_dict["alias"]

        try:
            server.rcd.service.activate(activation_info)
        except ximian_xmlrpclib.Fault, f:
            if f.faultCode == rcfault.cant_activate \
                   or f.faultCode == rcfault.invalid_service:

                err_str = f.faultString
                success = 0
            else:
                raise
Exemplo n.º 5
0
    def execute(self, server, options_dict, non_option_args):
        if len(non_option_args) < 1:
            self.usage()
            sys.exit(1)

        services = rcserviceutils.get_services(server)

        for o in non_option_args:
            s = rcserviceutils.find_service(services, o)

            if not s:
                rctalk.error("No service matches '%s'" % o)
                sys.exit(1)

            try:
                server.rcd.service.remove(s["id"])
            except ximian_xmlrpclib.Fault, f:
                if f.faultCode != rcfault.invalid_service:
                    raise

                rctalk.error(f.faultString)
            else:
                rctalk.message("Service '%s' successfully removed." %
                               s["name"])
Exemplo n.º 6
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 ---")