ソースを参照

Fixed a bug where the --serverurl option of supervisorctl would not
accept a URL with a "unix" scheme. (Jason Kirtland)

Mike Naberezny 15 年 前
コミット
5ee8831537

+ 3 - 0
CHANGES.txt

@@ -20,6 +20,9 @@ Next Release
   - Made a more friendly exception message when a FCGI socket cannot be
     created.  (Roger Hoover)
 
+  - Fixed a bug where the --serverurl option of supervisorctl would not
+    accept a URL with a "unix" scheme.  (Jason Kirtland)
+
 3.0a7 (2009-05-24)
  
   - We now bundle our own patched version of Medusa contributed by Jason

+ 2 - 0
src/supervisor/datatypes.py

@@ -371,6 +371,8 @@ def url(value):
     import urlparse
     scheme, netloc, path, params, query, fragment = urlparse.urlparse(value)
     if scheme and netloc:
+        return value     
+    if scheme == 'unix' and path.startswith('//') and len(path) > 2:
         return value
     raise ValueError("value %s is not a URL" % value)
 

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

@@ -152,6 +152,30 @@ class DatatypesTest(unittest.TestCase):
         self.assertRaises(ValueError, integer, 'abc')
         self.assertEqual(integer('1'), 1)
         self.assertEqual(integer(str(sys.maxint+1)), sys.maxint+1)
+
+    def test_url_accepts_urlparse_recognized_scheme_with_netloc(self):
+        good_url = 'http://localhost:9001'
+        self.assertEqual(datatypes.url(good_url), good_url)
+
+    def test_url_rejects_urlparse_recognized_scheme_but_no_netloc(self):
+        bad_url = 'http://'
+        self.assertRaises(ValueError, datatypes.url, bad_url)
+
+    def test_url_accepts_unix_scheme_with_path(self):
+        good_url = "unix://somepath"
+        self.assertEqual(good_url, datatypes.url(good_url))
+
+    def test_url_rejects_unix_scheme_with_no_slashes_or_path(self):
+        bad_url = "unix:"
+        self.assertRaises(ValueError, datatypes.url, bad_url)   
+
+    def test_url_rejects_unix_scheme_with_slashes_but_no_path(self):
+        bad_url = "unix://"
+        self.assertRaises(ValueError, datatypes.url, bad_url)   
+    
+    def test_url_rejects_urlparse_unrecognized_scheme_with_path(self):
+        bad_url = "bad://path"
+        self.assertRaises(ValueError, datatypes.url, bad_url)
  
 class InetStreamSocketConfigTests(unittest.TestCase):
     def _getTargetClass(self):

+ 8 - 1
src/supervisor/tests/test_options.py

@@ -141,7 +141,14 @@ class ClientOptionsTests(unittest.TestCase):
         self.assertEqual(options.username, 'chris')
         self.assertEqual(options.password, '123')
         self.assertEqual(options.history_file, history_file)
-                   
+
+    def test_options_unixsocket_cli(self):
+        from StringIO import StringIO
+        fp = StringIO('[supervisorctl]')
+        instance = self._makeOne()
+        instance.configfile = fp
+        instance.realize(args=['--serverurl', 'unix:///dev/null'])
+        self.assertEqual(instance.serverurl, 'unix:///dev/null')
 
 class ServerOptionsTests(unittest.TestCase):
     def _getTargetClass(self):