From: Tony Mack <tmack@cs.princeton.edu>
Date: Fri, 9 Jul 2010 20:18:44 +0000 (+0000)
Subject: attempt to use plc sshell before xmlrpc
X-Git-Tag: sfa-1.0-0~157
X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=d4d1f318bf057611704e85e9d7f62e6a96f89306;p=sfa.git

attempt to use plc sshell before xmlrpc
---

diff --git a/sfa/plc/api.py b/sfa/plc/api.py
index c0c0d13d..aac86eb9 100644
--- a/sfa/plc/api.py
+++ b/sfa/plc/api.py
@@ -58,11 +58,8 @@ except:
         def __repr__(self):
             return 'defaultdict(%s, %s)' % (self.default_factory,
                                             dict.__repr__(self))
-
-
 ## end of http://code.activestate.com/recipes/523034/ }}}
 
-
 def list_to_dict(recs, key):
     """
     convert a list of dictionaries into a dictionary keyed on the 
@@ -85,7 +82,6 @@ class SfaAPI(BaseAPI):
                          cert_file=cert_file, cache=cache)
  
         self.encoding = encoding
-
         from sfa.util.table import SfaTable
         self.SfaTable = SfaTable
         # Better just be documenting the API
@@ -115,12 +111,16 @@ class SfaAPI(BaseAPI):
         self.plauth = {'Username': self.config.SFA_PLC_USER,
                        'AuthMethod': 'password',
                        'AuthString': self.config.SFA_PLC_PASSWORD}
-
-
-        self.plshell_type = 'xmlrpc' 
-        # connect via xmlrpc
-        url = self.config.SFA_PLC_URL
-        shell = xmlrpclib.Server(url, verbose = 0, allow_none = True)
+        try:
+            sys.path.append(os.path.dirname(os.path.realpath("/usr/bin/plcsh")))
+            self.plshell_type = 'direct'
+            import PLC.Shell
+            shell = PLC.Shell.Shell(globals = globals())
+        except:
+            self.plshell_type = 'xmlrpc' 
+            url = self.config.SFA_PLC_URL
+            shell = xmlrpclib.Server(url, verbose = 0, allow_none = True)
+        
         return shell
 
     def getCredential(self):