summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: ac03620)
raw | patch | inline | side by side (parent: ac03620)
author | richard <richard@57a73879-2fb5-44c3-a270-3262357dd7e2> | |
Thu, 8 Nov 2001 04:29:59 +0000 (04:29 +0000) | ||
committer | richard <richard@57a73879-2fb5-44c3-a270-3262357dd7e2> | |
Thu, 8 Nov 2001 04:29:59 +0000 (04:29 +0000) |
[thanks Engelbert Gruber for the inspiration]
git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@382 57a73879-2fb5-44c3-a270-3262357dd7e2
git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@382 57a73879-2fb5-44c3-a270-3262357dd7e2
CHANGES.txt | patch | blob | history | |
roundup-admin | patch | blob | history |
diff --git a/CHANGES.txt b/CHANGES.txt
index 2095b52e7124f9452b73bf061e9e001b33718b01..6ed0501d8bf675ef791605b4cc6de25bd18c6c9e 100644 (file)
--- a/CHANGES.txt
+++ b/CHANGES.txt
. Added Structured Text rendering to htmltemplate, thanks Brad Clements.
. Added CGI configuration via env vars (see roundup.cgi for details)
. "roundup.cgi" is now installed to "<python-prefix>/share/roundup/cgi-bin"
+ . roundup-admin now accepts abbreviated commands (eg. l = li = lis = list)
Fixed:
. Fixed a bug in HTMLTemplate changes.
diff --git a/roundup-admin b/roundup-admin
index 8ea917329913e3c944b989b9f62ca58c1c6ebe61..7250e917b7a68d52f1cab3d3bdab488c28d9331d 100755 (executable)
--- a/roundup-admin
+++ b/roundup-admin
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
#
-# $Id: roundup-admin,v 1.38 2001-11-05 23:45:40 richard Exp $
+# $Id: roundup-admin,v 1.39 2001-11-08 04:29:59 richard Exp $
import sys
if int(sys.version[0]) < 2:
print 'Roundup requires python 2.0 or later.'
sys.exit(1)
-import string, os, getpass, getopt, re
+import string, os, getpass, getopt, re, UserDict
try:
import csv
except ImportError:
from roundup import date, hyperdb, roundupdb, init, password
import roundup.instance
+class CommandDict(UserDict.UserDict):
+ '''Simple dictionary that lets us do lookups using partial keys.
+
+ Original code submitted by Engelbert Gruber.
+ '''
+ _marker = []
+ def get(self, key, default=_marker):
+ d = self.data.get(key, default)
+ if d is not default: return [(key, d)]
+ keylist = self.data.keys()
+ keylist.sort()
+ l = []
+ for ki in keylist:
+ if ki.startswith(key):
+ l.append((ki, self.data[ki]))
+ if not l and default is self._marker:
+ raise KeyError, key
+ return l
+
class AdminTool:
def __init__(self):
- self.commands = {}
+ self.commands = CommandDict()
for k in AdminTool.__dict__.keys():
if k[:3] == 'do_':
self.commands[k[3:]] = getattr(self, k)
initopts -- init command options
all -- all available help
'''
- help = self.help.get(args[0], None)
- if help:
- help()
+ topic = args[0]
+
+ # try help_ methods
+ if self.help.has_key(topic):
+ self.help[topic]()
+ return
+
+ # try command docstrings
+ try:
+ l = self.commands.get(topic)
+ except KeyError:
+ print 'Sorry, no help for "%s"'%topic
return
- help = self.commands.get(args[0], None)
- if help:
- # display the help, removing the docsring indent
+
+ # display the help for each match, removing the docsring indent
+ for name, help in l:
lines = nl_re.split(help.__doc__)
print lines[0]
indent = indent_re.match(lines[1])
print line[indent:]
else:
print line
- else:
- print 'Sorry, no help for "%s"'%args[0]
def help_initopts(self):
import roundup.templates
self.help_all()
return 0
+ # figure what the command is
+ try:
+ functions = self.commands.get(command)
+ except KeyError:
+ # not a valid command
+ print 'Unknown command "%s" ("help commands" for a list)'%command
+ return 1
+
+ # check for multiple matches
+ if len(functions) > 1:
+ print 'Multiple commands match "%s": %s'%(command,
+ ', '.join([i[0] for i in functions]))
+ return 1
+ command, function = functions[0]
+
# make sure we have an instance_home
while not self.instance_home:
self.instance_home = raw_input('Enter instance home: ').strip()
if command == 'init':
return self.do_init(self.instance_home, args)
- function = self.commands.get(command, None)
-
- # not a valid command
- if function is None:
- print 'Unknown command "%s" ("help commands" for a list)'%command
- return 1
-
# get the instance
instance = roundup.instance.open(self.instance_home)
self.db = instance.open('admin')
#
# $Log: not supported by cvs2svn $
+# Revision 1.38 2001/11/05 23:45:40 richard
+# Fixed newuser_action so it sets the cookie with the unencrypted password.
+# Also made it present nicer error messages (not tracebacks).
+#
# Revision 1.37 2001/10/23 01:00:18 richard
# Re-enabled login and registration access after lopping them off via
# disabling access for anonymous users.