Exemple #1
0
        dlist = []

        for d in non_option_args:
            dep = rcpackageutils.parse_dep_str(server, d)

            dups = filter(lambda x, d=dep: x["name"] == d["name"], dlist)

            if dups:
                rctalk.warning("Duplicate entry found: " + dups[0]["name"])

            dlist.append(dep)

        install_deps, remove_deps, dep_info = \
                      resolve_dependencies(server, [], [], dlist)

        if not install_deps and not remove_deps:
            rctalk.message("Requirements are already met on the system.  No "
                           "packages need to be")
            rctalk.message("installed or removed.")
            sys.exit(0)

        self.transact(server, options_dict, [], install_deps, [], remove_deps)


rccommand.register(PackageInstallCmd)
rccommand.register(PackageRemoveCmd)
rccommand.register(PackageUpdateCmd)
rccommand.register(PackageVerifyCmd)
rccommand.register(PackageSolveCmd)
rccommand.register(PackageRollbackCmd)
Exemple #2
0
            if db <= 0:
                rctalk.warning("Ignoring invalid argument to --days-back option.")
            else:
                days_back = db

        secs_back = int(days_back * 86400)  # 1 day = 86400 sec

        query.append(["cutoff_time", "<=", str(secs_back)])

        ## Pass our query to the server, and get a pile of log entries back.
        ## We need to sort them, since they aren't guaranteed to be in any
        ## particular order.

        entries = server.rcd.log.query_log(query)
        entries.sort(lambda x,y:cmp(x["timestamp"], y["timestamp"]))

        ## The way we display the data depends on how
        ## talkative we have been told to be.

        if rctalk.be_terse:
            log_entries_to_table(entries)
        elif rctalk.show_verbose:
            log_entries_list(entries)
        else:
            log_entries_to_quick_table(entries)


rccommand.register(LogQueryCmd)
                
Exemple #3
0
    def description_short(self):
        return "List packages that require the item you specify"

    def query_fn(self, server):
        return server.rcd.packsys.what_requires


###
### "what-conflicts" command
###


class WhatConflictsCmd(WhateverCmd):
    def name(self):
        return "what-conflicts"

    def aliases(self):
        return ["wc"]

    def description_short(self):
        return "List packages that conflict with the item you specify"

    def query_fn(self, server):
        return server.rcd.packsys.what_conflicts


rccommand.register(WhatProvidesCmd)
rccommand.register(WhatRequiresCmd)
rccommand.register(WhatConflictsCmd)
Exemple #4
0
        if not options_dict.has_key("no-confirmation"):
            rctalk.message("")
            if len(to_delete) == 1:
                msg = "this lock"
            else:
                msg = "these locks"
            confirm = rctalk.prompt("Delete %s? [y/N]" % msg)
            if not confirm or not string.lower(confirm[0]) == "y":
                rctalk.message("Cancelled.")
                sys.exit(0)

        failures = []
        for l, i in map(lambda x, y: (x, y), to_delete, indices):
            retval = server.rcd.packsys.remove_lock(l)
            if not retval:
                failures.append(i)

        if failures:
            rctalk.warning("Unable to remove lock%s %s",
                           (len(failures) > 1 and "s") or "",
                           string.join(map(str, failures), ", "))
            sys.exit(1)

        
        
        

rccommand.register(LockListCmd)
rccommand.register(LockAddCmd)
rccommand.register(LockDeleteCmd)
Exemple #5
0
        # ones in the "hidden" channels, like the system packages channel.
        patches = rcpackageutils.filter_visible_channels(server, patches)

        for p in patches:
            row = rcformat.package_to_row(server, p,
                                          options_dict.has_key("no-abbrev"),
                                          keys)
            patch_table.append(row)

        if patch_table:
            rcformat.tabular(headers, patch_table)
        else:
            rctalk.message("--- No Patches found ---")


rccommand.register(ListYouPatchesCmd)


def find_latest_patch(server, patch, allow_unsub, quiet):
    plist = server.rcd.you.search([["name", "is", patch],
                                   ["installed", "is", "false"]])

    if not plist:
        if not quiet:
            if allow_unsub:
                rctalk.error("Unable to find patch '%s'" % patch)
            else:
                rctalk.error("Unable to find patch '%s' in any " \
                             "subscribed channel" % patch)
        return []
