コード例 #1
0
def add_channel(channels, credentials):
    need_channel(channels)
    result = subscribeChannels(channels, credentials.user, credentials.password)
    if result == 0:
        info(_("Channel(s): %s successfully added") % ', '.join(channels))
    else:
        systemExit(result, _("Error during adding channel(s) %s") % ', '.join(channels))
コード例 #2
0
def main():
    if OPTIONS.add:
        subscribeChannels(OPTIONS.channel, OPTIONS.user, OPTIONS.password)
        if OPTIONS.verbose:
            print "Channel(s): %s successfully added" % ', '.join(OPTIONS.channel)
    elif OPTIONS.remove:
        unsubscribeChannels(OPTIONS.channel, OPTIONS.user, OPTIONS.password)
        if OPTIONS.verbose:
            print "Channel(s): %s successfully removed" % ', '.join(OPTIONS.channel)
    elif OPTIONS.list:
        try:
            channels = map(lambda x: x['label'], getChannels().channels())
        except up2dateErrors.NoChannelsError:
            systemExit(1, 'This system is not associated with any channel.')
        channels.sort()
        print '\n'.join(channels)
    else:
        s = rhnserver.RhnServer()
        print s.up2date.listall(up2dateAuth.getSystemId())
        systemExit(3, "ERROR: you may want to specify --add, --remove or --list")
コード例 #3
0
def main():
    if OPTIONS.add:
        need_channel(OPTIONS.channel)
        result = subscribeChannels(OPTIONS.channel, OPTIONS.user, OPTIONS.password)
        if OPTIONS.verbose:
            if result == 0:
                print _("Channel(s): %s successfully added") % ", ".join(OPTIONS.channel)
            else:
                sys.stderr.write(
                    rhncli.utf8_encode(_("Error during adding channel(s) %s") % ", ".join(OPTIONS.channel))
                )
        if result != 0:
            sys.exit(result)
    elif OPTIONS.remove:
        need_channel(OPTIONS.channel)
        result = unsubscribeChannels(OPTIONS.channel, OPTIONS.user, OPTIONS.password)
        if OPTIONS.verbose:
            if result == 0:
                print _("Channel(s): %s successfully removed") % ", ".join(OPTIONS.channel)
            else:
                sys.stderr.write(
                    rhncli.utf8_encode(_("Error during removal of channel(s) %s") % ", ".join(OPTIONS.channel))
                )
        if result != 0:
            sys.exit(result)
    elif OPTIONS.list:
        try:
            channels = map(lambda x: x["label"], getChannels().channels())
        except up2dateErrors.NoChannelsError:
            systemExit(1, _("This system is not associated with any channel."))
        except up2dateErrors.NoSystemIdError:
            systemExit(1, _("Unable to locate SystemId file. Is this system registered?"))
        channels.sort()
        print "\n".join(channels)
    elif OPTIONS.base:
        try:
            for channel in getChannels().channels():
                # Base channel has no parent
                if not channel["parent_channel"]:
                    print channel["label"]
        except up2dateErrors.NoChannelsError:
            systemExit(1, "This system is not associated with any channel.")
        except up2dateErrors.NoSystemIdError:
            systemExit(1, "Unable to locate SystemId file. Is this system registered?")

    elif OPTIONS.available_channels:
        channels = get_available_channels(OPTIONS.user, OPTIONS.password)
        channels.sort()
        print "\n".join(channels)
    else:
        systemExit(3, _("ERROR: you may want to specify --add, --remove or --list"))
コード例 #4
0
def main():
    if OPTIONS.add:
        need_channel(OPTIONS.channel)
        result = subscribeChannels(OPTIONS.channel, OPTIONS.user,
                                   OPTIONS.password)
        if OPTIONS.verbose:
            if result == 0:
                print _("Channel(s): %s successfully added") % ', '.join(
                    OPTIONS.channel)
            else:
                sys.stderr.write(
                    rhncli.utf8_encode(
                        _("Error during adding channel(s) %s") %
                        ', '.join(OPTIONS.channel)))
        if result != 0:
            sys.exit(result)
    elif OPTIONS.remove:
        need_channel(OPTIONS.channel)
        result = unsubscribeChannels(OPTIONS.channel, OPTIONS.user,
                                     OPTIONS.password)
        if OPTIONS.verbose:
            if result == 0:
                print _("Channel(s): %s successfully removed") % ', '.join(
                    OPTIONS.channel)
            else:
                sys.stderr.write(
                    rhncli.utf8_encode(
                        _("Error during removal of channel(s) %s") %
                        ', '.join(OPTIONS.channel)))
        if result != 0:
            sys.exit(result)
    elif OPTIONS.list:
        try:
            channels = map(lambda x: x['label'], getChannels().channels())
        except up2dateErrors.NoChannelsError:
            systemExit(1, _('This system is not associated with any channel.'))
        except up2dateErrors.NoSystemIdError:
            systemExit(
                1,
                _('Unable to locate SystemId file. Is this system registered?')
            )
        channels.sort()
        print '\n'.join(channels)
    elif OPTIONS.available_channels:
        channels = get_available_channels(OPTIONS.user, OPTIONS.password)
        channels.sort()
        print '\n'.join(channels)
    else:
        systemExit(
            3, _("ERROR: you may want to specify --add, --remove or --list"))