X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sfa%2Fmanagers%2Fregistry_manager.py;h=78d933d7c1ac63903c4c189972515bbedf5d2582;hb=30d9951e075d93127c3909dcb41be09b420b3525;hp=1eafc10ffc0b07c3b0d8838bd910a341ebd5bf2c;hpb=4ef76bd85ea24906c4ebb580c896fe1084d6ba88;p=sfa.git diff --git a/sfa/managers/registry_manager.py b/sfa/managers/registry_manager.py index 1eafc10f..78d933d7 100644 --- a/sfa/managers/registry_manager.py +++ b/sfa/managers/registry_manager.py @@ -1,4 +1,5 @@ -import types +from __future__ import print_function + # for get_key_from_incoming_ip import tempfile import os @@ -161,7 +162,7 @@ class RegistryManager: def Resolve(self, api, xrns, type=None, details=False): dbsession = api.dbsession() - if not isinstance(xrns, types.ListType): + if not isinstance(xrns, list): # try to infer type if not set and we get a single input if not type: type = Xrn(xrns).get_type() @@ -385,7 +386,7 @@ class RegistryManager: pub_key=getattr(record,'reg-keys',None) if pub_key is not None: # use only first key in record - if pub_key and isinstance(pub_key, types.ListType): pub_key = pub_key[0] + if pub_key and isinstance(pub_key, list): pub_key = pub_key[0] pkey = convert_public_key(pub_key) email = getattr(record,'email',None) @@ -414,10 +415,12 @@ class RegistryManager: elif isinstance (record, RegUser): # create RegKey objects for incoming keys if hasattr(record,'reg-keys'): - keys=getattr(record,'reg-keys') + keys = getattr(record, 'reg-keys') # some people send the key as a string instead of a list of strings - if isinstance(keys,types.StringTypes): keys=[keys] - logger.debug ("creating {} keys for user {}".format(len(keys), record.hrn)) + # note for python2/3 : no need to consider unicode in a key + if isinstance(keys, str): + keys = [keys] + logger.debug("creating {} keys for user {}".format(len(keys), record.hrn)) record.reg_keys = [ RegKey (key) for key in keys ] # update testbed-specific data if needed @@ -458,7 +461,7 @@ class RegistryManager: if type == 'user': if getattr(new_record, 'keys', None): new_key = new_record.keys - if isinstance (new_key, types.ListType): + if isinstance (new_key, list): new_key = new_key[0] # take new_key into account @@ -503,7 +506,7 @@ class RegistryManager: # record.__dict__ as received by the driver seems to be off # anyway the driver should receive an object # (and then extract __dict__ itself if needed) - print "DO NOT REMOVE ME before driver.update, record={}".format(record) + print("DO NOT REMOVE ME before driver.update, record={}".format(record)) # as of June 2015: I suspect we could remove that print line above and replace it with # augment_with_sfa_builtins(record) # instead, that checks for these fields, like it is done above in List() @@ -623,7 +626,7 @@ class RegistryManager: for command in all_commands: (status, output) = commands.getstatusoutput(command) if status: - raise Exception, output + raise Exception(output) for filename in [key_filename, gid_filename]: os.unlink(filename)