Exemple #6
0
        ### For now, we just do something pretty mindless

        ### FIXME: the channel selection aren't supported yet

        news = server.rcd.news.get_all()

        if not news:
            rctalk.message("--- No news available ---")
            sys.exit(0)

        for n in news:
            if n.has_key("service_name"):
                rctalk.message("[%s]" % n["service_name"])
            if n.has_key("title"):
                rctalk.message(textify_entities(n["title"]))
            if n.has_key("time_str"):
                rctalk.message("("+n["time_str"]+")")
            if n.has_key("summary"):
                summary = re.sub("\s+", " ", n["summary"])
                lines = rcformat.linebreak(textify_entities(summary), 75)
                for l in lines:
                    rctalk.message(l)
            if n.has_key("url"):
                rctalk.message("To learn more, visit " + n["url"])
            rctalk.message("")


rccommand.register(NewsCmd)

Exemple #7
0
            else:
                rctalk.warning("Server did not return a name.")

            if results.has_key("copyright"):
                rctalk.message("  " + results["copyright"])
            else:
                rctalk.warning("Daemon did not return copyright information.")

            # Exit normally if we could ping the server
            return

        # And exit abnormally if we couldn't.
        sys.exit(1)


rccommand.register(PingCmd)


class ShutdownCmd(rccommand.RCCommand):
    def name(self):
        return "shutdown"

    def description_short(self):
        return "Shut down the daemon"

    def category(self):
        return "system"

    # This API will never change, so setting this to local prevents checking
    # the protocol version.  We want to be able to shut down no matter what.
    def is_local(self):
Exemple #8
0
    def category(self):
        return "system"

    def arguments(self):
        return "<channel>"

    def execute(self, server, options_dict, non_option_args):

        if len(non_option_args) == 0:
            rctalk.error("No channel specified.")
            sys.exit(1)

        channel_name = non_option_args[0]
        channels = rcchannelutils.get_channels_by_name(server, channel_name)

        if not rcchannelutils.validate_channel_list(channel_name, channels):
            sys.exit(1)

        channel = channels[0]

        retval = server.rcd.packsys.unmount_directory(channel["id"])

        if retval:
            rctalk.message("Unmounted channel '%s'" % channel["name"])
        else:
            rctalk.error("Unmount of channel '%s' failed" % channel["name"])

rccommand.register(MountCmd)
rccommand.register(UnmountCmd)
Exemple #9
0
    def category(self):
        return "system"

    def arguments(self):
        return "<channel>"

    def execute(self, server, options_dict, non_option_args):

        if len(non_option_args) == 0:
            rctalk.error("No channel specified.")
            sys.exit(1)

        channel_name = non_option_args[0]
        channels = rcchannelutils.get_channels_by_name(server, channel_name)

        if not rcchannelutils.validate_channel_list(channel_name, channels):
            sys.exit(1)

        channel = channels[0]

        retval = server.rcd.packsys.unmount_directory(channel["id"])

        if retval:
            rctalk.message("Unmounted channel '%s'" % channel["name"])
        else:
            rctalk.error("Unmount of channel '%s' failed" % channel["name"])


rccommand.register(MountCmd)
rccommand.register(UnmountCmd)
Exemple #10
0
        for d in non_option_args:
            dep = rcpackageutils.parse_dep_str(server, d)

            dups = filter(lambda x, d=dep:x["name"] == d["name"], dlist)

            if dups:
                rctalk.warning("Duplicate entry found: " + dups[0]["name"])

            dlist.append(dep)

        install_deps, remove_deps, dep_info = \
                      resolve_dependencies(server, [], [], dlist)

        if not install_deps and not remove_deps:
            rctalk.message("Requirements are already met on the system.  No "
                           "packages need to be")
            rctalk.message("installed or removed.")
            sys.exit(0)

        self.transact(server, options_dict,
                      [], install_deps,
                      [], remove_deps)

rccommand.register(PackageInstallCmd)
rccommand.register(PackageRemoveCmd)
rccommand.register(PackageUpdateCmd)
rccommand.register(PackageVerifyCmd)
rccommand.register(PackageSolveCmd)
rccommand.register(PackageRollbackCmd)
Exemple #11
0
        rcformat.tabular(["#", "Pattern", "Channel", "Importance"], table)

        if not options_dict.has_key("no-confirmation"):
            rctalk.message("")
            if len(to_delete) == 1:
                msg = "this lock"
            else:
                msg = "these locks"
            confirm = rctalk.prompt("Delete %s? [y/N]" % msg)
            if not confirm or not string.lower(confirm[0]) == "y":
                rctalk.message("Cancelled.")
                sys.exit(0)

        failures = []
        for l, i in map(lambda x, y: (x, y), to_delete, indices):
            retval = server.rcd.packsys.remove_lock(l)
            if not retval:
                failures.append(i)

        if failures:
            rctalk.warning("Unable to remove lock%s %s",
                           (len(failures) > 1 and "s") or "",
                           string.join(map(str, failures), ", "))
            sys.exit(1)


rccommand.register(LockListCmd)
rccommand.register(LockAddCmd)
rccommand.register(LockDeleteCmd)
Exemple #12
0
                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)))

        if error_flag:
            sys.exit(1)


