X-Git-Url: http://git.onelab.eu/?p=nodemanager.git;a=blobdiff_plain;f=plcapi.py;h=a03e9e0cafda730a96001181d8ede841ed12e78d;hp=6ed3cac62c67489a904b491938f9ccc24598e4d5;hb=HEAD;hpb=6547f8a5147cf731bce4dff93d1c86bbfc6d363f diff --git a/plcapi.py b/plcapi.py index 6ed3cac..a03e9e0 100644 --- a/plcapi.py +++ b/plcapi.py @@ -1,6 +1,3 @@ -# $Id$ -# $URL$ - import safexmlrpc import hmac try: @@ -20,7 +17,7 @@ class PLCAPI: session => SessionAuth To authenticate using the Boot Manager authentication method, or - the new session-based method. + the new session-based method, respectively. """ def __init__(self, uri, cacert, auth, timeout = 90, **kwds): @@ -31,7 +28,7 @@ class PLCAPI: if isinstance(auth, (tuple, list)): (self.node_id, self.key) = auth self.session = None - elif isinstance(auth, (str, unicode)): + elif isinstance(auth, str): self.node_id = self.key = None self.session = auth else: @@ -41,7 +38,7 @@ class PLCAPI: def update_session(self, f="/usr/boot/plnode.txt"): - # try authenticatipopulate /etc.planetlab/session + # try authenticatipopulate /etc.planetlab/session def plnode(key): try: return [i[:-1].split('=') for i in open(f).readlines() if i.startswith(key)][0][1].strip('"') @@ -53,13 +50,13 @@ class PLCAPI: open("/etc/planetlab/session", 'w').write(plc.GetSession().strip()) self.session = open("/etc/planetlab/session").read().strip() - + def check_authentication(self): authstatus = False if self.key or self.session: - try: + try: authstatus = self.AuthCheck() - except: + except: logger.log_exc("plcapi: failed in plcapi.check_authentication") return authstatus @@ -88,10 +85,10 @@ class PLCAPI: # Yes, the comments in the old implementation are # misleading. Keys of dicts are not included in the # hash. - values += canonicalize(arg.values()) + values += canonicalize(list(arg.values())) else: # We use unicode() instead of str(). - values.append(unicode(arg)) + values.append(str(arg)) return values