From c2a7bd21cce6f2800e7684a8437de1814647c369 Mon Sep 17 00:00:00 2001 From: Faiyaz Ahmed Date: Thu, 18 Jun 2009 21:19:22 +0000 Subject: [PATCH 1/1] -k removes keys --- cmdline/getRecord.py | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/cmdline/getRecord.py b/cmdline/getRecord.py index 3e4c068c..e0487423 100755 --- a/cmdline/getRecord.py +++ b/cmdline/getRecord.py @@ -28,38 +28,42 @@ def create_parser(): parser.add_option("-d", "--debug", dest="DEBUG", action="store_true", default=False, help = "record file path") parser.add_option("-k", "--key", dest="withkey", action="store_true", - default=False, help = "print keys") + 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") return parser + def printRec(record, filters, options): line = "" if len(filters): for filter in filters: if options.DEBUG: print "Filtering on %s" %filter - if options.withkey: - line += "%s: " %filter - line += "%s\n" % \ - printVal(record.dict["record"].get(filter, None)) - print line + line += "%s: %s\n" % (filter, + printVal(record.dict["record"].get(filter, None))) + print line else: # print the wole thing for (key, value) in record.dict["record"].iteritems(): - if options.withkey: - line += "%s: " % key - line += "%s\n" % printVal(value) + 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 + # fix the iteratable values def printVal(value): line = "" if type(value) in (tuple, list): for i in value: line += "%s " % i - else: + elif value != None: line += value return line.rstrip("\n") + def main(): parser = create_parser(); (options, args) = parser.parse_args() -- 2.43.0