Code

roundup-admin install checks for existing tracker in target home
[roundup.git] / roundup / admin.py
index 0c9fe44aa44dd4866de64eb3fdcf4de5bcd76d9c..57a7a0cfc5b825f6905d00d6dee5d4daf8ab5c37 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.65 2004-04-03 21:32:24 richard Exp $
+# $Id: admin.py,v 1.66 2004-04-05 06:24:06 richard Exp $
 
 '''Administration commands for maintaining Roundup trackers.
 '''
@@ -356,11 +356,23 @@ Command help:
             raise UsageError, _('Not enough arguments supplied')
 
         # make sure the tracker home can be created
+        tracker_home = os.path.abspath(tracker_home)
         parent = os.path.split(tracker_home)[0]
         if not os.path.exists(parent):
             raise UsageError, _('Instance home parent directory "%(parent)s"'
                 ' does not exist')%locals()
 
+        if os.path.exists(os.path.join(tracker_home, 'config.py')):
+            print _('WARNING: There appears to be a tracker in '
+                '"%(tracker_home)s"!')%locals()
+            print _('If you re-install it, you will lose all the data!')
+            ok = raw_input(_('Erase it? Y/N: ')).strip()
+            if ok.strip().lower() != 'y':
+                return 0
+
+            # clear it out so the install isn't confused
+            shutil.rmtree(tracker_home)
+
         # select template
         templates = self.listTemplates()
         template = len(args) > 1 and args[1] or ''
@@ -439,8 +451,8 @@ Command help:
         if db_exists:
             print _('WARNING: The database is already initialised!')
             print _('If you re-initialise it, you will lose all the data!')
-            ok = raw_input(_('Erase it? Y/[N]: ')).strip()
-            if ok.lower() != 'y':
+            ok = raw_input(_('Erase it? Y/N: ')).strip()
+            if ok.strip().lower() != 'y':
                 return 0
 
             # Get a database backend in use by tracker