X-Git-Url: http://git.onelab.eu/?p=sfa.git;a=blobdiff_plain;f=clientbin%2FgetRecord.py;h=8af2bf63c1dffe6b34dcbe70aa9a1bae484e7596;hp=97d17942446d176590acd4631728374ef1aca458;hb=4a9e6751f9f396f463932133b9d62fc925a99ef6;hpb=648ac3fd865ea29425485f26eb0a7bf1a62281e0 diff --git a/clientbin/getRecord.py b/clientbin/getRecord.py index 97d17942..8af2bf63 100755 --- a/clientbin/getRecord.py +++ b/clientbin/getRecord.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python2 +#!/usr/bin/env python3 """ Filters/Prints record objects @@ -24,11 +24,11 @@ def create_parser(): description = """getRecord will parse a supplied (via stdin) record and print all values or key/values, and filter results based on a given key or set of keys.""" parser = OptionParser(usage=usage, description=description) parser.add_option("-d", "--debug", dest="DEBUG", action="store_true", - default=False, help="record file path") + default=False, help="record file path") parser.add_option("-k", "--key", dest="withkey", action="store_true", - default=False, help="print SSH keys and certificates") + default=False, help="print SSH keys and certificates") parser.add_option("-p", "--plinfo", dest="plinfo", action="store_true", - default=False, help="print PlanetLab specific internal fields") + default=False, help="print PlanetLab specific internal fields") return parser @@ -38,18 +38,18 @@ def printRec(record_dict, filters, options): if len(filters): for filter in filters: if options.DEBUG: - print "Filtering on %s" % filter + print("Filtering on %s" % filter) line += "%s: %s\n" % (filter, printVal(record_dict.get(filter, None))) - print line + print(line) else: # print the wole thing - for (key, value) in record_dict.iteritems(): + for (key, value) in record_dict.items(): if (not options.withkey and key in ('gid', 'keys')) or\ (not options.plinfo and key == 'pl_info'): continue line += "%s: %s\n" % (key, printVal(value)) - print line + print(line) # fix the iteratable values @@ -74,7 +74,7 @@ def main(): if options.DEBUG: pprint(record.toxml()) - print "#####################################################" + print("#####################################################") printRec(record_dict, args, options) @@ -82,7 +82,7 @@ if __name__ == '__main__': try: main() except ExpatError as e: - print "RecordError. Is your record valid XML?" - print e + print("RecordError. Is your record valid XML?") + print(e) except Exception as e: - print e + print(e)