Mercurial > p > roundup > code
annotate roundup-admin @ 301:7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Also, made the thing into a class to reduce parameter passing.
Nuked the leading whitespace from the help __doc__ displays too.
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Thu, 18 Oct 2001 02:16:42 +0000 |
| parents | fd9835c1e58d |
| children | d1fb3fcdb11b |
| rev | line source |
|---|---|
|
301
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
1 #! /usr/bin/env python |
|
213
d45384bc6420
Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents:
204
diff
changeset
|
2 # |
|
d45384bc6420
Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents:
204
diff
changeset
|
3 # 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
|
4 # 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
|
5 # 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
|
6 # 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
|
7 # |
| 214 | 8 # 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
|
9 # 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
|
10 # 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
|
11 # POSSIBILITY OF SUCH DAMAGE. |
|
d45384bc6420
Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents:
204
diff
changeset
|
12 # |
|
d45384bc6420
Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents:
204
diff
changeset
|
13 # 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
|
14 # 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
|
15 # 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
|
16 # 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
|
17 # 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
|
18 # |
|
301
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
19 # $Id: roundup-admin,v 1.34 2001-10-18 02:16:42 richard Exp $ |
|
27
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
20 |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
21 import sys |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
22 if int(sys.version[0]) < 2: |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
23 print 'Roundup requires python 2.0 or later.' |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
24 sys.exit(1) |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
25 |
|
204
c1461733cbf9
Instances are now opened by a special function...
Richard Jones <richard@users.sourceforge.net>
parents:
193
diff
changeset
|
26 import string, os, getpass, getopt, re |
|
278
a5dabf2430c5
Added database importing and exporting through CSV files.
Richard Jones <richard@users.sourceforge.net>
parents:
274
diff
changeset
|
27 try: |
|
a5dabf2430c5
Added database importing and exporting through CSV files.
Richard Jones <richard@users.sourceforge.net>
parents:
274
diff
changeset
|
28 import csv |
|
a5dabf2430c5
Added database importing and exporting through CSV files.
Richard Jones <richard@users.sourceforge.net>
parents:
274
diff
changeset
|
29 except ImportError: |
|
a5dabf2430c5
Added database importing and exporting through CSV files.
Richard Jones <richard@users.sourceforge.net>
parents:
274
diff
changeset
|
30 csv = None |
|
299
fd9835c1e58d
Did a fair bit of work on the admin tool.
Richard Jones <richard@users.sourceforge.net>
parents:
298
diff
changeset
|
31 from roundup import date, hyperdb, roundupdb, init, password |
|
204
c1461733cbf9
Instances are now opened by a special function...
Richard Jones <richard@users.sourceforge.net>
parents:
193
diff
changeset
|
32 import roundup.instance |
|
27
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
33 |
|
301
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
34 class AdminTool: |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
35 |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
36 def __init__(self): |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
37 self.commands = {} |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
38 for k, v in AdminTool.__dict__.items(): |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
39 if k[:3] == 'do_': |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
40 self.commands[k[3:]] = v |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
41 self.help = {} |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
42 for k, v in AdminTool.__dict__.items(): |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
43 if k[:5] == 'help_': |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
44 self.help[k[5:]] = v |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
45 |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
46 def usage(message=''): |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
47 if message: message = 'Problem: '+message+'\n' |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
48 print '''%sUsage: roundup-admin [-i instance home] [-u login] [-c] <command> <arguments> |
|
291
ee7705d7bb06
More help in admin tool.
Richard Jones <richard@users.sourceforge.net>
parents:
287
diff
changeset
|
49 |
|
ee7705d7bb06
More help in admin tool.
Richard Jones <richard@users.sourceforge.net>
parents:
287
diff
changeset
|
50 Help: |
|
ee7705d7bb06
More help in admin tool.
Richard Jones <richard@users.sourceforge.net>
parents:
287
diff
changeset
|
51 roundup-admin -h |
|
ee7705d7bb06
More help in admin tool.
Richard Jones <richard@users.sourceforge.net>
parents:
287
diff
changeset
|
52 roundup-admin help -- this help |
|
ee7705d7bb06
More help in admin tool.
Richard Jones <richard@users.sourceforge.net>
parents:
287
diff
changeset
|
53 roundup-admin help <command> -- command-specific help |
|
ee7705d7bb06
More help in admin tool.
Richard Jones <richard@users.sourceforge.net>
parents:
287
diff
changeset
|
54 roundup-admin help all -- all available help |
|
ee7705d7bb06
More help in admin tool.
Richard Jones <richard@users.sourceforge.net>
parents:
287
diff
changeset
|
55 Options: |
|
ee7705d7bb06
More help in admin tool.
Richard Jones <richard@users.sourceforge.net>
parents:
287
diff
changeset
|
56 -i instance home -- specify the issue tracker "home directory" to administer |
|
ee7705d7bb06
More help in admin tool.
Richard Jones <richard@users.sourceforge.net>
parents:
287
diff
changeset
|
57 -u -- the user[:password] to use for commands |
|
ee7705d7bb06
More help in admin tool.
Richard Jones <richard@users.sourceforge.net>
parents:
287
diff
changeset
|
58 -c -- when outputting lists of data, just comma-separate them'''%message |
|
301
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
59 self.help_commands() |
|
291
ee7705d7bb06
More help in admin tool.
Richard Jones <richard@users.sourceforge.net>
parents:
287
diff
changeset
|
60 |
|
301
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
61 def help_commands(self): |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
62 print 'Commands:', |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
63 commands = [''] |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
64 for command in self.commands.values(): |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
65 h = command.__doc__.split('\n')[0] |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
66 commands.append(h[7:]) |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
67 commands.sort() |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
68 print '\n '.join(commands) |
|
140
a4383d62a407
Now uses getopt, much improved command-line parsing.
Richard Jones <richard@users.sourceforge.net>
parents:
137
diff
changeset
|
69 |
|
301
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
70 def help_all(self): |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
71 print ''' |
|
27
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
72 All commands (except help) require an instance specifier. This is just the path |
|
248
96cdd8ef0581
Added some more help to roundup-admin
Richard Jones <richard@users.sourceforge.net>
parents:
235
diff
changeset
|
73 to the roundup instance you're working with. A roundup instance is where |
|
96cdd8ef0581
Added some more help to roundup-admin
Richard Jones <richard@users.sourceforge.net>
parents:
235
diff
changeset
|
74 roundup keeps the database and configuration file that defines an issue |
|
96cdd8ef0581
Added some more help to roundup-admin
Richard Jones <richard@users.sourceforge.net>
parents:
235
diff
changeset
|
75 tracker. It may be thought of as the issue tracker's "home directory". It may |
|
96cdd8ef0581
Added some more help to roundup-admin
Richard Jones <richard@users.sourceforge.net>
parents:
235
diff
changeset
|
76 be specified in the environment variable ROUNDUP_INSTANCE or on the command |
|
96cdd8ef0581
Added some more help to roundup-admin
Richard Jones <richard@users.sourceforge.net>
parents:
235
diff
changeset
|
77 line as "-i instance". |
|
27
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
78 |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
79 A designator is a classname and a nodeid concatenated, eg. bug1, user10, ... |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
80 |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
81 Property values are represented as strings in command arguments and in the |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
82 printed results: |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
83 . Strings are, well, strings. |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
84 . Date values are printed in the full date format in the local time zone, and |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
85 accepted in the full format or any of the partial formats explained below. |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
86 . Link values are printed as node designators. When given as an argument, |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
87 node designators and key strings are both accepted. |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
88 . Multilink values are printed as lists of node designators joined by commas. |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
89 When given as an argument, node designators and key strings are both |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
90 accepted; an empty string, a single node, or a list of nodes joined by |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
91 commas is accepted. |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
92 |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
93 When multiple nodes are specified to the roundup get or roundup set |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
94 commands, the specified properties are retrieved or set on all the listed |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
95 nodes. |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
96 |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
97 When multiple results are returned by the roundup get or roundup find |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
98 commands, they are printed one per line (default) or joined by commas (with |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
99 the -c) option. |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
100 |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
101 Where the command changes data, a login name/password is required. The |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
102 login may be specified as either "name" or "name:password". |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
103 . ROUNDUP_LOGIN environment variable |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
104 . the -u command-line option |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
105 If either the name or password is not supplied, they are obtained from the |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
106 command-line. |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
107 |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
108 Date format examples: |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
109 "2000-04-17.03:45" means <Date 2000-04-17.08:45:00> |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
110 "2000-04-17" means <Date 2000-04-17.00:00:00> |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
111 "01-25" means <Date yyyy-01-25.00:00:00> |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
112 "08-13.22:13" means <Date yyyy-08-14.03:13:00> |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
113 "11-07.09:32:43" means <Date yyyy-11-07.14:32:43> |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
114 "14:25" means <Date yyyy-mm-dd.19:25:00> |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
115 "8:47:11" means <Date yyyy-mm-dd.13:47:11> |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
116 "." means "right now" |
|
140
a4383d62a407
Now uses getopt, much improved command-line parsing.
Richard Jones <richard@users.sourceforge.net>
parents:
137
diff
changeset
|
117 |
|
a4383d62a407
Now uses getopt, much improved command-line parsing.
Richard Jones <richard@users.sourceforge.net>
parents:
137
diff
changeset
|
118 Command help: |
|
27
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
119 ''' |
|
301
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
120 for name, command in self.commands.items(): |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
121 print '%s:'%name |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
122 print ' ',command.__doc__ |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
123 |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
124 def do_help(self, args, nl_re=re.compile('[\r\n]'), |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
125 indent_re=re.compile(r'^(\s+)\S+')): |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
126 '''Usage: help topic |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
127 Give help about topic. |
|
140
a4383d62a407
Now uses getopt, much improved command-line parsing.
Richard Jones <richard@users.sourceforge.net>
parents:
137
diff
changeset
|
128 |
|
301
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
129 commands -- list commands |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
130 <command> -- help specific to a command |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
131 initopts -- init command options |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
132 all -- all available help |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
133 ''' |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
134 help = self.help.get(args[0], None) |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
135 if help: |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
136 help(self) |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
137 return |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
138 help = self.commands.get(args[0], None) |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
139 if help: |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
140 # display the help, removing the docsring indent |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
141 lines = nl_re.split(help.__doc__) |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
142 print lines[0] |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
143 indent = indent_re.match(lines[1]) |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
144 if indent: indent = len(indent.group(1)) |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
145 for line in lines[1:]: |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
146 if indent: |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
147 print line[indent:] |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
148 else: |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
149 print line |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
150 else: |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
151 print 'Sorry, no help for "%s"'%args[0] |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
152 |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
153 def help_initopts(self): |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
154 import roundup.templates |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
155 templates = roundup.templates.listTemplates() |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
156 print 'Templates:', ', '.join(templates) |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
157 import roundup.backends |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
158 backends = roundup.backends.__all__ |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
159 print 'Back ends:', ', '.join(backends) |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
160 |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
161 |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
162 def do_init(instance_home, args): |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
163 '''Usage: init [template [backend [admin password]]] |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
164 Initialise a new Roundup instance. |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
165 |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
166 The command will prompt for the instance home directory (if not supplied |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
167 through INSTANCE_HOME or the -i option. The template, backend and admin |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
168 password may be specified on the command-line as arguments, in that |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
169 order. |
|
291
ee7705d7bb06
More help in admin tool.
Richard Jones <richard@users.sourceforge.net>
parents:
287
diff
changeset
|
170 |
|
301
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
171 See also initopts help. |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
172 ''' |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
173 # select template |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
174 import roundup.templates |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
175 templates = roundup.templates.listTemplates() |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
176 template = len(args) > 1 and args[1] or '' |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
177 if template not in templates: |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
178 print 'Templates:', ', '.join(templates) |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
179 while template not in templates: |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
180 template = raw_input('Select template [extended]: ').strip() |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
181 if not template: |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
182 template = 'extended' |
|
291
ee7705d7bb06
More help in admin tool.
Richard Jones <richard@users.sourceforge.net>
parents:
287
diff
changeset
|
183 |
|
301
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
184 import roundup.backends |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
185 backends = roundup.backends.__all__ |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
186 backend = len(args) > 2 and args[2] or '' |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
187 if backend not in backends: |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
188 print 'Back ends:', ', '.join(backends) |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
189 while backend not in backends: |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
190 backend = raw_input('Select backend [anydbm]: ').strip() |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
191 if not backend: |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
192 backend = 'anydbm' |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
193 if len(args) > 3: |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
194 adminpw = confirm = args[3] |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
195 else: |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
196 adminpw = '' |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
197 confirm = 'x' |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
198 while adminpw != confirm: |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
199 adminpw = getpass.getpass('Admin Password: ') |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
200 confirm = getpass.getpass(' Confirm: ') |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
201 init.init(instance_home, template, backend, adminpw) |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
202 return 0 |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
203 |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
204 |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
205 def do_get(self, args): |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
206 '''Usage: get property designator[,designator]* |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
207 Get the given property of one or more designator(s). |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
208 |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
209 Retrieves the property value of the nodes specified by the designators. |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
210 ''' |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
211 propname = args[0] |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
212 designators = string.split(args[1], ',') |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
213 l = [] |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
214 for designator in designators: |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
215 classname, nodeid = roundupdb.splitDesignator(designator) |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
216 if self.comma_sep: |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
217 l.append(self.db.getclass(classname).get(nodeid, propname)) |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
218 else: |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
219 print self.db.getclass(classname).get(nodeid, propname) |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
220 if self.comma_sep: |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
221 print ','.join(l) |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
222 return 0 |
|
291
ee7705d7bb06
More help in admin tool.
Richard Jones <richard@users.sourceforge.net>
parents:
287
diff
changeset
|
223 |
|
ee7705d7bb06
More help in admin tool.
Richard Jones <richard@users.sourceforge.net>
parents:
287
diff
changeset
|
224 |
|
301
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
225 def do_set(self, args): |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
226 '''Usage: set designator[,designator]* propname=value ... |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
227 Set the given property of one or more designator(s). |
|
291
ee7705d7bb06
More help in admin tool.
Richard Jones <richard@users.sourceforge.net>
parents:
287
diff
changeset
|
228 |
|
301
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
229 Sets the property to the value for all designators given. |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
230 ''' |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
231 from roundup import hyperdb |
|
140
a4383d62a407
Now uses getopt, much improved command-line parsing.
Richard Jones <richard@users.sourceforge.net>
parents:
137
diff
changeset
|
232 |
|
301
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
233 designators = string.split(args[0], ',') |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
234 props = {} |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
235 for prop in args[1:]: |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
236 key, value = prop.split('=') |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
237 props[key] = value |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
238 for designator in designators: |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
239 classname, nodeid = roundupdb.splitDesignator(designator) |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
240 cl = self.db.getclass(classname) |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
241 properties = cl.getprops() |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
242 for key, value in props.items(): |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
243 type = properties[key] |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
244 if isinstance(type, hyperdb.String): |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
245 continue |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
246 elif isinstance(type, hyperdb.Password): |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
247 props[key] = password.Password(value) |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
248 elif isinstance(type, hyperdb.Date): |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
249 props[key] = date.Date(value) |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
250 elif isinstance(type, hyperdb.Interval): |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
251 props[key] = date.Interval(value) |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
252 elif isinstance(type, hyperdb.Link): |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
253 props[key] = value |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
254 elif isinstance(type, hyperdb.Multilink): |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
255 props[key] = value.split(',') |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
256 apply(cl.set, (nodeid, ), props) |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
257 return 0 |
|
140
a4383d62a407
Now uses getopt, much improved command-line parsing.
Richard Jones <richard@users.sourceforge.net>
parents:
137
diff
changeset
|
258 |
|
301
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
259 def do_find(self, args): |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
260 '''Usage: find classname propname=value ... |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
261 Find the nodes of the given class with a given link property value. |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
262 |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
263 Find the nodes of the given class with a given link property value. The |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
264 value may be either the nodeid of the linked node, or its key value. |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
265 ''' |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
266 classname = args[0] |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
267 cl = self.db.getclass(classname) |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
268 |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
269 # look up the linked-to class and get the nodeid that has the value |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
270 propname, value = args[1].split('=') |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
271 num_re = re.compile('^\d+$') |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
272 if not num_re.match(value): |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
273 propcl = cl.properties[propname] |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
274 if (not isinstance(propcl, hyperdb.Link) and not |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
275 isinstance(type, hyperdb.Multilink)): |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
276 print 'You may only "find" link properties' |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
277 return 1 |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
278 propcl = self.db.getclass(propcl.classname) |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
279 value = propcl.lookup(value) |
|
140
a4383d62a407
Now uses getopt, much improved command-line parsing.
Richard Jones <richard@users.sourceforge.net>
parents:
137
diff
changeset
|
280 |
|
301
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
281 # now do the find |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
282 if self.comma_sep: |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
283 print ','.join(cl.find(**{propname: value})) |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
284 else: |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
285 print cl.find(**{propname: value}) |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
286 return 0 |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
287 |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
288 def do_spec(self, args): |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
289 '''Usage: spec classname |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
290 Show the properties for a classname. |
|
140
a4383d62a407
Now uses getopt, much improved command-line parsing.
Richard Jones <richard@users.sourceforge.net>
parents:
137
diff
changeset
|
291 |
|
301
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
292 This lists the properties for a given class. |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
293 ''' |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
294 classname = args[0] |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
295 cl = self.db.getclass(classname) |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
296 keyprop = cl.getkey() |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
297 for key, value in cl.properties.items(): |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
298 if keyprop == key: |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
299 print '%s: %s (key property)'%(key, value) |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
300 else: |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
301 print '%s: %s'%(key, value) |
|
140
a4383d62a407
Now uses getopt, much improved command-line parsing.
Richard Jones <richard@users.sourceforge.net>
parents:
137
diff
changeset
|
302 |
|
301
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
303 def do_create(self, args): |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
304 '''Usage: create classname property=value ... |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
305 Create a new entry of a given class. |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
306 |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
307 This creates a new entry of the given class using the property |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
308 name=value arguments provided on the command line after the "create" |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
309 command. |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
310 ''' |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
311 from roundup import hyperdb |
|
140
a4383d62a407
Now uses getopt, much improved command-line parsing.
Richard Jones <richard@users.sourceforge.net>
parents:
137
diff
changeset
|
312 |
|
301
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
313 classname = args[0] |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
314 cl = self.db.getclass(classname) |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
315 props = {} |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
316 properties = cl.getprops(protected = 0) |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
317 if len(args) == 1: |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
318 # ask for the properties |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
319 for key, value in properties.items(): |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
320 if key == 'id': continue |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
321 name = value.__class__.__name__ |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
322 if isinstance(value , hyperdb.Password): |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
323 again = None |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
324 while value != again: |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
325 value = getpass.getpass('%s (Password): '%key.capitalize()) |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
326 again = getpass.getpass(' %s (Again): '%key.capitalize()) |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
327 if value != again: print 'Sorry, try again...' |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
328 if value: |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
329 props[key] = value |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
330 else: |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
331 value = raw_input('%s (%s): '%(key.capitalize(), name)) |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
332 if value: |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
333 props[key] = value |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
334 else: |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
335 # use the args |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
336 for prop in args[1:]: |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
337 key, value = prop.split('=') |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
338 props[key] = value |
|
235
d7d358408537
added missing 'import' statements.
Anthony Baxter <anthonybaxter@users.sourceforge.net>
parents:
224
diff
changeset
|
339 |
|
301
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
340 # convert types |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
341 for key in props.keys(): |
|
140
a4383d62a407
Now uses getopt, much improved command-line parsing.
Richard Jones <richard@users.sourceforge.net>
parents:
137
diff
changeset
|
342 type = properties[key] |
|
301
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
343 if isinstance(type, hyperdb.Date): |
|
140
a4383d62a407
Now uses getopt, much improved command-line parsing.
Richard Jones <richard@users.sourceforge.net>
parents:
137
diff
changeset
|
344 props[key] = date.Date(value) |
|
224
ad2c98faec97
using isinstance(blah, Foo) now instead of isFooType
Richard Jones <richard@users.sourceforge.net>
parents:
214
diff
changeset
|
345 elif isinstance(type, hyperdb.Interval): |
|
140
a4383d62a407
Now uses getopt, much improved command-line parsing.
Richard Jones <richard@users.sourceforge.net>
parents:
137
diff
changeset
|
346 props[key] = date.Interval(value) |
|
301
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
347 elif isinstance(type, hyperdb.Password): |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
348 props[key] = password.Password(value) |
|
224
ad2c98faec97
using isinstance(blah, Foo) now instead of isFooType
Richard Jones <richard@users.sourceforge.net>
parents:
214
diff
changeset
|
349 elif isinstance(type, hyperdb.Multilink): |
|
140
a4383d62a407
Now uses getopt, much improved command-line parsing.
Richard Jones <richard@users.sourceforge.net>
parents:
137
diff
changeset
|
350 props[key] = value.split(',') |
|
a4383d62a407
Now uses getopt, much improved command-line parsing.
Richard Jones <richard@users.sourceforge.net>
parents:
137
diff
changeset
|
351 |
|
301
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
352 if cl.getkey() and not props.has_key(cl.getkey()): |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
353 print "You must provide the '%s' property."%cl.getkey() |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
354 else: |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
355 print apply(cl.create, (), props) |
|
140
a4383d62a407
Now uses getopt, much improved command-line parsing.
Richard Jones <richard@users.sourceforge.net>
parents:
137
diff
changeset
|
356 |
|
301
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
357 return 0 |
|
140
a4383d62a407
Now uses getopt, much improved command-line parsing.
Richard Jones <richard@users.sourceforge.net>
parents:
137
diff
changeset
|
358 |
|
301
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
359 def do_list(self, args): |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
360 '''Usage: list classname [property] |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
361 List the instances of a class. |
|
140
a4383d62a407
Now uses getopt, much improved command-line parsing.
Richard Jones <richard@users.sourceforge.net>
parents:
137
diff
changeset
|
362 |
|
301
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
363 Lists all instances of the given class. If the property is not |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
364 specified, the "label" property is used. The label property is tried |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
365 in order: the key, "name", "title" and then the first property, |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
366 alphabetically. |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
367 ''' |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
368 classname = args[0] |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
369 cl = self.db.getclass(classname) |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
370 if len(args) > 1: |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
371 key = args[1] |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
372 else: |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
373 key = cl.labelprop() |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
374 if self.comma_sep: |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
375 print ','.join(cl.list()) |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
376 else: |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
377 for nodeid in cl.list(): |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
378 value = cl.get(nodeid, key) |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
379 print "%4s: %s"%(nodeid, value) |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
380 return 0 |
|
140
a4383d62a407
Now uses getopt, much improved command-line parsing.
Richard Jones <richard@users.sourceforge.net>
parents:
137
diff
changeset
|
381 |
|
301
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
382 def do_table(self, args): |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
383 '''Usage: table classname [property[,property]*] |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
384 List the instances of a class in tabular form. |
|
299
fd9835c1e58d
Did a fair bit of work on the admin tool.
Richard Jones <richard@users.sourceforge.net>
parents:
298
diff
changeset
|
385 |
|
301
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
386 Lists all instances of the given class. If the properties are not |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
387 specified, all properties are displayed. By default, the column widths |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
388 are the width of the property names. The width may be explicitly defined |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
389 by defining the property as "name:width". For example:: |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
390 roundup> table priority id,name:10 |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
391 Id Name |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
392 1 fatal-bug |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
393 2 bug |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
394 3 usability |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
395 4 feature |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
396 ''' |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
397 classname = args[0] |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
398 cl = self.db.getclass(classname) |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
399 if len(args) > 1: |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
400 prop_names = args[1].split(',') |
|
299
fd9835c1e58d
Did a fair bit of work on the admin tool.
Richard Jones <richard@users.sourceforge.net>
parents:
298
diff
changeset
|
401 else: |
|
301
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
402 prop_names = cl.getprops().keys() |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
403 props = [] |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
404 for name in prop_names: |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
405 if ':' in name: |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
406 name, width = name.split(':') |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
407 props.append((name, int(width))) |
|
299
fd9835c1e58d
Did a fair bit of work on the admin tool.
Richard Jones <richard@users.sourceforge.net>
parents:
298
diff
changeset
|
408 else: |
|
301
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
409 props.append((name, len(name))) |
|
140
a4383d62a407
Now uses getopt, much improved command-line parsing.
Richard Jones <richard@users.sourceforge.net>
parents:
137
diff
changeset
|
410 |
|
301
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
411 print ' '.join([string.capitalize(name) for name, width in props]) |
|
278
a5dabf2430c5
Added database importing and exporting through CSV files.
Richard Jones <richard@users.sourceforge.net>
parents:
274
diff
changeset
|
412 for nodeid in cl.list(): |
|
299
fd9835c1e58d
Did a fair bit of work on the admin tool.
Richard Jones <richard@users.sourceforge.net>
parents:
298
diff
changeset
|
413 l = [] |
|
301
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
414 for name, width in props: |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
415 if name != 'id': |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
416 value = str(cl.get(nodeid, name)) |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
417 else: |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
418 value = str(nodeid) |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
419 f = '%%-%ds'%width |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
420 l.append(f%value[:width]) |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
421 print ' '.join(l) |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
422 return 0 |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
423 |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
424 def do_history(self, args): |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
425 '''Usage: history designator |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
426 Show the history entries of a designator. |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
427 |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
428 Lists the journal entries for the node identified by the designator. |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
429 ''' |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
430 classname, nodeid = roundupdb.splitDesignator(args[0]) |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
431 # TODO: handle the -c option? |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
432 print self.db.getclass(classname).history(nodeid) |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
433 return 0 |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
434 |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
435 def do_retire(self, args): |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
436 '''Usage: retire designator[,designator]* |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
437 Retire the node specified by designator. |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
438 |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
439 This action indicates that a particular node is not to be retrieved by |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
440 the list or find commands, and its key value may be re-used. |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
441 ''' |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
442 designators = string.split(args[0], ',') |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
443 for designator in designators: |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
444 classname, nodeid = roundupdb.splitDesignator(designator) |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
445 self.db.getclass(classname).retire(nodeid) |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
446 return 0 |
|
299
fd9835c1e58d
Did a fair bit of work on the admin tool.
Richard Jones <richard@users.sourceforge.net>
parents:
298
diff
changeset
|
447 |
|
301
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
448 def do_export(self, args): |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
449 '''Usage: export class[,class] destination_dir |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
450 Export the database to tab-separated-value files. |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
451 |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
452 This action exports the current data from the database into |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
453 tab-separated-value files that are placed in the nominated destination |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
454 directory. The journals are not exported. |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
455 ''' |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
456 if len(args) < 2: |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
457 print do_export.__doc__ |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
458 return 1 |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
459 classes = string.split(args[0], ',') |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
460 dir = args[1] |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
461 |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
462 # use the csv parser if we can - it's faster |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
463 if csv is not None: |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
464 p = csv.parser(field_sep=':') |
|
278
a5dabf2430c5
Added database importing and exporting through CSV files.
Richard Jones <richard@users.sourceforge.net>
parents:
274
diff
changeset
|
465 |
|
301
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
466 # do all the classes specified |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
467 for classname in classes: |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
468 cl = self.db.getclass(classname) |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
469 f = open(os.path.join(dir, classname+'.csv'), 'w') |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
470 f.write(string.join(cl.properties.keys(), ':') + '\n') |
|
278
a5dabf2430c5
Added database importing and exporting through CSV files.
Richard Jones <richard@users.sourceforge.net>
parents:
274
diff
changeset
|
471 |
|
301
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
472 # all nodes for this class |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
473 properties = cl.properties.items() |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
474 for nodeid in cl.list(): |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
475 l = [] |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
476 for prop, type in properties: |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
477 value = cl.get(nodeid, prop) |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
478 # convert data where needed |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
479 if isinstance(type, hyperdb.Date): |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
480 value = value.get_tuple() |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
481 elif isinstance(type, hyperdb.Interval): |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
482 value = value.get_tuple() |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
483 elif isinstance(type, hyperdb.Password): |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
484 value = str(value) |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
485 l.append(repr(value)) |
|
278
a5dabf2430c5
Added database importing and exporting through CSV files.
Richard Jones <richard@users.sourceforge.net>
parents:
274
diff
changeset
|
486 |
|
301
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
487 # now write |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
488 if csv is not None: |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
489 f.write(p.join(l) + '\n') |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
490 else: |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
491 # escape the individual entries to they're valid CSV |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
492 m = [] |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
493 for entry in l: |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
494 if '"' in entry: |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
495 entry = '""'.join(entry.split('"')) |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
496 if ':' in entry: |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
497 entry = '"%s"'%entry |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
498 m.append(entry) |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
499 f.write(':'.join(m) + '\n') |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
500 return 0 |
|
278
a5dabf2430c5
Added database importing and exporting through CSV files.
Richard Jones <richard@users.sourceforge.net>
parents:
274
diff
changeset
|
501 |
|
301
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
502 def do_import(self, args): |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
503 '''Usage: import class file |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
504 Import the contents of the tab-separated-value file. |
|
278
a5dabf2430c5
Added database importing and exporting through CSV files.
Richard Jones <richard@users.sourceforge.net>
parents:
274
diff
changeset
|
505 |
|
301
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
506 The file must define the same properties as the class (including having |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
507 a "header" line with those property names.) The new nodes are added to |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
508 the existing database - if you want to create a new database using the |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
509 imported data, then create a new database (or, tediously, retire all |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
510 the old data.) |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
511 ''' |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
512 if len(args) < 2: |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
513 print do_import.__doc__ |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
514 return 1 |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
515 if csv is None: |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
516 print 'Sorry, you need the csv module to use this function.' |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
517 print 'Get it from: http://www.object-craft.com.au/projects/csv/' |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
518 return 1 |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
519 |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
520 from roundup import hyperdb |
|
278
a5dabf2430c5
Added database importing and exporting through CSV files.
Richard Jones <richard@users.sourceforge.net>
parents:
274
diff
changeset
|
521 |
|
301
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
522 # ensure that the properties and the CSV file headings match |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
523 cl = self.db.getclass(args[0]) |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
524 f = open(args[1]) |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
525 p = csv.parser(field_sep=':') |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
526 file_props = p.parse(f.readline()) |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
527 props = cl.properties.keys() |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
528 m = file_props[:] |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
529 m.sort() |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
530 props.sort() |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
531 if m != props: |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
532 print 'Import file doesn\'t define the same properties as "%s".'%args[0] |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
533 return 1 |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
534 |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
535 # loop through the file and create a node for each entry |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
536 n = range(len(props)) |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
537 while 1: |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
538 line = f.readline() |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
539 if not line: break |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
540 |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
541 # parse lines until we get a complete entry |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
542 while 1: |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
543 l = p.parse(line) |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
544 if l: break |
|
278
a5dabf2430c5
Added database importing and exporting through CSV files.
Richard Jones <richard@users.sourceforge.net>
parents:
274
diff
changeset
|
545 |
|
301
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
546 # make the new node's property map |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
547 d = {} |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
548 for i in n: |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
549 # Use eval to reverse the repr() used to output the CSV |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
550 value = eval(l[i]) |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
551 # Figure the property for this column |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
552 key = file_props[i] |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
553 type = cl.properties[key] |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
554 # Convert for property type |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
555 if isinstance(type, hyperdb.Date): |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
556 value = date.Date(value) |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
557 elif isinstance(type, hyperdb.Interval): |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
558 value = date.Interval(value) |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
559 elif isinstance(type, hyperdb.Password): |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
560 pwd = password.Password() |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
561 pwd.unpack(value) |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
562 value = pwd |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
563 if value is not None: |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
564 d[key] = value |
|
278
a5dabf2430c5
Added database importing and exporting through CSV files.
Richard Jones <richard@users.sourceforge.net>
parents:
274
diff
changeset
|
565 |
|
301
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
566 # and create the new node |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
567 apply(cl.create, (), d) |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
568 return 0 |
|
27
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
569 |
|
296
e155eca83f40
Beginnings of an interactive mode for roundup-admin
Richard Jones <richard@users.sourceforge.net>
parents:
294
diff
changeset
|
570 def run_command(self, args): |
|
299
fd9835c1e58d
Did a fair bit of work on the admin tool.
Richard Jones <richard@users.sourceforge.net>
parents:
298
diff
changeset
|
571 '''Run a single command |
|
fd9835c1e58d
Did a fair bit of work on the admin tool.
Richard Jones <richard@users.sourceforge.net>
parents:
298
diff
changeset
|
572 ''' |
|
296
e155eca83f40
Beginnings of an interactive mode for roundup-admin
Richard Jones <richard@users.sourceforge.net>
parents:
294
diff
changeset
|
573 command = args[0] |
|
27
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
574 |
|
296
e155eca83f40
Beginnings of an interactive mode for roundup-admin
Richard Jones <richard@users.sourceforge.net>
parents:
294
diff
changeset
|
575 # handle help now |
|
e155eca83f40
Beginnings of an interactive mode for roundup-admin
Richard Jones <richard@users.sourceforge.net>
parents:
294
diff
changeset
|
576 if command == 'help': |
|
e155eca83f40
Beginnings of an interactive mode for roundup-admin
Richard Jones <richard@users.sourceforge.net>
parents:
294
diff
changeset
|
577 if len(args)>1: |
|
301
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
578 self.do_help(args[1:]) |
|
296
e155eca83f40
Beginnings of an interactive mode for roundup-admin
Richard Jones <richard@users.sourceforge.net>
parents:
294
diff
changeset
|
579 return 0 |
|
301
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
580 self.do_help(['help']) |
|
296
e155eca83f40
Beginnings of an interactive mode for roundup-admin
Richard Jones <richard@users.sourceforge.net>
parents:
294
diff
changeset
|
581 return 0 |
|
e155eca83f40
Beginnings of an interactive mode for roundup-admin
Richard Jones <richard@users.sourceforge.net>
parents:
294
diff
changeset
|
582 if command == 'morehelp': |
|
301
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
583 self.do_help(['help']) |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
584 self.help_commands() |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
585 self.help_all() |
|
296
e155eca83f40
Beginnings of an interactive mode for roundup-admin
Richard Jones <richard@users.sourceforge.net>
parents:
294
diff
changeset
|
586 return 0 |
|
e155eca83f40
Beginnings of an interactive mode for roundup-admin
Richard Jones <richard@users.sourceforge.net>
parents:
294
diff
changeset
|
587 |
|
e155eca83f40
Beginnings of an interactive mode for roundup-admin
Richard Jones <richard@users.sourceforge.net>
parents:
294
diff
changeset
|
588 # make sure we have an instance_home |
|
e155eca83f40
Beginnings of an interactive mode for roundup-admin
Richard Jones <richard@users.sourceforge.net>
parents:
294
diff
changeset
|
589 while not self.instance_home: |
|
e155eca83f40
Beginnings of an interactive mode for roundup-admin
Richard Jones <richard@users.sourceforge.net>
parents:
294
diff
changeset
|
590 self.instance_home = raw_input('Enter instance home: ').strip() |
|
140
a4383d62a407
Now uses getopt, much improved command-line parsing.
Richard Jones <richard@users.sourceforge.net>
parents:
137
diff
changeset
|
591 |
|
296
e155eca83f40
Beginnings of an interactive mode for roundup-admin
Richard Jones <richard@users.sourceforge.net>
parents:
294
diff
changeset
|
592 # before we open the db, we may be doing an init |
|
e155eca83f40
Beginnings of an interactive mode for roundup-admin
Richard Jones <richard@users.sourceforge.net>
parents:
294
diff
changeset
|
593 if command == 'init': |
|
301
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
594 return self.do_init(self.instance_home, args) |
|
296
e155eca83f40
Beginnings of an interactive mode for roundup-admin
Richard Jones <richard@users.sourceforge.net>
parents:
294
diff
changeset
|
595 |
|
301
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
596 function = self.commands.get(command, None) |
|
296
e155eca83f40
Beginnings of an interactive mode for roundup-admin
Richard Jones <richard@users.sourceforge.net>
parents:
294
diff
changeset
|
597 |
|
e155eca83f40
Beginnings of an interactive mode for roundup-admin
Richard Jones <richard@users.sourceforge.net>
parents:
294
diff
changeset
|
598 # not a valid command |
|
e155eca83f40
Beginnings of an interactive mode for roundup-admin
Richard Jones <richard@users.sourceforge.net>
parents:
294
diff
changeset
|
599 if function is None: |
|
299
fd9835c1e58d
Did a fair bit of work on the admin tool.
Richard Jones <richard@users.sourceforge.net>
parents:
298
diff
changeset
|
600 print 'Unknown command "%s" ("help commands" for a list)'%command |
|
296
e155eca83f40
Beginnings of an interactive mode for roundup-admin
Richard Jones <richard@users.sourceforge.net>
parents:
294
diff
changeset
|
601 return 1 |
|
27
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
602 |
|
296
e155eca83f40
Beginnings of an interactive mode for roundup-admin
Richard Jones <richard@users.sourceforge.net>
parents:
294
diff
changeset
|
603 # get the instance |
|
e155eca83f40
Beginnings of an interactive mode for roundup-admin
Richard Jones <richard@users.sourceforge.net>
parents:
294
diff
changeset
|
604 instance = roundup.instance.open(self.instance_home) |
|
301
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
605 self.db = instance.open('admin') |
|
27
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
606 |
|
296
e155eca83f40
Beginnings of an interactive mode for roundup-admin
Richard Jones <richard@users.sourceforge.net>
parents:
294
diff
changeset
|
607 if len(args) < 2: |
|
e155eca83f40
Beginnings of an interactive mode for roundup-admin
Richard Jones <richard@users.sourceforge.net>
parents:
294
diff
changeset
|
608 print function.__doc__ |
|
e155eca83f40
Beginnings of an interactive mode for roundup-admin
Richard Jones <richard@users.sourceforge.net>
parents:
294
diff
changeset
|
609 return 1 |
|
137
4a87e0b0d3f7
Made the "init" prompting more friendly.
Richard Jones <richard@users.sourceforge.net>
parents:
127
diff
changeset
|
610 |
|
296
e155eca83f40
Beginnings of an interactive mode for roundup-admin
Richard Jones <richard@users.sourceforge.net>
parents:
294
diff
changeset
|
611 # do the command |
|
e155eca83f40
Beginnings of an interactive mode for roundup-admin
Richard Jones <richard@users.sourceforge.net>
parents:
294
diff
changeset
|
612 try: |
|
301
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
613 return function(args[1:]) |
|
296
e155eca83f40
Beginnings of an interactive mode for roundup-admin
Richard Jones <richard@users.sourceforge.net>
parents:
294
diff
changeset
|
614 finally: |
|
301
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
615 self.db.close() |
|
137
4a87e0b0d3f7
Made the "init" prompting more friendly.
Richard Jones <richard@users.sourceforge.net>
parents:
127
diff
changeset
|
616 |
|
27
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
617 return 1 |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
618 |
|
296
e155eca83f40
Beginnings of an interactive mode for roundup-admin
Richard Jones <richard@users.sourceforge.net>
parents:
294
diff
changeset
|
619 def interactive(self, ws_re=re.compile(r'\s+')): |
|
e155eca83f40
Beginnings of an interactive mode for roundup-admin
Richard Jones <richard@users.sourceforge.net>
parents:
294
diff
changeset
|
620 '''Run in an interactive mode |
|
e155eca83f40
Beginnings of an interactive mode for roundup-admin
Richard Jones <richard@users.sourceforge.net>
parents:
294
diff
changeset
|
621 ''' |
|
298
07a64ec2a79d
Interactive startup blurb - need to figure how to get the version in there.
Richard Jones <richard@users.sourceforge.net>
parents:
297
diff
changeset
|
622 print 'Roundup {version} ready for input.' |
|
07a64ec2a79d
Interactive startup blurb - need to figure how to get the version in there.
Richard Jones <richard@users.sourceforge.net>
parents:
297
diff
changeset
|
623 print 'Type "help" for help.' |
|
297
1bbc16563d89
Now with readline support :)
Richard Jones <richard@users.sourceforge.net>
parents:
296
diff
changeset
|
624 try: |
|
1bbc16563d89
Now with readline support :)
Richard Jones <richard@users.sourceforge.net>
parents:
296
diff
changeset
|
625 import readline |
|
1bbc16563d89
Now with readline support :)
Richard Jones <richard@users.sourceforge.net>
parents:
296
diff
changeset
|
626 except ImportError: |
|
1bbc16563d89
Now with readline support :)
Richard Jones <richard@users.sourceforge.net>
parents:
296
diff
changeset
|
627 print "Note: command history and editing not available" |
|
1bbc16563d89
Now with readline support :)
Richard Jones <richard@users.sourceforge.net>
parents:
296
diff
changeset
|
628 |
|
296
e155eca83f40
Beginnings of an interactive mode for roundup-admin
Richard Jones <richard@users.sourceforge.net>
parents:
294
diff
changeset
|
629 while 1: |
|
e155eca83f40
Beginnings of an interactive mode for roundup-admin
Richard Jones <richard@users.sourceforge.net>
parents:
294
diff
changeset
|
630 try: |
|
e155eca83f40
Beginnings of an interactive mode for roundup-admin
Richard Jones <richard@users.sourceforge.net>
parents:
294
diff
changeset
|
631 command = raw_input('roundup> ') |
|
e155eca83f40
Beginnings of an interactive mode for roundup-admin
Richard Jones <richard@users.sourceforge.net>
parents:
294
diff
changeset
|
632 except EOFError: |
|
e155eca83f40
Beginnings of an interactive mode for roundup-admin
Richard Jones <richard@users.sourceforge.net>
parents:
294
diff
changeset
|
633 print '.. exit' |
|
e155eca83f40
Beginnings of an interactive mode for roundup-admin
Richard Jones <richard@users.sourceforge.net>
parents:
294
diff
changeset
|
634 return 0 |
|
e155eca83f40
Beginnings of an interactive mode for roundup-admin
Richard Jones <richard@users.sourceforge.net>
parents:
294
diff
changeset
|
635 args = ws_re.split(command) |
|
e155eca83f40
Beginnings of an interactive mode for roundup-admin
Richard Jones <richard@users.sourceforge.net>
parents:
294
diff
changeset
|
636 if not args: continue |
|
e155eca83f40
Beginnings of an interactive mode for roundup-admin
Richard Jones <richard@users.sourceforge.net>
parents:
294
diff
changeset
|
637 if args[0] in ('quit', 'exit'): return 0 |
|
e155eca83f40
Beginnings of an interactive mode for roundup-admin
Richard Jones <richard@users.sourceforge.net>
parents:
294
diff
changeset
|
638 self.run_command(args) |
|
270
a4241ddd22d7
Added the Password property type.
Richard Jones <richard@users.sourceforge.net>
parents:
264
diff
changeset
|
639 |
|
296
e155eca83f40
Beginnings of an interactive mode for roundup-admin
Richard Jones <richard@users.sourceforge.net>
parents:
294
diff
changeset
|
640 def main(self): |
|
e155eca83f40
Beginnings of an interactive mode for roundup-admin
Richard Jones <richard@users.sourceforge.net>
parents:
294
diff
changeset
|
641 opts, args = getopt.getopt(sys.argv[1:], 'i:u:hc') |
|
274
79226fbb7741
Spit out command help if roundup-admin command doesn't get an argument.
Richard Jones <richard@users.sourceforge.net>
parents:
270
diff
changeset
|
642 |
|
296
e155eca83f40
Beginnings of an interactive mode for roundup-admin
Richard Jones <richard@users.sourceforge.net>
parents:
294
diff
changeset
|
643 # handle command-line args |
|
e155eca83f40
Beginnings of an interactive mode for roundup-admin
Richard Jones <richard@users.sourceforge.net>
parents:
294
diff
changeset
|
644 self.instance_home = os.environ.get('ROUNDUP_INSTANCE', '') |
|
e155eca83f40
Beginnings of an interactive mode for roundup-admin
Richard Jones <richard@users.sourceforge.net>
parents:
294
diff
changeset
|
645 name = password = '' |
|
e155eca83f40
Beginnings of an interactive mode for roundup-admin
Richard Jones <richard@users.sourceforge.net>
parents:
294
diff
changeset
|
646 if os.environ.has_key('ROUNDUP_LOGIN'): |
|
e155eca83f40
Beginnings of an interactive mode for roundup-admin
Richard Jones <richard@users.sourceforge.net>
parents:
294
diff
changeset
|
647 l = os.environ['ROUNDUP_LOGIN'].split(':') |
|
e155eca83f40
Beginnings of an interactive mode for roundup-admin
Richard Jones <richard@users.sourceforge.net>
parents:
294
diff
changeset
|
648 name = l[0] |
|
e155eca83f40
Beginnings of an interactive mode for roundup-admin
Richard Jones <richard@users.sourceforge.net>
parents:
294
diff
changeset
|
649 if len(l) > 1: |
|
e155eca83f40
Beginnings of an interactive mode for roundup-admin
Richard Jones <richard@users.sourceforge.net>
parents:
294
diff
changeset
|
650 password = l[1] |
|
e155eca83f40
Beginnings of an interactive mode for roundup-admin
Richard Jones <richard@users.sourceforge.net>
parents:
294
diff
changeset
|
651 self.comma_sep = 0 |
|
e155eca83f40
Beginnings of an interactive mode for roundup-admin
Richard Jones <richard@users.sourceforge.net>
parents:
294
diff
changeset
|
652 for opt, arg in opts: |
|
e155eca83f40
Beginnings of an interactive mode for roundup-admin
Richard Jones <richard@users.sourceforge.net>
parents:
294
diff
changeset
|
653 if opt == '-h': |
|
e155eca83f40
Beginnings of an interactive mode for roundup-admin
Richard Jones <richard@users.sourceforge.net>
parents:
294
diff
changeset
|
654 usage() |
|
e155eca83f40
Beginnings of an interactive mode for roundup-admin
Richard Jones <richard@users.sourceforge.net>
parents:
294
diff
changeset
|
655 return 0 |
|
e155eca83f40
Beginnings of an interactive mode for roundup-admin
Richard Jones <richard@users.sourceforge.net>
parents:
294
diff
changeset
|
656 if opt == '-i': |
|
e155eca83f40
Beginnings of an interactive mode for roundup-admin
Richard Jones <richard@users.sourceforge.net>
parents:
294
diff
changeset
|
657 self.instance_home = arg |
|
e155eca83f40
Beginnings of an interactive mode for roundup-admin
Richard Jones <richard@users.sourceforge.net>
parents:
294
diff
changeset
|
658 if opt == '-c': |
|
e155eca83f40
Beginnings of an interactive mode for roundup-admin
Richard Jones <richard@users.sourceforge.net>
parents:
294
diff
changeset
|
659 self.comma_sep = 1 |
|
140
a4383d62a407
Now uses getopt, much improved command-line parsing.
Richard Jones <richard@users.sourceforge.net>
parents:
137
diff
changeset
|
660 |
|
296
e155eca83f40
Beginnings of an interactive mode for roundup-admin
Richard Jones <richard@users.sourceforge.net>
parents:
294
diff
changeset
|
661 # if no command - go interactive |
|
e155eca83f40
Beginnings of an interactive mode for roundup-admin
Richard Jones <richard@users.sourceforge.net>
parents:
294
diff
changeset
|
662 if not args: |
|
e155eca83f40
Beginnings of an interactive mode for roundup-admin
Richard Jones <richard@users.sourceforge.net>
parents:
294
diff
changeset
|
663 return self.interactive() |
|
e155eca83f40
Beginnings of an interactive mode for roundup-admin
Richard Jones <richard@users.sourceforge.net>
parents:
294
diff
changeset
|
664 |
|
e155eca83f40
Beginnings of an interactive mode for roundup-admin
Richard Jones <richard@users.sourceforge.net>
parents:
294
diff
changeset
|
665 self.run_command(args) |
|
140
a4383d62a407
Now uses getopt, much improved command-line parsing.
Richard Jones <richard@users.sourceforge.net>
parents:
137
diff
changeset
|
666 |
|
27
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
667 |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
668 if __name__ == '__main__': |
|
296
e155eca83f40
Beginnings of an interactive mode for roundup-admin
Richard Jones <richard@users.sourceforge.net>
parents:
294
diff
changeset
|
669 tool = AdminTool() |
|
e155eca83f40
Beginnings of an interactive mode for roundup-admin
Richard Jones <richard@users.sourceforge.net>
parents:
294
diff
changeset
|
670 sys.exit(tool.main()) |
|
27
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
671 |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
672 # |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
673 # $Log: not supported by cvs2svn $ |
|
301
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
674 # Revision 1.33 2001/10/17 23:13:19 richard |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
675 # Did a fair bit of work on the admin tool. Now has an extra command "table" |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
676 # which displays node information in a tabular format. Also fixed import and |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
677 # export so they work. Removed freshen. |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
678 # Fixed quopri usage in mailgw from bug reports. |
|
7901b58cfae8
Oops, committed the admin script with the wierd #! line.
Richard Jones <richard@users.sourceforge.net>
parents:
299
diff
changeset
|
679 # |
|
299
fd9835c1e58d
Did a fair bit of work on the admin tool.
Richard Jones <richard@users.sourceforge.net>
parents:
298
diff
changeset
|
680 # Revision 1.32 2001/10/17 06:57:29 richard |
|
fd9835c1e58d
Did a fair bit of work on the admin tool.
Richard Jones <richard@users.sourceforge.net>
parents:
298
diff
changeset
|
681 # Interactive startup blurb - need to figure how to get the version in there. |
|
fd9835c1e58d
Did a fair bit of work on the admin tool.
Richard Jones <richard@users.sourceforge.net>
parents:
298
diff
changeset
|
682 # |
|
298
07a64ec2a79d
Interactive startup blurb - need to figure how to get the version in there.
Richard Jones <richard@users.sourceforge.net>
parents:
297
diff
changeset
|
683 # Revision 1.31 2001/10/17 06:17:26 richard |
|
07a64ec2a79d
Interactive startup blurb - need to figure how to get the version in there.
Richard Jones <richard@users.sourceforge.net>
parents:
297
diff
changeset
|
684 # Now with readline support :) |
|
07a64ec2a79d
Interactive startup blurb - need to figure how to get the version in there.
Richard Jones <richard@users.sourceforge.net>
parents:
297
diff
changeset
|
685 # |
|
297
1bbc16563d89
Now with readline support :)
Richard Jones <richard@users.sourceforge.net>
parents:
296
diff
changeset
|
686 # Revision 1.30 2001/10/17 06:04:00 richard |
|
1bbc16563d89
Now with readline support :)
Richard Jones <richard@users.sourceforge.net>
parents:
296
diff
changeset
|
687 # Beginnings of an interactive mode for roundup-admin |
|
1bbc16563d89
Now with readline support :)
Richard Jones <richard@users.sourceforge.net>
parents:
296
diff
changeset
|
688 # |
|
296
e155eca83f40
Beginnings of an interactive mode for roundup-admin
Richard Jones <richard@users.sourceforge.net>
parents:
294
diff
changeset
|
689 # Revision 1.29 2001/10/16 03:48:01 richard |
|
e155eca83f40
Beginnings of an interactive mode for roundup-admin
Richard Jones <richard@users.sourceforge.net>
parents:
294
diff
changeset
|
690 # admin tool now complains if a "find" is attempted with a non-link property. |
|
e155eca83f40
Beginnings of an interactive mode for roundup-admin
Richard Jones <richard@users.sourceforge.net>
parents:
294
diff
changeset
|
691 # |
|
294
49be38bb6e9a
admin tool now complains if a "find" is attempted with a non-link property.
Richard Jones <richard@users.sourceforge.net>
parents:
291
diff
changeset
|
692 # Revision 1.28 2001/10/13 00:07:39 richard |
|
49be38bb6e9a
admin tool now complains if a "find" is attempted with a non-link property.
Richard Jones <richard@users.sourceforge.net>
parents:
291
diff
changeset
|
693 # More help in admin tool. |
|
49be38bb6e9a
admin tool now complains if a "find" is attempted with a non-link property.
Richard Jones <richard@users.sourceforge.net>
parents:
291
diff
changeset
|
694 # |
|
291
ee7705d7bb06
More help in admin tool.
Richard Jones <richard@users.sourceforge.net>
parents:
287
diff
changeset
|
695 # Revision 1.27 2001/10/11 23:43:04 richard |
|
ee7705d7bb06
More help in admin tool.
Richard Jones <richard@users.sourceforge.net>
parents:
287
diff
changeset
|
696 # Implemented the comma-separated printing option in the admin tool. |
|
ee7705d7bb06
More help in admin tool.
Richard Jones <richard@users.sourceforge.net>
parents:
287
diff
changeset
|
697 # Fixed a typo (more of a vim-o actually :) in mailgw. |
|
ee7705d7bb06
More help in admin tool.
Richard Jones <richard@users.sourceforge.net>
parents:
287
diff
changeset
|
698 # |
|
287
ee2f4cb160bd
Implemented the comma-separated printing option in the admin tool.
Richard Jones <richard@users.sourceforge.net>
parents:
285
diff
changeset
|
699 # Revision 1.26 2001/10/11 05:03:51 richard |
|
ee2f4cb160bd
Implemented the comma-separated printing option in the admin tool.
Richard Jones <richard@users.sourceforge.net>
parents:
285
diff
changeset
|
700 # Marked the roundup-admin import/export as experimental since they're not fully |
|
ee2f4cb160bd
Implemented the comma-separated printing option in the admin tool.
Richard Jones <richard@users.sourceforge.net>
parents:
285
diff
changeset
|
701 # operational. |
|
ee2f4cb160bd
Implemented the comma-separated printing option in the admin tool.
Richard Jones <richard@users.sourceforge.net>
parents:
285
diff
changeset
|
702 # |
|
285
a6e3a9164814
Marked the roundup-admin import/export as experimental...
Richard Jones <richard@users.sourceforge.net>
parents:
280
diff
changeset
|
703 # Revision 1.25 2001/10/10 04:12:32 richard |
|
a6e3a9164814
Marked the roundup-admin import/export as experimental...
Richard Jones <richard@users.sourceforge.net>
parents:
280
diff
changeset
|
704 # The setup.cfg file is just causing pain. Away it goes. |
|
a6e3a9164814
Marked the roundup-admin import/export as experimental...
Richard Jones <richard@users.sourceforge.net>
parents:
280
diff
changeset
|
705 # |
|
280
80ad2bf9cf7b
The setup.cfg file is just causing pain. Away it goes.
Richard Jones <richard@users.sourceforge.net>
parents:
278
diff
changeset
|
706 # Revision 1.24 2001/10/10 03:54:57 richard |
|
80ad2bf9cf7b
The setup.cfg file is just causing pain. Away it goes.
Richard Jones <richard@users.sourceforge.net>
parents:
278
diff
changeset
|
707 # Added database importing and exporting through CSV files. |
|
80ad2bf9cf7b
The setup.cfg file is just causing pain. Away it goes.
Richard Jones <richard@users.sourceforge.net>
parents:
278
diff
changeset
|
708 # Uses the csv module from object-craft for exporting if it's available. |
|
80ad2bf9cf7b
The setup.cfg file is just causing pain. Away it goes.
Richard Jones <richard@users.sourceforge.net>
parents:
278
diff
changeset
|
709 # Requires the csv module for importing. |
|
80ad2bf9cf7b
The setup.cfg file is just causing pain. Away it goes.
Richard Jones <richard@users.sourceforge.net>
parents:
278
diff
changeset
|
710 # |
|
278
a5dabf2430c5
Added database importing and exporting through CSV files.
Richard Jones <richard@users.sourceforge.net>
parents:
274
diff
changeset
|
711 # Revision 1.23 2001/10/09 23:36:25 richard |
|
a5dabf2430c5
Added database importing and exporting through CSV files.
Richard Jones <richard@users.sourceforge.net>
parents:
274
diff
changeset
|
712 # Spit out command help if roundup-admin command doesn't get an argument. |
|
a5dabf2430c5
Added database importing and exporting through CSV files.
Richard Jones <richard@users.sourceforge.net>
parents:
274
diff
changeset
|
713 # |
|
274
79226fbb7741
Spit out command help if roundup-admin command doesn't get an argument.
Richard Jones <richard@users.sourceforge.net>
parents:
270
diff
changeset
|
714 # Revision 1.22 2001/10/09 07:25:59 richard |
|
79226fbb7741
Spit out command help if roundup-admin command doesn't get an argument.
Richard Jones <richard@users.sourceforge.net>
parents:
270
diff
changeset
|
715 # Added the Password property type. See "pydoc roundup.password" for |
|
79226fbb7741
Spit out command help if roundup-admin command doesn't get an argument.
Richard Jones <richard@users.sourceforge.net>
parents:
270
diff
changeset
|
716 # implementation details. Have updated some of the documentation too. |
|
79226fbb7741
Spit out command help if roundup-admin command doesn't get an argument.
Richard Jones <richard@users.sourceforge.net>
parents:
270
diff
changeset
|
717 # |
|
270
a4241ddd22d7
Added the Password property type.
Richard Jones <richard@users.sourceforge.net>
parents:
264
diff
changeset
|
718 # Revision 1.21 2001/10/05 02:23:24 richard |
|
a4241ddd22d7
Added the Password property type.
Richard Jones <richard@users.sourceforge.net>
parents:
264
diff
changeset
|
719 # . roundup-admin create now prompts for property info if none is supplied |
|
a4241ddd22d7
Added the Password property type.
Richard Jones <richard@users.sourceforge.net>
parents:
264
diff
changeset
|
720 # on the command-line. |
|
a4241ddd22d7
Added the Password property type.
Richard Jones <richard@users.sourceforge.net>
parents:
264
diff
changeset
|
721 # . hyperdb Class getprops() method may now return only the mutable |
|
a4241ddd22d7
Added the Password property type.
Richard Jones <richard@users.sourceforge.net>
parents:
264
diff
changeset
|
722 # properties. |
|
a4241ddd22d7
Added the Password property type.
Richard Jones <richard@users.sourceforge.net>
parents:
264
diff
changeset
|
723 # . Login now uses cookies, which makes it a whole lot more flexible. We can |
|
a4241ddd22d7
Added the Password property type.
Richard Jones <richard@users.sourceforge.net>
parents:
264
diff
changeset
|
724 # now support anonymous user access (read-only, unless there's an |
|
a4241ddd22d7
Added the Password property type.
Richard Jones <richard@users.sourceforge.net>
parents:
264
diff
changeset
|
725 # "anonymous" user, in which case write access is permitted). Login |
|
a4241ddd22d7
Added the Password property type.
Richard Jones <richard@users.sourceforge.net>
parents:
264
diff
changeset
|
726 # handling has been moved into cgi_client.Client.main() |
|
a4241ddd22d7
Added the Password property type.
Richard Jones <richard@users.sourceforge.net>
parents:
264
diff
changeset
|
727 # . The "extended" schema is now the default in roundup init. |
|
a4241ddd22d7
Added the Password property type.
Richard Jones <richard@users.sourceforge.net>
parents:
264
diff
changeset
|
728 # . The schemas have had their page headings modified to cope with the new |
|
a4241ddd22d7
Added the Password property type.
Richard Jones <richard@users.sourceforge.net>
parents:
264
diff
changeset
|
729 # login handling. Existing installations should copy the interfaces.py |
|
a4241ddd22d7
Added the Password property type.
Richard Jones <richard@users.sourceforge.net>
parents:
264
diff
changeset
|
730 # file from the roundup lib directory to their instance home. |
|
a4241ddd22d7
Added the Password property type.
Richard Jones <richard@users.sourceforge.net>
parents:
264
diff
changeset
|
731 # . Incorrectly had a Bizar Software copyright on the cgitb.py module from |
|
a4241ddd22d7
Added the Password property type.
Richard Jones <richard@users.sourceforge.net>
parents:
264
diff
changeset
|
732 # Ping - has been removed. |
|
a4241ddd22d7
Added the Password property type.
Richard Jones <richard@users.sourceforge.net>
parents:
264
diff
changeset
|
733 # . Fixed a whole bunch of places in the CGI interface where we should have |
|
a4241ddd22d7
Added the Password property type.
Richard Jones <richard@users.sourceforge.net>
parents:
264
diff
changeset
|
734 # been returning Not Found instead of throwing an exception. |
|
a4241ddd22d7
Added the Password property type.
Richard Jones <richard@users.sourceforge.net>
parents:
264
diff
changeset
|
735 # . Fixed a deviation from the spec: trying to modify the 'id' property of |
|
a4241ddd22d7
Added the Password property type.
Richard Jones <richard@users.sourceforge.net>
parents:
264
diff
changeset
|
736 # an item now throws an exception. |
|
a4241ddd22d7
Added the Password property type.
Richard Jones <richard@users.sourceforge.net>
parents:
264
diff
changeset
|
737 # |
|
264
a671e5917b33
Many features and fixes.
Richard Jones <richard@users.sourceforge.net>
parents:
262
diff
changeset
|
738 # Revision 1.20 2001/10/04 02:12:42 richard |
|
a671e5917b33
Many features and fixes.
Richard Jones <richard@users.sourceforge.net>
parents:
262
diff
changeset
|
739 # Added nicer command-line item adding: passing no arguments will enter an |
|
a671e5917b33
Many features and fixes.
Richard Jones <richard@users.sourceforge.net>
parents:
262
diff
changeset
|
740 # interactive more which asks for each property in turn. While I was at it, I |
|
a671e5917b33
Many features and fixes.
Richard Jones <richard@users.sourceforge.net>
parents:
262
diff
changeset
|
741 # fixed an implementation problem WRT the spec - I wasn't raising a |
|
a671e5917b33
Many features and fixes.
Richard Jones <richard@users.sourceforge.net>
parents:
262
diff
changeset
|
742 # ValueError if the key property was missing from a create(). Also added a |
|
a671e5917b33
Many features and fixes.
Richard Jones <richard@users.sourceforge.net>
parents:
262
diff
changeset
|
743 # protected=boolean argument to getprops() so we can list only the mutable |
|
a671e5917b33
Many features and fixes.
Richard Jones <richard@users.sourceforge.net>
parents:
262
diff
changeset
|
744 # properties (defaults to yes, which lists the immutables). |
|
a671e5917b33
Many features and fixes.
Richard Jones <richard@users.sourceforge.net>
parents:
262
diff
changeset
|
745 # |
|
262
ab921dc53ccd
Added nicer command-line item adding:
Richard Jones <richard@users.sourceforge.net>
parents:
261
diff
changeset
|
746 # Revision 1.19 2001/10/01 06:40:43 richard |
|
ab921dc53ccd
Added nicer command-line item adding:
Richard Jones <richard@users.sourceforge.net>
parents:
261
diff
changeset
|
747 # made do_get have the args in the correct order |
|
ab921dc53ccd
Added nicer command-line item adding:
Richard Jones <richard@users.sourceforge.net>
parents:
261
diff
changeset
|
748 # |
|
261
0ca5381a72b5
made do_get have the args in the correct order
Richard Jones <richard@users.sourceforge.net>
parents:
248
diff
changeset
|
749 # Revision 1.18 2001/09/18 22:58:37 richard |
|
0ca5381a72b5
made do_get have the args in the correct order
Richard Jones <richard@users.sourceforge.net>
parents:
248
diff
changeset
|
750 # |
|
0ca5381a72b5
made do_get have the args in the correct order
Richard Jones <richard@users.sourceforge.net>
parents:
248
diff
changeset
|
751 # Added some more help to roundu-admin |
|
0ca5381a72b5
made do_get have the args in the correct order
Richard Jones <richard@users.sourceforge.net>
parents:
248
diff
changeset
|
752 # |
|
248
96cdd8ef0581
Added some more help to roundup-admin
Richard Jones <richard@users.sourceforge.net>
parents:
235
diff
changeset
|
753 # Revision 1.17 2001/08/28 05:58:33 anthonybaxter |
|
96cdd8ef0581
Added some more help to roundup-admin
Richard Jones <richard@users.sourceforge.net>
parents:
235
diff
changeset
|
754 # added missing 'import' statements. |
|
96cdd8ef0581
Added some more help to roundup-admin
Richard Jones <richard@users.sourceforge.net>
parents:
235
diff
changeset
|
755 # |
|
235
d7d358408537
added missing 'import' statements.
Anthony Baxter <anthonybaxter@users.sourceforge.net>
parents:
224
diff
changeset
|
756 # Revision 1.16 2001/08/12 06:32:36 richard |
|
d7d358408537
added missing 'import' statements.
Anthony Baxter <anthonybaxter@users.sourceforge.net>
parents:
224
diff
changeset
|
757 # using isinstance(blah, Foo) now instead of isFooType |
|
d7d358408537
added missing 'import' statements.
Anthony Baxter <anthonybaxter@users.sourceforge.net>
parents:
224
diff
changeset
|
758 # |
|
224
ad2c98faec97
using isinstance(blah, Foo) now instead of isFooType
Richard Jones <richard@users.sourceforge.net>
parents:
214
diff
changeset
|
759 # Revision 1.15 2001/08/07 00:24:42 richard |
|
ad2c98faec97
using isinstance(blah, Foo) now instead of isFooType
Richard Jones <richard@users.sourceforge.net>
parents:
214
diff
changeset
|
760 # stupid typo |
|
ad2c98faec97
using isinstance(blah, Foo) now instead of isFooType
Richard Jones <richard@users.sourceforge.net>
parents:
214
diff
changeset
|
761 # |
| 214 | 762 # Revision 1.14 2001/08/07 00:15:51 richard |
| 763 # Added the copyright/license notice to (nearly) all files at request of | |
| 764 # Bizar Software. | |
| 765 # | |
|
213
d45384bc6420
Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents:
204
diff
changeset
|
766 # Revision 1.13 2001/08/05 07:44:13 richard |
|
d45384bc6420
Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents:
204
diff
changeset
|
767 # Instances are now opened by a special function that generates a unique |
|
d45384bc6420
Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents:
204
diff
changeset
|
768 # module name for the instances on import time. |
|
d45384bc6420
Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents:
204
diff
changeset
|
769 # |
|
204
c1461733cbf9
Instances are now opened by a special function...
Richard Jones <richard@users.sourceforge.net>
parents:
193
diff
changeset
|
770 # Revision 1.12 2001/08/03 01:28:33 richard |
|
c1461733cbf9
Instances are now opened by a special function...
Richard Jones <richard@users.sourceforge.net>
parents:
193
diff
changeset
|
771 # Used the much nicer load_package, pointed out by Steve Majewski. |
|
c1461733cbf9
Instances are now opened by a special function...
Richard Jones <richard@users.sourceforge.net>
parents:
193
diff
changeset
|
772 # |
|
193
241a0323aacb
Used the much nicer load_package, pointed out by Steve Majewski.
Richard Jones <richard@users.sourceforge.net>
parents:
190
diff
changeset
|
773 # Revision 1.11 2001/08/03 00:59:34 richard |
|
241a0323aacb
Used the much nicer load_package, pointed out by Steve Majewski.
Richard Jones <richard@users.sourceforge.net>
parents:
190
diff
changeset
|
774 # Instance import now imports the instance using imp.load_module so that |
|
241a0323aacb
Used the much nicer load_package, pointed out by Steve Majewski.
Richard Jones <richard@users.sourceforge.net>
parents:
190
diff
changeset
|
775 # we can have instance homes of "roundup" or other existing python package |
|
241a0323aacb
Used the much nicer load_package, pointed out by Steve Majewski.
Richard Jones <richard@users.sourceforge.net>
parents:
190
diff
changeset
|
776 # names. |
|
241a0323aacb
Used the much nicer load_package, pointed out by Steve Majewski.
Richard Jones <richard@users.sourceforge.net>
parents:
190
diff
changeset
|
777 # |
|
190
996eaf90c01e
Instance import now imports the instance using imp.load_module...
Richard Jones <richard@users.sourceforge.net>
parents:
167
diff
changeset
|
778 # Revision 1.10 2001/07/30 08:12:17 richard |
|
996eaf90c01e
Instance import now imports the instance using imp.load_module...
Richard Jones <richard@users.sourceforge.net>
parents:
167
diff
changeset
|
779 # Added time logging and file uploading to the templates. |
|
996eaf90c01e
Instance import now imports the instance using imp.load_module...
Richard Jones <richard@users.sourceforge.net>
parents:
167
diff
changeset
|
780 # |
|
167
a49c8a2ddd26
Added time logging and file uploading to the templates.
Richard Jones <richard@users.sourceforge.net>
parents:
160
diff
changeset
|
781 # Revision 1.9 2001/07/30 03:52:55 richard |
|
a49c8a2ddd26
Added time logging and file uploading to the templates.
Richard Jones <richard@users.sourceforge.net>
parents:
160
diff
changeset
|
782 # init help now lists templates and backends |
|
a49c8a2ddd26
Added time logging and file uploading to the templates.
Richard Jones <richard@users.sourceforge.net>
parents:
160
diff
changeset
|
783 # |
|
160
002249ffa5d0
init help now lists templates and backends
Richard Jones <richard@users.sourceforge.net>
parents:
153
diff
changeset
|
784 # Revision 1.8 2001/07/30 02:37:07 richard |
|
002249ffa5d0
init help now lists templates and backends
Richard Jones <richard@users.sourceforge.net>
parents:
153
diff
changeset
|
785 # Freshen is really broken. Commented out. |
|
002249ffa5d0
init help now lists templates and backends
Richard Jones <richard@users.sourceforge.net>
parents:
153
diff
changeset
|
786 # |
|
153
b07b9a5b6aa9
Freshen is really broken. Commented out.
Richard Jones <richard@users.sourceforge.net>
parents:
147
diff
changeset
|
787 # Revision 1.7 2001/07/30 01:28:46 richard |
|
b07b9a5b6aa9
Freshen is really broken. Commented out.
Richard Jones <richard@users.sourceforge.net>
parents:
147
diff
changeset
|
788 # Bugfixes |
|
b07b9a5b6aa9
Freshen is really broken. Commented out.
Richard Jones <richard@users.sourceforge.net>
parents:
147
diff
changeset
|
789 # |
| 147 | 790 # Revision 1.6 2001/07/30 00:57:51 richard |
| 791 # Now uses getopt, much improved command-line parsing. Much fuller help. Much | |
| 792 # better internal structure. It's just BETTER. :) | |
| 793 # | |
|
140
a4383d62a407
Now uses getopt, much improved command-line parsing.
Richard Jones <richard@users.sourceforge.net>
parents:
137
diff
changeset
|
794 # Revision 1.5 2001/07/30 00:04:48 richard |
|
a4383d62a407
Now uses getopt, much improved command-line parsing.
Richard Jones <richard@users.sourceforge.net>
parents:
137
diff
changeset
|
795 # Made the "init" prompting more friendly. |
|
a4383d62a407
Now uses getopt, much improved command-line parsing.
Richard Jones <richard@users.sourceforge.net>
parents:
137
diff
changeset
|
796 # |
|
137
4a87e0b0d3f7
Made the "init" prompting more friendly.
Richard Jones <richard@users.sourceforge.net>
parents:
127
diff
changeset
|
797 # Revision 1.4 2001/07/29 07:01:39 richard |
|
4a87e0b0d3f7
Made the "init" prompting more friendly.
Richard Jones <richard@users.sourceforge.net>
parents:
127
diff
changeset
|
798 # Added vim command to all source so that we don't get no steenkin' tabs :) |
|
4a87e0b0d3f7
Made the "init" prompting more friendly.
Richard Jones <richard@users.sourceforge.net>
parents:
127
diff
changeset
|
799 # |
|
127
0791d13baea7
Added vim command to all source so that we don't get no steenkin' tabs :)
Richard Jones <richard@users.sourceforge.net>
parents:
51
diff
changeset
|
800 # Revision 1.3 2001/07/23 08:45:28 richard |
|
0791d13baea7
Added vim command to all source so that we don't get no steenkin' tabs :)
Richard Jones <richard@users.sourceforge.net>
parents:
51
diff
changeset
|
801 # ok, so now "./roundup-admin init" will ask questions in an attempt to get a |
|
0791d13baea7
Added vim command to all source so that we don't get no steenkin' tabs :)
Richard Jones <richard@users.sourceforge.net>
parents:
51
diff
changeset
|
802 # workable instance_home set up :) |
|
0791d13baea7
Added vim command to all source so that we don't get no steenkin' tabs :)
Richard Jones <richard@users.sourceforge.net>
parents:
51
diff
changeset
|
803 # _and_ anydbm has had its first test :) |
|
0791d13baea7
Added vim command to all source so that we don't get no steenkin' tabs :)
Richard Jones <richard@users.sourceforge.net>
parents:
51
diff
changeset
|
804 # |
|
51
3a7e5515c1bd
ok, so now "./roundup-admin init" will ask questions...
Richard Jones <richard@users.sourceforge.net>
parents:
48
diff
changeset
|
805 # Revision 1.2 2001/07/23 08:20:44 richard |
|
3a7e5515c1bd
ok, so now "./roundup-admin init" will ask questions...
Richard Jones <richard@users.sourceforge.net>
parents:
48
diff
changeset
|
806 # Moved over to using marshal in the bsddb and anydbm backends. |
|
3a7e5515c1bd
ok, so now "./roundup-admin init" will ask questions...
Richard Jones <richard@users.sourceforge.net>
parents:
48
diff
changeset
|
807 # roundup-admin now has a "freshen" command that'll load/save all nodes (not |
|
3a7e5515c1bd
ok, so now "./roundup-admin init" will ask questions...
Richard Jones <richard@users.sourceforge.net>
parents:
48
diff
changeset
|
808 # retired - mod hyperdb.Class.list() so it lists retired nodes) |
|
3a7e5515c1bd
ok, so now "./roundup-admin init" will ask questions...
Richard Jones <richard@users.sourceforge.net>
parents:
48
diff
changeset
|
809 # |
|
48
671203878652
Moved over to using marshal in the bsddb and anydbm backends.
Richard Jones <richard@users.sourceforge.net>
parents:
27
diff
changeset
|
810 # Revision 1.1 2001/07/23 03:46:48 richard |
|
671203878652
Moved over to using marshal in the bsddb and anydbm backends.
Richard Jones <richard@users.sourceforge.net>
parents:
27
diff
changeset
|
811 # moving the bin files to facilitate out-of-the-boxness |
|
671203878652
Moved over to using marshal in the bsddb and anydbm backends.
Richard Jones <richard@users.sourceforge.net>
parents:
27
diff
changeset
|
812 # |
|
27
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
813 # Revision 1.1 2001/07/22 11:15:45 richard |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
814 # More Grande Splite stuff |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
815 # |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
816 # |
|
127
0791d13baea7
Added vim command to all source so that we don't get no steenkin' tabs :)
Richard Jones <richard@users.sourceforge.net>
parents:
51
diff
changeset
|
817 # vim: set filetype=python ts=4 sw=4 et si |
