manually complete previous move
[sfa.git] / sfa / client / sfi.py
index 1639871..282c473 100644 (file)
@@ -284,7 +284,8 @@ class Sfi:
         self.logger.enable_console()
         ### various auxiliary material that we keep at hand 
         self.command=None
-        self.config=None
+        # need to call this other than just 'config' as we have a command/method with that name
+        self.config_instance=None
         self.config_file=None
         self.client_bootstrap=None
 
@@ -298,7 +299,7 @@ class Sfi:
             print line
         else:
             print line
-            self.create_parser().print_help()
+            self.create_global_parser().print_help()
         # preserve order from the code
         for command in commands_list:
             (doc, args_string, example) = commands_dict[command]
@@ -322,6 +323,48 @@ class Sfi:
             print "\n==================== %s example(s)"%self.command
             print example
 
+    def create_global_parser(self):
+        # Generate command line parser
+        parser = OptionParser(add_help_option=False,
+                              usage="sfi [sfi_options] command [cmd_options] [cmd_args]",
+                              description="Commands: %s"%(" ".join(commands_list)))
+        parser.add_option("-r", "--registry", dest="registry",
+                         help="root registry", metavar="URL", default=None)
+        parser.add_option("-s", "--sliceapi", dest="sm", default=None, metavar="URL",
+                         help="slice API - in general a SM URL, but can be used to talk to an aggregate")
+        parser.add_option("-R", "--raw", dest="raw", default=None,
+                          help="Save raw, unparsed server response to a file")
+        parser.add_option("", "--rawformat", dest="rawformat", type="choice",
+                          help="raw file format ([text]|pickled|json)", default="text",
+                          choices=("text","pickled","json"))
+        parser.add_option("", "--rawbanner", dest="rawbanner", default=None,
+                          help="text string to write before and after raw output")
+        parser.add_option("-d", "--dir", dest="sfi_dir",
+                         help="config & working directory - default is %default",
+                         metavar="PATH", default=Sfi.default_sfi_dir())
+        parser.add_option("-u", "--user", dest="user",
+                         help="user name", metavar="HRN", default=None)
+        parser.add_option("-a", "--auth", dest="auth",
+                         help="authority name", metavar="HRN", default=None)
+        parser.add_option("-v", "--verbose", action="count", dest="verbose", default=0,
+                         help="verbose mode - cumulative")
+        parser.add_option("-D", "--debug",
+                          action="store_true", dest="debug", default=False,
+                          help="Debug (xml-rpc) protocol messages")
+        # would it make sense to use ~/.ssh/id_rsa as a default here ?
+        parser.add_option("-k", "--private-key",
+                         action="store", dest="user_private_key", default=None,
+                         help="point to the private key file to use if not yet installed in sfi_dir")
+        parser.add_option("-t", "--timeout", dest="timeout", default=None,
+                         help="Amout of time to wait before timing out the request")
+        parser.add_option("-h", "--help", 
+                         action="store_true", dest="help", default=False,
+                         help="one page summary on commands & exit")
+        parser.disable_interspersed_args()
+
+        return parser
+        
+
     def create_command_parser(self, command):
         if command not in commands_dict:
             msg="Invalid command\n"
@@ -441,49 +484,6 @@ use this if you mean an authority instead""")
         return parser
 
         
-    def create_parser(self):
-
-        # Generate command line parser
-        parser = OptionParser(add_help_option=False,
-                              usage="sfi [sfi_options] command [cmd_options] [cmd_args]",
-                              description="Commands: %s"%(" ".join(commands_list)))
-        parser.add_option("-r", "--registry", dest="registry",
-                         help="root registry", metavar="URL", default=None)
-        parser.add_option("-s", "--sliceapi", dest="sm", default=None, metavar="URL",
-                         help="slice API - in general a SM URL, but can be used to talk to an aggregate")
-        parser.add_option("-R", "--raw", dest="raw", default=None,
-                          help="Save raw, unparsed server response to a file")
-        parser.add_option("", "--rawformat", dest="rawformat", type="choice",
-                          help="raw file format ([text]|pickled|json)", default="text",
-                          choices=("text","pickled","json"))
-        parser.add_option("", "--rawbanner", dest="rawbanner", default=None,
-                          help="text string to write before and after raw output")
-        parser.add_option("-d", "--dir", dest="sfi_dir",
-                         help="config & working directory - default is %default",
-                         metavar="PATH", default=Sfi.default_sfi_dir())
-        parser.add_option("-u", "--user", dest="user",
-                         help="user name", metavar="HRN", default=None)
-        parser.add_option("-a", "--auth", dest="auth",
-                         help="authority name", metavar="HRN", default=None)
-        parser.add_option("-v", "--verbose", action="count", dest="verbose", default=0,
-                         help="verbose mode - cumulative")
-        parser.add_option("-D", "--debug",
-                          action="store_true", dest="debug", default=False,
-                          help="Debug (xml-rpc) protocol messages")
-        # would it make sense to use ~/.ssh/id_rsa as a default here ?
-        parser.add_option("-k", "--private-key",
-                         action="store", dest="user_private_key", default=None,
-                         help="point to the private key file to use if not yet installed in sfi_dir")
-        parser.add_option("-t", "--timeout", dest="timeout", default=None,
-                         help="Amout of time to wait before timing out the request")
-        parser.add_option("-h", "--help", 
-                         action="store_true", dest="help", default=False,
-                         help="one page summary on commands & exit")
-        parser.disable_interspersed_args()
-
-        return parser
-        
-
     #
     # Main: parse arguments and dispatch to command
     #
@@ -495,7 +495,7 @@ use this if you mean an authority instead""")
         return method(command_options, command_args)
 
     def main(self):
-        self.sfi_parser = self.create_parser()
+        self.sfi_parser = self.create_global_parser()
         (options, args) = self.sfi_parser.parse_args()
         if options.help: 
             self.print_commands_help(options)
@@ -573,7 +573,7 @@ use this if you mean an authority instead""")
                 self.logger.log_exc("Could not read config file %s"%config_file)
             sys.exit(1)
      
-        self.config=config
+        self.config_instance=config
         errors = 0
         # Set SliceMgr URL
         if (self.options.sm is not None):
@@ -1500,7 +1500,7 @@ $ sfi m
         myslice_keys=['backend', 'delegate', 'platform', 'username']
         for key in myslice_keys:
             full_key="MYSLICE_" + key.upper()
-            value=getattr(self.config,full_key,None)
+            value=getattr(self.config_instance,full_key,None)
             if value:   myslice_dict[key]=value
             else:       print "Unsufficient config, missing key %s in [myslice] section of sfi_config"%key
         if len(myslice_dict) != len(myslice_keys):