annotate roundup/instance.py @ 1162:86d41c31f9be

old habits...
author Richard Jones <richard@users.sourceforge.net>
date Wed, 18 Sep 2002 00:02:13 +0000
parents 30db4a11d700
children 8e318dfaf479
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
213
d45384bc6420 Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents: 204
diff changeset
1 #
d45384bc6420 Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents: 204
diff changeset
2 # Copyright (c) 2001 Bizar Software Pty Ltd (http://www.bizarsoftware.com.au/)
d45384bc6420 Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents: 204
diff changeset
3 # This module is free software, and you may redistribute it and/or modify
d45384bc6420 Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents: 204
diff changeset
4 # under the same terms as Python, so long as this copyright message and
d45384bc6420 Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents: 204
diff changeset
5 # disclaimer are retained in their original form.
d45384bc6420 Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents: 204
diff changeset
6 #
214
18134bffab37 stupid typo
Richard Jones <richard@users.sourceforge.net>
parents: 213
diff changeset
7 # IN NO EVENT SHALL BIZAR SOFTWARE PTY LTD BE LIABLE TO ANY PARTY FOR
213
d45384bc6420 Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents: 204
diff changeset
8 # DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING
d45384bc6420 Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents: 204
diff changeset
9 # OUT OF THE USE OF THIS CODE, EVEN IF THE AUTHOR HAS BEEN ADVISED OF THE
d45384bc6420 Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents: 204
diff changeset
10 # POSSIBILITY OF SUCH DAMAGE.
d45384bc6420 Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents: 204
diff changeset
11 #
d45384bc6420 Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents: 204
diff changeset
12 # BIZAR SOFTWARE PTY LTD SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
d45384bc6420 Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents: 204
diff changeset
13 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
d45384bc6420 Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents: 204
diff changeset
14 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS"
d45384bc6420 Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents: 204
diff changeset
15 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
d45384bc6420 Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents: 204
diff changeset
16 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
d45384bc6420 Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents: 204
diff changeset
17 #
1162
86d41c31f9be old habits...
Richard Jones <richard@users.sourceforge.net>
parents: 1158
diff changeset
18 # $Id: instance.py,v 1.8 2002-09-18 00:02:13 richard Exp $
204
c1461733cbf9 Instances are now opened by a special function...
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
19
406
bdc2ea127ae9 Added module docstrings to all modules.
Jürgen Hermann <jhermann@users.sourceforge.net>
parents: 380
diff changeset
20 __doc__ = '''
1158
30db4a11d700 sanity check instance attributes on open
Richard Jones <richard@users.sourceforge.net>
parents: 1090
diff changeset
21 Tracker handling (open tracker).
406
bdc2ea127ae9 Added module docstrings to all modules.
Jürgen Hermann <jhermann@users.sourceforge.net>
parents: 380
diff changeset
22
bdc2ea127ae9 Added module docstrings to all modules.
Jürgen Hermann <jhermann@users.sourceforge.net>
parents: 380
diff changeset
23 Currently this module provides one function: open. This function opens
1158
30db4a11d700 sanity check instance attributes on open
Richard Jones <richard@users.sourceforge.net>
parents: 1090
diff changeset
24 a tracker. Note that trackers used to be called instances.
204
c1461733cbf9 Instances are now opened by a special function...
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
25 '''
c1461733cbf9 Instances are now opened by a special function...
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
26
380
a1331423eb93 Fixed issues with nosy reaction and author copies.
Richard Jones <richard@users.sourceforge.net>
parents: 214
diff changeset
27 import imp, os
204
c1461733cbf9 Instances are now opened by a special function...
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
28
1162
86d41c31f9be old habits...
Richard Jones <richard@users.sourceforge.net>
parents: 1158
diff changeset
29 class TrackerError(Exception):
1158
30db4a11d700 sanity check instance attributes on open
Richard Jones <richard@users.sourceforge.net>
parents: 1090
diff changeset
30 pass
30db4a11d700 sanity check instance attributes on open
Richard Jones <richard@users.sourceforge.net>
parents: 1090
diff changeset
31
204
c1461733cbf9 Instances are now opened by a special function...
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
32 class Opener:
c1461733cbf9 Instances are now opened by a special function...
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
33 def __init__(self):
c1461733cbf9 Instances are now opened by a special function...
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
34 self.number = 0
1158
30db4a11d700 sanity check instance attributes on open
Richard Jones <richard@users.sourceforge.net>
parents: 1090
diff changeset
35 self.trackers = {}
204
c1461733cbf9 Instances are now opened by a special function...
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
36
1158
30db4a11d700 sanity check instance attributes on open
Richard Jones <richard@users.sourceforge.net>
parents: 1090
diff changeset
37 def open(self, tracker_home):
30db4a11d700 sanity check instance attributes on open
Richard Jones <richard@users.sourceforge.net>
parents: 1090
diff changeset
38 ''' Open the tracker.
380
a1331423eb93 Fixed issues with nosy reaction and author copies.
Richard Jones <richard@users.sourceforge.net>
parents: 214
diff changeset
39
1158
30db4a11d700 sanity check instance attributes on open
Richard Jones <richard@users.sourceforge.net>
parents: 1090
diff changeset
40 Raise ValueError if the tracker home doesn't exist.
380
a1331423eb93 Fixed issues with nosy reaction and author copies.
Richard Jones <richard@users.sourceforge.net>
parents: 214
diff changeset
41 '''
1158
30db4a11d700 sanity check instance attributes on open
Richard Jones <richard@users.sourceforge.net>
parents: 1090
diff changeset
42 if not os.path.exists(tracker_home):
30db4a11d700 sanity check instance attributes on open
Richard Jones <richard@users.sourceforge.net>
parents: 1090
diff changeset
43 raise ValueError, 'no such directory: "%s"'%tracker_home
30db4a11d700 sanity check instance attributes on open
Richard Jones <richard@users.sourceforge.net>
parents: 1090
diff changeset
44 if self.trackers.has_key(tracker_home):
30db4a11d700 sanity check instance attributes on open
Richard Jones <richard@users.sourceforge.net>
parents: 1090
diff changeset
45 return imp.load_package(self.trackers[tracker_home],
30db4a11d700 sanity check instance attributes on open
Richard Jones <richard@users.sourceforge.net>
parents: 1090
diff changeset
46 tracker_home)
204
c1461733cbf9 Instances are now opened by a special function...
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
47 self.number = self.number + 1
1158
30db4a11d700 sanity check instance attributes on open
Richard Jones <richard@users.sourceforge.net>
parents: 1090
diff changeset
48 modname = '_roundup_tracker_%s'%self.number
30db4a11d700 sanity check instance attributes on open
Richard Jones <richard@users.sourceforge.net>
parents: 1090
diff changeset
49 self.trackers[tracker_home] = modname
30db4a11d700 sanity check instance attributes on open
Richard Jones <richard@users.sourceforge.net>
parents: 1090
diff changeset
50
30db4a11d700 sanity check instance attributes on open
Richard Jones <richard@users.sourceforge.net>
parents: 1090
diff changeset
51 # load the tracker
30db4a11d700 sanity check instance attributes on open
Richard Jones <richard@users.sourceforge.net>
parents: 1090
diff changeset
52 tracker = imp.load_package(modname, tracker_home)
30db4a11d700 sanity check instance attributes on open
Richard Jones <richard@users.sourceforge.net>
parents: 1090
diff changeset
53
30db4a11d700 sanity check instance attributes on open
Richard Jones <richard@users.sourceforge.net>
parents: 1090
diff changeset
54 # ensure the tracker has all the required bits
30db4a11d700 sanity check instance attributes on open
Richard Jones <richard@users.sourceforge.net>
parents: 1090
diff changeset
55 for required in 'config open init Client MailGW'.split():
30db4a11d700 sanity check instance attributes on open
Richard Jones <richard@users.sourceforge.net>
parents: 1090
diff changeset
56 if not hasattr(tracker, required):
1162
86d41c31f9be old habits...
Richard Jones <richard@users.sourceforge.net>
parents: 1158
diff changeset
57 raise TrackerError, 'Required tracker attribute "%s" '\
1158
30db4a11d700 sanity check instance attributes on open
Richard Jones <richard@users.sourceforge.net>
parents: 1090
diff changeset
58 'missing'%required
30db4a11d700 sanity check instance attributes on open
Richard Jones <richard@users.sourceforge.net>
parents: 1090
diff changeset
59
30db4a11d700 sanity check instance attributes on open
Richard Jones <richard@users.sourceforge.net>
parents: 1090
diff changeset
60 return tracker
204
c1461733cbf9 Instances are now opened by a special function...
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
61
c1461733cbf9 Instances are now opened by a special function...
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
62 opener = Opener()
c1461733cbf9 Instances are now opened by a special function...
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
63 open = opener.open
c1461733cbf9 Instances are now opened by a special function...
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
64
c1461733cbf9 Instances are now opened by a special function...
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
65 del Opener
c1461733cbf9 Instances are now opened by a special function...
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
66 del opener
c1461733cbf9 Instances are now opened by a special function...
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
67
c1461733cbf9 Instances are now opened by a special function...
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
68
c1461733cbf9 Instances are now opened by a special function...
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
69 # vim: set filetype=python ts=4 sw=4 et si

Roundup Issue Tracker: http://roundup-tracker.org/