فهرست منبع

Renamed `process_config_file()`

Renamed `process_config_file()` to `process_config()`.

The function does so much more than simply process the config file (such
as applying defaults). I also intend to factor out the code that does
not take care of parsing/reading the config file.

All tests pass on my local workstation.
Jens Rantil 13 سال پیش
والد
کامیت
54482b43ac
5فایلهای تغییر یافته به همراه16 افزوده شده و 13 حذف شده
  1. 8 5
      supervisor/options.py
  2. 1 1
      supervisor/rpcinterface.py
  3. 1 1
      supervisor/tests/base.py
  4. 4 4
      supervisor/tests/test_options.py
  5. 2 2
      supervisor/tests/test_rpcinterfaces.py

+ 8 - 5
supervisor/options.py

@@ -290,10 +290,13 @@ class Options:
             self.configfile = self.default_configfile()
 
         if self.configfile:
-            self.process_config_file()
+            self.process_config()
 
-    def process_config_file(self, do_usage=True):
-        """Process config file."""
+    def process_config(self, do_usage=True):
+        """Process configuration data structure.
+        
+        This includes reading config file if necessary, setting defaults etc.
+        """
         if not hasattr(self.configfile, 'read'):
             self.here = os.path.abspath(os.path.dirname(self.configfile))
             set_here(self.here)
@@ -483,8 +486,8 @@ class ServerOptions(Options):
 
         self.identifier = section.identifier
 
-    def process_config_file(self, do_usage=True):
-        Options.process_config_file(self, do_usage=do_usage)
+    def process_config(self, do_usage=True):
+        Options.process_config(self, do_usage=do_usage)
 
         new = self.configroot.supervisord.process_group_configs
         self.process_group_configs = new

+ 1 - 1
supervisor/rpcinterface.py

@@ -159,7 +159,7 @@ class SupervisorNamespaceRPCInterface:
         """
         self._update('reloadConfig')
         try:
-            self.supervisord.options.process_config_file(do_usage=False)
+            self.supervisord.options.process_config(do_usage=False)
         except ValueError, msg:
             raise RPCError(Faults.CANT_REREAD, msg)
             

+ 1 - 1
supervisor/tests/base.py

@@ -79,7 +79,7 @@ class DummyOptions:
         self.realizeargs = args
         self.realizekw = kw
 
-    def process_config_file(self, do_usage=True):
+    def process_config(self, do_usage=True):
         pass
 
     def cleanup_fds(self):

+ 4 - 4
supervisor/tests/test_options.py

@@ -80,12 +80,12 @@ class OptionTests(unittest.TestCase):
         options.realize([])
         self.assertEquals(options.other, 41)
         options.master['other'] = 42
-        options.process_config_file()
+        options.process_config()
         self.assertEquals(options.other, 42)
 
     def test_config_reload_do_usage_false(self):
         options = self._makeOptions(read_error='error')
-        self.assertRaises(ValueError, options.process_config_file,
+        self.assertRaises(ValueError, options.process_config,
                           False)
 
     def test_config_reload_do_usage_true(self):
@@ -98,7 +98,7 @@ class OptionTests(unittest.TestCase):
         options.exit = exit
         options.configroot.anoption = 1
         options.configroot.other = 1
-        options.process_config_file(True)
+        options.process_config(True)
         self.assertEqual(L, [2])
 
     def test__set(self):
@@ -491,7 +491,7 @@ class ServerOptionsTests(unittest.TestCase):
         programs = three
         """)
         instance.configfile = StringIO(text)
-        instance.process_config_file()
+        instance.process_config()
 
         section = instance.configroot.supervisord
 

+ 2 - 2
supervisor/tests/test_rpcinterfaces.py

@@ -232,12 +232,12 @@ class SupervisorNamespaceXMLRPCInterfaceTests(TestBase):
         value = interface.reloadConfig()
         self.assertEqual(value, [[['added'], ['changed'], ['dropped']]])
 
-    def test_reloadConfig_process_config_file_raises_ValueError(self):
+    def test_reloadConfig_process_config_raises_ValueError(self):
         from supervisor import xmlrpc
         options = DummyOptions()
         def raise_exc(*arg, **kw):
             raise ValueError('foo')
-        options.process_config_file = raise_exc
+        options.process_config = raise_exc
         supervisord = DummySupervisor(options)
         interface = self._makeOne(supervisord)
         self._assertRPCError(xmlrpc.Faults.CANT_REREAD, interface.reloadConfig)