reverting last commit (we can attempt to import plcapi source again. The problem...
authorTony Mack <tmack@cs.princeton.edu>
Fri, 5 Mar 2010 20:17:31 +0000 (20:17 +0000)
committerTony Mack <tmack@cs.princeton.edu>
Fri, 5 Mar 2010 20:17:31 +0000 (20:17 +0000)
sfa/plc/api.py

index cd6b2bd..52f72ff 100644 (file)
@@ -69,13 +69,22 @@ class SfaAPI(BaseAPI):
         self.plauth = {'Username': self.config.SFA_PLC_USER,
                        'AuthMethod': 'password',
                        'AuthString': self.config.SFA_PLC_PASSWORD}
-        # connect via xmlrpc
-        self.plshell_type = 'xmlrpc' 
-        url = self.config.SFA_PLC_URL
-        shell = xmlrpclib.Server(url, verbose = 0, allow_none = True)
-        shell.AuthCheck(self.plauth)
-        return shell
-    
+
+        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())
+            shell.AuthCheck(self.plauth)
+            return shell
+        except ImportError:
+            self.plshell_type = 'xmlrpc' 
+            # connect via xmlrpc
+            url = self.config.SFA_PLC_URL
+            shell = xmlrpclib.Server(url, verbose = 0, allow_none = True)
+            shell.AuthCheck(self.plauth)
+            return shell
+
     def getPLCShellVersion(self):
         # We need to figure out what version of PLCAPI we are talking to.
         # Some calls we need to make later will be different depending on