- added logging variable 'object_type'
[plcapi.git] / PLC / Shell.py
index e0d7fbd..7ab27c4 100644 (file)
@@ -5,7 +5,7 @@
 # Mark Huang <mlhuang@cs.princeton.edu>
 # Copyright (C) 2005 The Trustees of Princeton University
 #
-# $Id: Shell.py,v 1.18 2006/12/15 18:36:16 mlhuang Exp $
+# $Id: Shell.py,v 1.2 2007/01/10 21:04:40 mlhuang Exp $
 #
 
 import pydoc
@@ -80,20 +80,20 @@ class Shell:
             else:
                 self.api = PLCAPI(config)
             self.config = self.api.config
+            self.url = None
             self.server = None
         except Exception, err:
             # Try connecting to the API server via XML-RPC
             self.api = PLCAPI(None)
 
-            if config is None:
-                self.config = Config()
-            else:
-                try:
+            try:
+                if config is None:
+                    self.config = Config()
+                else:
                     self.config = Config(config)
-                except Exception, err:
-                    # Try to continue if no configuration file is available
-                    self.config = None
-                    pass
+            except Exception, err:
+                # Try to continue if no configuration file is available
+                self.config = None
 
             if url is None:
                 if self.config is None:
@@ -106,7 +106,11 @@ class Shell:
             if cacert is None and self.config is not None:
                 cacert = self.config.PLC_API_CA_SSL_CRT
 
-            self.server = xmlrpclib.ServerProxy(url, PyCurlTransport(url, cacert), allow_none = 1)
+            self.url = url
+            if cacert is not None:
+                self.server = xmlrpclib.ServerProxy(url, PyCurlTransport(url, cacert), allow_none = 1)
+            else:
+                self.server = xmlrpclib.ServerProxy(url, allow_none = 1)
 
         # Set up authentication structure