X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=roundup-admin;h=6a1d5c078efa1716ccc4a5e9e17d209857a4a983;hb=a25e89b84b3a5dc04adc4450a85424171b3bb7f9;hp=b9cdc9f9a0267eddbd22a7e84ac8e913a910f250;hpb=d8ec5b793387433502aaf703007e6caa9786d577;p=roundup.git diff --git a/roundup-admin b/roundup-admin index b9cdc9f..6a1d5c0 100755 --- a/roundup-admin +++ b/roundup-admin @@ -16,14 +16,12 @@ # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. # -# $Id: roundup-admin,v 1.51 2001-12-10 00:57:38 richard Exp $ +# $Id: roundup-admin,v 1.55 2001-12-17 03:52:47 richard Exp $ -import sys -if not hasattr(sys, 'version_info') or sys.version_info[:2] < (2,1): - print 'Roundup requires python 2.1 or later.' - sys.exit(1) +# python version check +from roundup import version_check -import string, os, getpass, getopt, re, UserDict +import sys, os, getpass, getopt, re, UserDict try: import csv except ImportError: @@ -95,6 +93,28 @@ Options: print '\n'.join(commands) print + def help_commands_html(self, indent_re=re.compile(r'^(\s+)\S+')): + commands = self.commands.values() + def sortfun(a, b): + return cmp(a.__name__, b.__name__) + commands.sort(sortfun) + for command in commands: + h = command.__doc__.split('\n') + name = command.__name__[3:] + usage = h[0] + print ''' +%(name)s + %(usage)s

+

'''%locals()
+            indent = indent_re.match(h[3])
+            if indent: indent = len(indent.group(1))
+            for line in h[3:]:
+                if indent:
+                    print line[indent:]
+                else:
+                    print line
+            print '
\n' + def help_all(self): print ''' All commands (except help) require an instance specifier. This is just the path @@ -249,7 +269,7 @@ Command help: if len(args) < 2: raise UsageError, 'Not enough arguments supplied' propname = args[0] - designators = string.split(args[1], ',') + designators = args[1].split(',') l = [] for designator in designators: # decode the node designator @@ -288,7 +308,7 @@ Command help: raise UsageError, 'Not enough arguments supplied' from roundup import hyperdb - designators = string.split(args[0], ',') + designators = args[0].split(',') props = {} for prop in args[1:]: if prop.find('=') == -1: @@ -603,6 +623,11 @@ Command help: # figure the property names to display if len(args) > 1: prop_names = args[1].split(',') + all_props = cl.getprops() + for prop_name in prop_names: + if not all_props.has_key(prop_name): + raise UsageError, '%s has no property "%s"'%(classname, + prop_name) else: prop_names = cl.getprops().keys() @@ -619,7 +644,7 @@ Command help: props.append((spec, len(spec))) # now display the heading - print ' '.join([string.capitalize(name) for name, width in props]) + print ' '.join([name.capitalize() for name, width in props]) # and the table data for nodeid in cl.list(): @@ -629,8 +654,10 @@ Command help: try: value = str(cl.get(nodeid, name)) except KeyError: - raise UsageError, '%s has no property "%s"'%(classname, - name) + # we already checked if the property is valid - a + # KeyError here means the node just doesn't have a + # value for it + value = '' else: value = str(nodeid) f = '%%-%ds'%width @@ -695,7 +722,7 @@ Command help: ''' if len(args) < 1: raise UsageError, 'Not enough arguments supplied' - designators = string.split(args[0], ',') + designators = args[0].split(',') for designator in designators: try: classname, nodeid = roundupdb.splitDesignator(designator) @@ -719,7 +746,7 @@ Command help: ''' if len(args) < 2: raise UsageError, 'Not enough arguments supplied' - classes = string.split(args[0], ',') + classes = args[0].split(',') dir = args[1] # use the csv parser if we can - it's faster @@ -733,7 +760,7 @@ Command help: except KeyError: raise UsageError, 'no such class "%s"'%classname f = open(os.path.join(dir, classname+'.csv'), 'w') - f.write(string.join(cl.properties.keys(), ':') + '\n') + f.write(':'.join(cl.properties.keys()) + '\n') # all nodes for this class properties = cl.properties.items() @@ -973,6 +1000,29 @@ if __name__ == '__main__': # # $Log: not supported by cvs2svn $ +# Revision 1.54 2001/12/15 23:09:23 richard +# Some cleanups in roundup-admin, also made it work again... +# +# Revision 1.53 2001/12/13 00:20:00 richard +# . Centralised the python version check code, bumped version to 2.1.1 (really +# needs to be 2.1.2, but that isn't released yet :) +# +# Revision 1.52 2001/12/12 21:47:45 richard +# . Message author's name appears in From: instead of roundup instance name +# (which still appears in the Reply-To:) +# . envelope-from is now set to the roundup-admin and not roundup itself so +# delivery reports aren't sent to roundup (thanks Patrick Ohly) +# +# Revision 1.51 2001/12/10 00:57:38 richard +# From CHANGES: +# . Added the "display" command to the admin tool - displays a node's values +# . #489760 ] [issue] only subject +# . fixed the doc/index.html to include the quoting in the mail alias. +# +# Also: +# . fixed roundup-admin so it works with transactions +# . disabled the back_anydbm module if anydbm tries to use dumbdbm +# # Revision 1.50 2001/12/02 05:06:16 richard # . We now use weakrefs in the Classes to keep the database reference, so # the close() method on the database is no longer needed.