Mercurial > p > roundup > code
comparison roundup/instance.py @ 2621:d344419d599d
use new style config;
drop logging configuration logging as the config does this itself;
fix vim modeline.
| author | Alexander Smishlajev <a1s@users.sourceforge.net> |
|---|---|
| date | Sun, 25 Jul 2004 13:14:57 +0000 |
| parents | eeadb59213d8 |
| children | a9e1fff1e793 |
comparison
equal
deleted
inserted
replaced
| 2620:92c820cfcc4a | 2621:d344419d599d |
|---|---|
| 12 # BIZAR SOFTWARE PTY LTD SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, | 12 # BIZAR SOFTWARE PTY LTD SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, |
| 13 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | 13 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
| 14 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" | 14 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" |
| 15 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, | 15 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, |
| 16 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. | 16 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. |
| 17 # | 17 # |
| 18 # $Id: instance.py,v 1.15 2004-07-19 01:49:26 richard Exp $ | 18 # $Id: instance.py,v 1.16 2004-07-25 13:14:57 a1s Exp $ |
| 19 | 19 |
| 20 '''Tracker handling (open tracker). | 20 '''Tracker handling (open tracker). |
| 21 | 21 |
| 22 Backwards compatibility for the old-style "imported" trackers. | 22 Backwards compatibility for the old-style "imported" trackers. |
| 23 ''' | 23 ''' |
| 24 __docformat__ = 'restructuredtext' | 24 __docformat__ = 'restructuredtext' |
| 25 | 25 |
| 26 import os | 26 import os |
| 27 from roundup import rlog | 27 from roundup import configuration, rlog |
| 28 | 28 |
| 29 class Vars: | 29 class Vars: |
| 30 ''' I'm just a container ''' | 30 ''' I'm just a container ''' |
| 31 | 31 |
| 32 class Tracker: | 32 class Tracker: |
| 85 | 85 |
| 86 # load the tracker | 86 # load the tracker |
| 87 tracker = imp.load_package(modname, tracker_home) | 87 tracker = imp.load_package(modname, tracker_home) |
| 88 | 88 |
| 89 # ensure the tracker has all the required bits | 89 # ensure the tracker has all the required bits |
| 90 for required in 'config open init Client MailGW'.split(): | 90 for required in 'open init Client MailGW'.split(): |
| 91 if not hasattr(tracker, required): | 91 if not hasattr(tracker, required): |
| 92 raise TrackerError, \ | 92 raise TrackerError, \ |
| 93 'Required tracker attribute "%s" missing'%required | 93 'Required tracker attribute "%s" missing'%required |
| 94 | 94 |
| 95 # init the logging | 95 # load and apply the config |
| 96 config = tracker.config | 96 tracker.config = configuration.Config(tracker_home) |
| 97 if hasattr(config, 'LOGGING_CONFIG'): | 97 # FIXME! dbinit does "import config". |
| 98 try: | 98 # What would be the upgrade plan for existing trackers? |
| 99 import logging | 99 tracker.dbinit.config = tracker.config |
| 100 config.logging = logging | |
| 101 except ImportError, msg: | |
| 102 raise TrackerError, 'Python logging module unavailable: %s'%msg | |
| 103 config.logging.fileConfig(config.LOGGING_CONFIG) | |
| 104 else: | |
| 105 config.logging = rlog.BasicLogging() | |
| 106 if hasattr(config, 'LOGGING_FILENAME'): | |
| 107 config.logging.setFile(config.LOGGING_FILENAME) | |
| 108 if hasattr(config, 'LOGGING_LEVEL'): | |
| 109 config.logging.setLevel(config.LOGGING_LEVEL) | |
| 110 else: | |
| 111 config.logging.setLevel('ERROR') | |
| 112 | 100 |
| 113 return tracker | 101 return tracker |
| 114 | 102 |
| 115 OldStyleTrackers = OldStyleTrackers() | 103 OldStyleTrackers = OldStyleTrackers() |
| 116 def open(tracker_home): | 104 def open(tracker_home): |
| 118 # user should upgrade... | 106 # user should upgrade... |
| 119 return OldStyleTrackers.open(tracker_home) | 107 return OldStyleTrackers.open(tracker_home) |
| 120 | 108 |
| 121 return Tracker(tracker_home) | 109 return Tracker(tracker_home) |
| 122 | 110 |
| 123 # vim: set filetype=python ts=4 sw=4 et si | 111 # vim: set filetype=python sts=4 sw=4 et si : |
