##// END OF EJS Templates
Updates to config/application.
Brian Granger -
Show More
@@ -61,6 +61,10 b' This line is evaluated in Python, so simple expressions are allowed, e.g.'
61 61 #-----------------------------------------------------------------------------
62 62
63 63
64 class ApplicationError(Exception):
65 pass
66
67
64 68 class Application(SingletonConfigurable):
65 69 """A singleton application with full configuration support."""
66 70
@@ -111,7 +115,12 b' class Application(SingletonConfigurable):'
111 115 assert isinstance(value[0], (dict, Config)), "Bad flag: %r:%s"%(key,value)
112 116 assert isinstance(value[1], basestring), "Bad flag: %r:%s"%(key,value)
113 117 self.init_logging()
114
118
119 def _config_changed(self, name, old, new):
120 SingletonConfigurable._config_changed(self, name, old, new)
121 self.log.debug('Config changed:')
122 self.log.debug(repr(new))
123
115 124 def init_logging(self):
116 125 """Start logging for this application.
117 126
@@ -210,11 +219,11 b' class Application(SingletonConfigurable):'
210 219 if '-h' in argv or '--help' in argv:
211 220 self.print_description()
212 221 self.print_help()
213 sys.exit(1)
222 self.exit(1)
214 223
215 224 if '--version' in argv:
216 225 self.print_version()
217 sys.exit(1)
226 self.exit(1)
218 227
219 228 loader = KeyValueConfigLoader(argv=argv, aliases=self.aliases,
220 229 flags=self.flags)
@@ -223,8 +232,10 b' class Application(SingletonConfigurable):'
223 232
224 233 def load_config_file(self, filename, path=None):
225 234 """Load a .py based config file by filename and path."""
226 # TODO: this raises IOError if filename does not exist.
227 235 loader = PyFileConfigLoader(filename, path=path)
228 236 config = loader.load_config()
229 237 self.update_config(config)
230 238
239 def exit(self, exit_status=0):
240 self.log.debug("Exiting application: %s" % self.name)
241 sys.exit(exit_status)
General Comments 0
You need to be logged in to leave comments. Login now