Code

oops
[roundup.git] / roundup / admin.py
index 18c1638a7de2fd5aef8e3726efbd726abddbbf2a..b213c14d70624d8cee19dcd3cfc038ae3694fa89 100644 (file)
@@ -16,7 +16,7 @@
 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
 # 
-# $Id: admin.py,v 1.12 2002-05-26 09:04:42 richard Exp $
+# $Id: admin.py,v 1.18 2002-07-18 11:17:30 gmcm Exp $
 
 import sys, os, getpass, getopt, re, UserDict, shlex, shutil
 try:
@@ -24,6 +24,7 @@ try:
 except ImportError:
     csv = None
 from roundup import date, hyperdb, roundupdb, init, password, token
+from roundup import __version__ as roundup_version
 import roundup.instance
 from roundup.i18n import _
 
@@ -316,7 +317,7 @@ Command help:
 
 
     def do_initialise(self, instance_home, args):
-        '''Usage: initialise [adminpw [adminemail]]
+        '''Usage: initialise [adminpw]
         Initialise a new Roundup instance.
 
         The administrator details will be set at this step.
@@ -324,7 +325,6 @@ Command help:
         Execute the instance's initialisation function dbinit.init()
         '''
         # password
-        print args
         if len(args) > 1:
             adminpw = args[1]
         else:
@@ -334,14 +334,6 @@ Command help:
                 adminpw = getpass.getpass(_('Admin Password: '))
                 confirm = getpass.getpass(_('       Confirm: '))
 
-        # email
-        if len(args) > 2:
-            adminemail = args[2]
-        else:
-            adminemail = ''
-            while not adminemail:
-                adminemail = raw_input(_('   Admin Email: ')).strip()
-
         # make sure the instance home is installed
         if not os.path.exists(instance_home):
             raise UsageError, _('Instance home does not exist')%locals()
@@ -447,6 +439,10 @@ Command help:
                     props[key] = value
                 elif isinstance(proptype, hyperdb.Multilink):
                     props[key] = value.split(',')
+                elif isinstance(proptype, hyperdb.Boolean):
+                    props[key] = value.lower() in ('yes', 'true', 'on', '1')
+                elif isinstance(proptype, hyperdb.Number):
+                    props[key] = int(value)
 
             # try the set
             try:
@@ -619,6 +615,10 @@ Command help:
                 props[propname] = password.Password(value)
             elif isinstance(proptype, hyperdb.Multilink):
                 props[propname] = value.split(',')
+            elif isinstance(proptype, hyperdb.Boolean):
+                props[propname] = value.lower() in ('yes', 'true', 'on', '1')
+            elif isinstance(proptype, hyperdb.Number):
+                props[propname] = int(value)
 
         # check for the key property
         propname = cl.getkey()
@@ -964,14 +964,23 @@ Date format is "YYYY-MM-DD" eg:
             raise ValueError, _('Invalid format')
         m = m.groupdict()
         if m['period']:
-            # TODO: need to fix date module.  one should be able to say
-            # pack_before = date.Date(". - %s"%value)
-            pack_before = date.Date(".") + date.Interval("- %s"%value)
+            pack_before = date.Date(". - %s"%value)
         elif m['date']:
             pack_before = date.Date(value)
         self.db.pack(pack_before)
         return 0
 
+    def do_reindex(self, args):
+        '''Usage: reindex
+        Re-generate an instance's search indexes.
+
+        This will re-generate the search indexes for an instance. This will
+        typically happen automatically.
+        '''
+        self.db.indexer.force_reindex()
+        self.db.reindex()
+        return 0
+
     def run_command(self, args):
         '''Run a single command
         '''
@@ -1054,7 +1063,7 @@ Date format is "YYYY-MM-DD" eg:
     def interactive(self):
         '''Run in an interactive mode
         '''
-        print _('Roundup {version} ready for input.')
+        print _('Roundup %s ready for input.'%roundup_version)
         print _('Type "help" for help.')
         try:
             import readline
@@ -1122,6 +1131,26 @@ if __name__ == '__main__':
 
 #
 # $Log: not supported by cvs2svn $
+# Revision 1.17  2002/07/14 06:05:50  richard
+#  . fixed the date module so that Date(". - 2d") works
+#
+# Revision 1.16  2002/07/09 04:19:09  richard
+# Added reindex command to roundup-admin.
+# Fixed reindex on first access.
+# Also fixed reindexing of entries that change.
+#
+# Revision 1.15  2002/06/17 23:14:44  richard
+# . #569415 ] {version}
+#
+# Revision 1.14  2002/06/11 06:41:50  richard
+# Removed prompt for admin email in initialisation.
+#
+# Revision 1.13  2002/05/30 23:58:14  richard
+# oops
+#
+# Revision 1.12  2002/05/26 09:04:42  richard
+# out by one in the init args
+#
 # Revision 1.11  2002/05/23 01:14:20  richard
 #  . split instance initialisation into two steps, allowing config changes
 #    before the database is initialised.