Exemplo n.º 1
0
def report_item(remote, otype, item=None, name=None):
    if item is None:
        if otype == "setting":
            cur_settings = remote.get_settings()
            try:
                item = {'name': name, 'value': cur_settings[name]}
            except:
                print "Setting not found: %s" % name
                sys.exit(1)
        elif otype == "signature":
            items = remote.get_signatures()
            total_sigs = 0
            if "breeds" in items:
                print "Currently loaded signatures:"
                if name in items["breeds"]:
                    print "%s:" % name
                    oskeys = items["breeds"][name].keys()
                    oskeys.sort()
                    if len(oskeys) > 0:
                        total_sigs += len(oskeys)
                        for osversion in oskeys:
                            print "\t%s" % osversion
                    else:
                        print "\t(none)"
                    print "\nBreed '%s' has %d total signatures" % (name,
                                                                    total_sigs)
                else:
                    print "No breed named '%s' found" % name
                    sys.exit(1)
            else:
                print "No breeds found in the signature, a signature update is recommended"
                sys.exit(1)
            return
        else:
            item = remote.get_item(otype, name)
            if item == "~":
                print "No %s found: %s" % (otype, name)
                sys.exit(1)

    if otype == "distro":
        data = utils.printable_from_fields(item, item_distro.FIELDS)
    elif otype == "profile":
        data = utils.printable_from_fields(item, item_profile.FIELDS)
    elif otype == "system":
        data = utils.printable_from_fields(item, item_system.FIELDS)
    elif otype == "repo":
        data = utils.printable_from_fields(item, item_repo.FIELDS)
    elif otype == "image":
        data = utils.printable_from_fields(item, item_image.FIELDS)
    elif otype == "mgmtclass":
        data = utils.printable_from_fields(item, item_mgmtclass.FIELDS)
    elif otype == "package":
        data = utils.printable_from_fields(item, item_package.FIELDS)
    elif otype == "file":
        data = utils.printable_from_fields(item, item_file.FIELDS)
    elif otype == "setting":
        data = "%-40s: %s" % (item['name'], item['value'])
    print data
Exemplo n.º 2
0
def report_item(remote, otype, item=None, name=None):
    if item is None:
        if otype == "setting":
            cur_settings = remote.get_settings()
            try:
                item = {'name': name, 'value': cur_settings[name]}
            except:
                print "Setting not found: %s" % name
                sys.exit(1)
        elif otype == "signature":
            items = remote.get_signatures()
            total_sigs = 0
            if "breeds" in items:
                print "Currently loaded signatures:"
                if name in items["breeds"]:
                    print "%s:" % name
                    oskeys = items["breeds"][name].keys()
                    oskeys.sort()
                    if len(oskeys) > 0:
                        total_sigs += len(oskeys)
                        for osversion in oskeys:
                            print "\t%s" % osversion
                    else:
                        print "\t(none)"
                    print "\nBreed '%s' has %d total signatures" % (name, total_sigs)
                else:
                    print "No breed named '%s' found" % name
                    sys.exit(1)
            else:
                print "No breeds found in the signature, a signature update is recommended"
                sys.exit(1)
            return
        else:
            item = remote.get_item(otype, name)
            if item == "~":
                print "No %s found: %s" % (otype, name)
                sys.exit(1)

    if otype == "distro":
        data = utils.printable_from_fields(item, item_distro.FIELDS)
    elif otype == "profile":
        data = utils.printable_from_fields(item, item_profile.FIELDS)
    elif otype == "system":
        data = utils.printable_from_fields(item, item_system.FIELDS)
    elif otype == "repo":
        data = utils.printable_from_fields(item, item_repo.FIELDS)
    elif otype == "image":
        data = utils.printable_from_fields(item, item_image.FIELDS)
    elif otype == "mgmtclass":
        data = utils.printable_from_fields(item, item_mgmtclass.FIELDS)
    elif otype == "package":
        data = utils.printable_from_fields(item, item_package.FIELDS)
    elif otype == "file":
        data = utils.printable_from_fields(item, item_file.FIELDS)
    elif otype == "setting":
        data = "%-40s: %s" % (item['name'], item['value'])
    print data
Exemplo n.º 3
0
 def printable(self):
     return utils.printable_from_fields(self, self.get_fields())
Exemplo n.º 4
0
 def printable(self):
     return utils.printable_from_fields(self, self.get_fields())