Bläddra i källkod

Remove datatypes.set_here()
This used to store the directory of the main config file and was
used to expand %(here)s. Now, %(here)s has changed to mean the
directory of the file containing it, so it will be different for
files included via an [include] section. Other code now sets
'here' and tests for all documented places %(here)s can be used
were added in 0eb3b885de30adbf2c4cb9bc46f399764e296ed0.

Mike Naberezny 9 år sedan
förälder
incheckning
04890d0858
3 ändrade filer med 2 tillägg och 27 borttagningar
  1. 2 10
      supervisor/datatypes.py
  2. 0 2
      supervisor/options.py
  3. 0 15
      supervisor/tests/test_datatypes.py

+ 2 - 10
supervisor/datatypes.py

@@ -10,12 +10,6 @@ from supervisor.compat import long
 from supervisor.loggers import getLevelNumByDescription
 from supervisor.medusa import text_socket
 
-here = None
-
-def set_here(v):
-    global here
-    here = v
-
 def process_or_group_name(name):
     """Ensures that a process or group name is not created with
        characters that break the eventlistener protocol"""
@@ -334,15 +328,13 @@ def octal_type(arg):
         raise ValueError('%s can not be converted to an octal type' % arg)
 
 def existing_directory(v):
-    nv = v % {'here':here}
-    nv = os.path.expanduser(nv)
+    nv = os.path.expanduser(v)
     if os.path.isdir(nv):
         return nv
     raise ValueError('%s is not an existing directory' % v)
 
 def existing_dirpath(v):
-    nv = v % {'here':here}
-    nv = os.path.expanduser(nv)
+    nv = os.path.expanduser(v)
     dir = os.path.dirname(nv)
     if not dir:
         # relative pathname with no directory component

+ 0 - 2
supervisor/options.py

@@ -48,7 +48,6 @@ from supervisor.datatypes import url
 from supervisor.datatypes import Automatic
 from supervisor.datatypes import auto_restart
 from supervisor.datatypes import profile_options
-from supervisor.datatypes import set_here
 
 from supervisor import loggers
 from supervisor import states
@@ -352,7 +351,6 @@ class Options:
         # Process config file
         if not hasattr(self.configfile, 'read'):
             self.here = os.path.abspath(os.path.dirname(self.configfile))
-            set_here(self.here)
         try:
             self.read_config(self.configfile)
         except ValueError as msg:

+ 0 - 15
supervisor/tests/test_datatypes.py

@@ -355,13 +355,6 @@ class ExistingDirectoryTests(unittest.TestCase):
             path = self._callFUT('~')
             self.assertEqual(home, path)
 
-    def test_expands_here(self):
-        datatypes.here = os.path.dirname(__file__)
-        try:
-            self.assertEqual(self._callFUT('%(here)s'), datatypes.here)
-        finally:
-            datatypes.here = None
-
 class ExistingDirpathTests(unittest.TestCase):
     def _callFUT(self, arg):
         return datatypes.existing_dirpath(arg)
@@ -399,14 +392,6 @@ class ExistingDirpathTests(unittest.TestCase):
             path = self._callFUT('~/foo')
             self.assertEqual(os.path.join(home, 'foo'), path)
 
-    def test_expands_here(self):
-        datatypes.here = os.path.dirname(__file__)
-        try:
-            expected = os.path.join(datatypes.here, 'foo')
-            self.assertEqual(self._callFUT('%(here)s/foo'), expected)
-        finally:
-            datatypes.here = None
-
 class LoggingLevelTests(unittest.TestCase):
     def _callFUT(self, arg):
         return datatypes.logging_level(arg)