X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sfa%2Fplc%2Fapi.py;h=52f72ffa3732643bcd1eed159e348d5853fe3c34;hb=8c2ea05e14c82591f084951b64b938dab4ce4254;hp=cd6b2bde32dc089e7548e61e78f8f44259ee593a;hpb=127447d17ad02230d235ee2e3fddcfdc4311db23;p=sfa.git diff --git a/sfa/plc/api.py b/sfa/plc/api.py index cd6b2bde..52f72ffa 100644 --- a/sfa/plc/api.py +++ b/sfa/plc/api.py @@ -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