use hashlib and fallback to sha (for python 2.4)
[nodemanager.git] / plcapi.py
index 2ef5dc1..6ed3cac 100644 (file)
--- a/plcapi.py
+++ b/plcapi.py
@@ -1,7 +1,12 @@
 # $Id$
+# $URL$
 
 import safexmlrpc
-import hmac, sha
+import hmac
+try:
+    from hashlib import sha1 as sha
+except ImportError:
+    import sha
 import logger
 
 class PLCAPI:
@@ -50,8 +55,13 @@ class PLCAPI:
 
         
     def check_authentication(self):
-        # just a simple call to check authentication
-        return self.AuthCheck(self)
+        authstatus = False
+        if self.key or self.session:
+            try: 
+                authstatus = self.AuthCheck()
+            except: 
+                logger.log_exc("plcapi: failed in plcapi.check_authentication")
+        return authstatus
 
 
     def add_auth(self, function):