/[circus]/circus/circus/config.py
ViewVC logotype

Diff of /circus/circus/config.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.7 by tvon, Fri Nov 15 00:52:35 2002 UTC revision 1.8 by tvon, Fri Nov 15 04:13:24 2002 UTC
# Line 20  __author__ = "Thomas von Schwerdtner <tv Line 20  __author__ = "Thomas von Schwerdtner <tv
20  __date__ = "Wed Nov 11 2002"  __date__ = "Wed Nov 11 2002"
21  __version__ = "$Revision$"  __version__ = "$Revision$"
22    
23  import ConfigParser  import ConfigParser, sys, os
24    
25  class Config(ConfigParser.ConfigParser):  class Config(ConfigParser.ConfigParser):
26      """A ConfigParser module with our defaults auto-loaded      """A ConfigParser module with our defaults auto-loaded
# Line 31  class Config(ConfigParser.ConfigParser): Line 31  class Config(ConfigParser.ConfigParser):
31          }          }
32                    
33      user_config = None      user_config = None
34      defaults = {      circus_home = None
35          "modules_dir":  "/usr/share/circus/modules"      module_path = None
36              }      defaults = {"modules_dir" : "/usr/share/circus/modules"}
37    
38      def __init__(self):      def __init__(self):
39          ConfigParser.ConfigParser.__init__(self, self.conf_defaults)          ConfigParser.ConfigParser.__init__(self, self.conf_defaults)
40    
41    
42        def set_module_path(self, path):
43            
44            # no non-existant paths
45            # XXX: Should raise an exception here, returning -1 is for kids
46            if not os.path.exists(path):
47                return -1
48    
49            # Clean it up in case its relative from circus_home
50            path = os.path.abspath(path)
51    
52            for p in sys.path:
53                p = os.path.abspath(p)
54                if path in (p, p + os.sep):
55                    return 0
56            
57            sys.path.append(path)
58    
59            
60      def debug_print(self):      def debug_print(self):
61          self.read(self.user_config)          self.read(self.user_config)
62          for section in self.sections():          for section in self.sections():
63              print section              print section
64              for option in self.options(section):              for option in self.options(section):
65                  print " ", option, "=", self.get(section, option)                  print " ", option, "=", self.get(section, option)
66    
67    
68    
69    

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.8

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26