###
### Don't forget to register!
###

rccommand.register(PackagesCmd)
rccommand.register(PackageSearchCmd)
rccommand.register(PackageListUpdatesCmd)
rccommand.register(SummaryCmd)
rccommand.register(PackageInfoCmd)
rccommand.register(PackageInfoProvidesCmd)
rccommand.register(PackageInfoRequirementsCmd)
rccommand.register(PackageInfoChildrenCmd)
rccommand.register(PackageInfoConflictsCmd)
rccommand.register(PackageInfoObsoletesCmd)
rccommand.register(PackageDumpCmd)
rccommand.register(PackageDanglingRequiresCmd)
rccommand.register(PackageFileListCmd)
rccommand.register(PackageForFileCmd)
Exemple #13
0
    def execute(self, server, options_dict, non_option_args):

        ### For now, we just do something pretty mindless

        ### FIXME: the channel selection aren't supported yet

        news = server.rcd.news.get_all()

        if not news:
            rctalk.message("--- No news available ---")
            sys.exit(0)

        for n in news:
            if n.has_key("service_name"):
                rctalk.message("[%s]" % n["service_name"])
            if n.has_key("title"):
                rctalk.message(textify_entities(n["title"]))
            if n.has_key("time_str"):
                rctalk.message("(" + n["time_str"] + ")")
            if n.has_key("summary"):
                summary = re.sub("\s+", " ", n["summary"])
                lines = rcformat.linebreak(textify_entities(summary), 75)
                for l in lines:
                    rctalk.message(l)
            if n.has_key("url"):
                rctalk.message("To learn more, visit " + n["url"])
            rctalk.message("")


rccommand.register(NewsCmd)
Exemple #14
0
        
        if not non_option_args:
            if options_dict.has_key("no-descriptions"):
                f = lambda p:[p["name"], str(p["value"])]
            else:
                headers.append("Description")
                f = lambda p:[p["name"], str(p["value"]), p["description"]]

            pref_table = map(f, server.rcd.prefs.list_prefs())
        else:
            for a in non_option_args:
                try:
                    p = server.rcd.prefs.get_pref(a)
                except ximian_xmlrpclib.Fault, f:
                    if f.faultCode == rcfault.invalid_preference:
                        rctalk.warning("There is no preference named '" + a + "'")
                    else:
                        raise
                else:
                    pref_table.append([a, str(p)])

        pref_table.sort(lambda x,y:cmp(string.lower(x[0]),
                                       string.lower(y[0])))

        if pref_table:
            rcformat.tabular(headers, pref_table)

rccommand.register(PrefsListCmd)
rccommand.register(PrefsSetCmd)
            
Exemple #15
0
                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)))

        if error_flag:
            sys.exit(1)
        
###
### Don't forget to register!
###

rccommand.register(PackagesCmd)
rccommand.register(PackageSearchCmd)
rccommand.register(PackageListUpdatesCmd)
rccommand.register(SummaryCmd)
rccommand.register(PackageInfoCmd)
rccommand.register(PackageInfoProvidesCmd)
rccommand.register(PackageInfoRequirementsCmd)
rccommand.register(PackageInfoChildrenCmd)
rccommand.register(PackageInfoConflictsCmd)
rccommand.register(PackageInfoObsoletesCmd)
rccommand.register(PackageDumpCmd)
rccommand.register(PackageDanglingRequiresCmd)
rccommand.register(PackageFileListCmd)
rccommand.register(PackageForFileCmd)
Exemple #16
0
                rctalk.message("  " + results["name"])
            else:
                rctalk.warning("Server did not return a name.")

            if results.has_key("copyright"):
                rctalk.message("  " + results["copyright"])
            else:
                rctalk.warning("Daemon did not return copyright information.")

            # Exit normally if we could ping the server
            return

        # And exit abnormally if we couldn't.
        sys.exit(1)

rccommand.register(PingCmd)

class ShutdownCmd(rccommand.RCCommand):

    def name(self):
        return "shutdown"

    def description_short(self):
        return "Shut down the daemon"

    def category(self):
        return "system"

    # This API will never change, so setting this to local prevents checking
    # the protocol version.  We want to be able to shut down no matter what.
    def is_local(self):
Exemple #17
0
                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")

