Bladeren bron

Display names consistently in the clear command. Refs #300

Mike Naberezny 11 jaren geleden
bovenliggende
commit
124e0e5cba
3 gewijzigde bestanden met toevoegingen van 17 en 9 verwijderingen
  1. 2 2
      CHANGES.txt
  2. 7 6
      supervisor/supervisorctl.py
  3. 8 1
      supervisor/tests/test_supervisorctl.py

+ 2 - 2
CHANGES.txt

@@ -1,8 +1,8 @@
 3.1a1 (Next Release)
 --------------------
 
-- The output of the ``start``, ``stop``, and ``restart`` commands in
-  ``supervisorctl`` has been changed to be consistent with the ``status``
+- The output of the ``start``, ``stop``, ``restart``, and ``clear`` commands
+  in ``supervisorctl`` has been changed to be consistent with the ``status``
   command.  Previously, the ``status`` command would show a process like
   ``foo:foo_01`` but starting that process would show ``foo_01: started``
   (note the group prefix ``foo:`` was missing).  Now, starting the process

+ 7 - 6
supervisor/supervisorctl.py

@@ -1035,7 +1035,7 @@ class DefaultControllerPlugin(ControllerPluginBase):
         self.ctl.output("update <gname> [...]\tUpdate specific groups")
 
     def _clearresult(self, result):
-        name = result['name']
+        name = make_namespec(result['group'], result['name'])
         code = result['status']
         template = '%s: ERROR (%s)'
         if code == xmlrpc.Faults.BAD_NAME:
@@ -1064,18 +1064,19 @@ class DefaultControllerPlugin(ControllerPluginBase):
             for result in results:
                 result = self._clearresult(result)
                 self.ctl.output(result)
-
         else:
-
             for name in names:
+                group_name, process_name = split_namespec(name)
                 try:
                     result = supervisor.clearProcessLogs(name)
                 except xmlrpclib.Fault, e:
-                    error = self._clearresult({'status':e.faultCode,
-                                               'name':name,
-                                               'description':e.faultString})
+                    error = self._clearresult({'status': e.faultCode,
+                                               'name': process_name,
+                                               'group': group_name,
+                                               'description': e.faultString})
                     self.ctl.output(error)
                 else:
+                    name = make_namespec(group_name, process_name)
                     self.ctl.output('%s: cleared' % name)
 
     def help_clear(self):

+ 8 - 1
supervisor/tests/test_supervisorctl.py

@@ -743,6 +743,13 @@ class TestDefaultControllerPlugin(unittest.TestCase):
         self.assertEqual(plugin.ctl.stdout.getvalue(),
                          'foo: cleared\n')
 
+    def test_clear_one_with_group_success(self):
+        plugin = self._makeOne()
+        result = plugin.do_clear('foo:foo')
+        self.assertEqual(result, None)
+        self.assertEqual(plugin.ctl.stdout.getvalue(),
+                         'foo: cleared\n')
+
     def test_clear_many(self):
         plugin = self._makeOne()
         result = plugin.do_clear('foo bar')
@@ -758,7 +765,7 @@ class TestDefaultControllerPlugin(unittest.TestCase):
         self.assertEqual(plugin.ctl.stdout.getvalue(),
                          'foo: cleared\n'
                          'foo2: cleared\n'
-                         'failed: ERROR (failed)\n')
+                         'failed_group:failed: ERROR (failed)\n')
 
     def test_open_fail(self):
         plugin = self._makeOne()