Skip to content

Commit 651bf11

Browse files
author
Richard Jones
committed
roundup-admin install checks for existing tracker in target home
1 parent cd01e55 commit 651bf11

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

CHANGES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Fixed:
1818
- added "download_url" method to generate a correctly quoted URL for file
1919
download links (sf bug 927745)
2020
- all uses of TRACKER_WEB now ensure it ends with a '/'
21+
- roundup-admin install checks for existing tracker in target home
2122

2223

2324
2004-03-27 0.7.0b2

roundup/admin.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1717
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1818
#
19-
# $Id: admin.py,v 1.65 2004-04-03 21:32:24 richard Exp $
19+
# $Id: admin.py,v 1.66 2004-04-05 06:24:06 richard Exp $
2020

2121
'''Administration commands for maintaining Roundup trackers.
2222
'''
@@ -356,11 +356,23 @@ def do_install(self, tracker_home, args):
356356
raise UsageError, _('Not enough arguments supplied')
357357

358358
# make sure the tracker home can be created
359+
tracker_home = os.path.abspath(tracker_home)
359360
parent = os.path.split(tracker_home)[0]
360361
if not os.path.exists(parent):
361362
raise UsageError, _('Instance home parent directory "%(parent)s"'
362363
' does not exist')%locals()
363364

365+
if os.path.exists(os.path.join(tracker_home, 'config.py')):
366+
print _('WARNING: There appears to be a tracker in '
367+
'"%(tracker_home)s"!')%locals()
368+
print _('If you re-install it, you will lose all the data!')
369+
ok = raw_input(_('Erase it? Y/N: ')).strip()
370+
if ok.strip().lower() != 'y':
371+
return 0
372+
373+
# clear it out so the install isn't confused
374+
shutil.rmtree(tracker_home)
375+
364376
# select template
365377
templates = self.listTemplates()
366378
template = len(args) > 1 and args[1] or ''
@@ -439,8 +451,8 @@ def do_initialise(self, tracker_home, args):
439451
if db_exists:
440452
print _('WARNING: The database is already initialised!')
441453
print _('If you re-initialise it, you will lose all the data!')
442-
ok = raw_input(_('Erase it? Y/[N]: ')).strip()
443-
if ok.lower() != 'y':
454+
ok = raw_input(_('Erase it? Y/N: ')).strip()
455+
if ok.strip().lower() != 'y':
444456
return 0
445457

446458
# Get a database backend in use by tracker

0 commit comments

Comments
 (0)