Explorar o código

- Per-process exitcodes= configuration now will not accept exit
codes that are integers above 255 (supervisord will not start when
one of the exit codes is outside the range of 0 - 255).

Chris McDonough %!s(int64=17) %!d(string=hai) anos
pai
achega
129411d732
Modificáronse 3 ficheiros con 20 adicións e 1 borrados
  1. 4 0
      CHANGES.txt
  2. 5 1
      src/supervisor/datatypes.py
  3. 11 0
      src/supervisor/tests/test_datatypes.py

+ 4 - 0
CHANGES.txt

@@ -1,5 +1,9 @@
 Next Release
 
+  - Per-process exitcodes= configuration now will not accept exit
+    codes that are integers above 255 (supervisord will not start when
+    one of the exit codes is outside the range of 0 - 255).
+
   - Per-process 'directory' value can now contain expandable values
     like %(here)s. (See http://www.plope.com/software/collector/262).
 

+ 5 - 1
src/supervisor/datatypes.py

@@ -70,7 +70,11 @@ def list_of_ints(arg):
 
 def list_of_exitcodes(arg):
     try:
-        return list_of_ints(arg)
+        vals = list_of_ints(arg)
+        for val in vals:
+            if val > 255:
+                raise 'Invalid exit code "%s"' % val
+        return vals
     except:
         raise ValueError("not a valid list of exit codes: " + repr(arg))
 

+ 11 - 0
src/supervisor/tests/test_datatypes.py

@@ -204,6 +204,17 @@ class UnixStreamSocketConfigTests(unittest.TestCase):
         self.assertFalse(os.path.exists(tf_name))
         sock.close
 
+class TestTopLevelFunctions(unittest.TestCase):
+
+    def test_list_of_exitcodes(self):
+        from supervisor.datatypes import list_of_exitcodes
+        vals = list_of_exitcodes('1,2,3')
+        self.assertEqual(vals, [1,2,3])
+        vals = list_of_exitcodes('1')
+        self.assertEqual(vals, [1])
+        self.assertRaises(ValueError, list_of_exitcodes, 'a,b,c')
+        self.assertRaises(ValueError, list_of_exitcodes, '1024')
+
 def test_suite():
     return unittest.findTestCases(sys.modules[__name__])