瀏覽代碼

Supervisorctl now reports a better error message when the supervisor namespace is not registered. (Mike Naberezny)

Chris McDonough 18 年之前
父節點
當前提交
76b03e2b80
共有 3 個文件被更改,包括 34 次插入0 次删除
  1. 6 0
      CHANGES.txt
  2. 10 0
      src/supervisor/supervisorctl.py
  3. 18 0
      src/supervisor/tests/test_supervisorctl.py

+ 6 - 0
CHANGES.txt

@@ -1,3 +1,9 @@
+Next Release
+
+  - Supervisorctl now reports a better error message when the main
+    supervisor XML-RPC namespace is not registered.  Thanks to
+    Mike Orr for reporting this. (Mike Naberezny)
+
 3.0a2
 
   - Fixed the README.txt example for defining the supervisor RPC

+ 10 - 0
src/supervisor/supervisorctl.py

@@ -121,6 +121,16 @@ class Controller(cmd.Cmd):
                     'talk to a server with API version %s, but the '
                     'remote version is %s.' % (rpcinterface.API_VERSION, api))
                 return False
+        except xmlrpclib.Fault, e:
+            if e.faultCode == xmlrpc.Faults.UNKNOWN_METHOD:
+                self._output(
+                    'Sorry, supervisord responded but did not recognize '
+                    'the supervisor namespace commands that supervisorctl '
+                    'uses to control it.  Please check that the '
+                    '[rpcinterface:supervisor] section is enabled in the '
+                    'configuration file (see sample.conf).')
+                return False
+            raise 
         except socket.error, why:
             if why[0] == errno.ECONNREFUSED:
                 self._output('%s refused connection' % self.options.serverurl)

+ 18 - 0
src/supervisor/tests/test_supervisorctl.py

@@ -35,6 +35,24 @@ class ControllerTests(unittest.TestCase):
         'to talk to a server with API version 3.0, but the remote version is '
         '1.0.\n')
 
+    def test__upcheck_unknown_method(self):
+        options = DummyClientOptions()
+        from xmlrpclib import Fault
+        from supervisor.xmlrpc import Faults
+        def getVersion():
+            raise Fault(Faults.UNKNOWN_METHOD, 'duh')
+        options._server.supervisor.getVersion = getVersion
+        controller = self._makeOne(options)
+        controller.stdout = StringIO()
+        result = controller._upcheck()
+        self.assertEqual(result, False)
+        value = controller.stdout.getvalue()
+        self.assertEqual(value, 'Sorry, supervisord responded but did not '
+        'recognize the supervisor namespace commands that supervisorctl '
+        'uses to control it.  Please check that the '
+        '[rpcinterface:supervisor] section is enabled in the '
+        'configuration file (see sample.conf).\n')
+
     def test_onecmd(self):
         options = DummyClientOptions()
         controller = self._makeOne(options)