rccommand.register(ListChannelsCmd)
rccommand.register(SubscribeCmd)
rccommand.register(UnsubscribeCmd)
Exemple #18
0
            if db <= 0:
                rctalk.warning(
                    "Ignoring invalid argument to --days-back option.")
            else:
                days_back = db

        secs_back = int(days_back * 86400)  # 1 day = 86400 sec

        query.append(["cutoff_time", "<=", str(secs_back)])

        ## Pass our query to the server, and get a pile of log entries back.
        ## We need to sort them, since they aren't guaranteed to be in any
        ## particular order.

        entries = server.rcd.log.query_log(query)
        entries.sort(lambda x, y: cmp(x["timestamp"], y["timestamp"]))

        ## The way we display the data depends on how
        ## talkative we have been told to be.

        if rctalk.be_terse:
            log_entries_to_table(entries)
        elif rctalk.show_verbose:
            log_entries_list(entries)
        else:
            log_entries_to_quick_table(entries)


rccommand.register(LogQueryCmd)
Exemple #19
0
            if f.faultCode == rcfault.cant_activate \
                   or f.faultCode == rcfault.invalid_service:

                err_str = f.faultString
                success = 0
            else:
                raise
        else:
            success = 1

        if success:
            rctalk.message("System successfully activated")

            if not options_dict.has_key("no-refresh"):
                rcchannelutils.refresh_channels(server)

        else:
            if not err_str:
                err_str = "Invalid activation code or email address"

            rctalk.warning("System could not be activated: %s" % err_str)
            sys.exit(1)


rccommand.register(ServiceListCmd)
rccommand.register(ServiceAddCmd)
rccommand.register(ServiceDeleteCmd)
rccommand.register(ServiceMirrorsCmd)
rccommand.register(ServiceRefreshCmd)
rccommand.register(ServiceActivateCmd)
Exemple #20
0
    def description_short(self):
        return "List packages that require the item you specify"

    def query_fn(self, server):
        return server.rcd.packsys.what_requires
    

###
### "what-conflicts" command
###

class WhatConflictsCmd(WhateverCmd):

    def name(self):
        return "what-conflicts"

    def aliases(self):
        return ["wc"]

    def description_short(self):
        return "List packages that conflict with the item you specify"

    def query_fn(self, server):
        return server.rcd.packsys.what_conflicts
    

rccommand.register(WhatProvidesCmd)
rccommand.register(WhatRequiresCmd)
rccommand.register(WhatConflictsCmd)
Exemple #21
0
        # If we're getting all of the packages available to us, filter out
        # ones in the "hidden" channels, like the system packages channel.
        patches = rcpackageutils.filter_visible_channels(server, patches)

        for p in patches:
            row = rcformat.package_to_row(server, p, options_dict.has_key("no-abbrev"), keys)
            patch_table.append(row)

        if patch_table:
            rcformat.tabular(headers, patch_table)
        else:
            rctalk.message("--- No Patches found ---")


rccommand.register(ListYouPatchesCmd)


def find_latest_patch(server, patch, allow_unsub, quiet):
    plist = server.rcd.you.search([["name", "is", patch],
                                   ["installed", "is", "false"]])

    if not plist:
        if not quiet:
            if allow_unsub:
                rctalk.error("Unable to find patch '%s'" % patch)
            else:
                rctalk.error("Unable to find patch '%s' in any " \
                             "subscribed channel" % patch)
        return []
Exemple #22
0
        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
        else:
            success = 1

        if success:
            rctalk.message("System successfully activated")

            if not options_dict.has_key("no-refresh"):
                rcchannelutils.refresh_channels(server)
            
        else:
            if not err_str:
                err_str = "Invalid activation code or email address"
            
            rctalk.warning("System could not be activated: %s" % err_str)
            sys.exit(1)

rccommand.register(ServiceListCmd)
rccommand.register(ServiceAddCmd)
rccommand.register(ServiceDeleteCmd)
rccommand.register(ServiceMirrorsCmd)
rccommand.register(ServiceRefreshCmd)
rccommand.register(ServiceActivateCmd)
Exemple #23
0
        if set_privs:
            user = matching[0]
            current_privs = string.split(user[1], ", ")

            valid_privs = map(string.lower,
                              server.rcd.users.get_valid_privileges())
            new_privs = get_privileges(current_privs, valid_privs)
            new_privs_str = string.join(new_privs, ", ")
        else:
            new_privs_str = "-*-unchanged-*-"

        if not set_privs and not options_dict.has_key("change-password"):
            # Lame.  Fake a permission denied fault so the user gets the
            # stock "no permissions error"
            raise ximian_xmlrpclib.Fault(rcfault.permission_denied,
                                         "Permission denied")

        rctalk.message("")
        
        if server.rcd.users.update(username, new_password, new_privs_str):
            rctalk.message("Saved changes to user '%s'" % username)
        else:
            rctalk.warning("Couldn't save changes to user '%s'" % username)


rccommand.register(UserListCmd)
rccommand.register(UserAddCmd)
rccommand.register(UserDeleteCmd)
rccommand.register(UserEditCmd)