Mercurial > p > roundup > code
comparison roundup/admin.py @ 2184:d04ef0543c76
roundup-admin install checks for existing tracker in target home
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Mon, 05 Apr 2004 06:24:06 +0000 |
| parents | e1a481838a32 |
| children | 3f89c8ffe4f1 |
comparison
equal
deleted
inserted
replaced
| 2183:ac24a9c74cca | 2184:d04ef0543c76 |
|---|---|
| 14 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | 14 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
| 15 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" | 15 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" |
| 16 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, | 16 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, |
| 17 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. | 17 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. |
| 18 # | 18 # |
| 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 $ |
| 20 | 20 |
| 21 '''Administration commands for maintaining Roundup trackers. | 21 '''Administration commands for maintaining Roundup trackers. |
| 22 ''' | 22 ''' |
| 23 __docformat__ = 'restructuredtext' | 23 __docformat__ = 'restructuredtext' |
| 24 | 24 |
| 354 ''' | 354 ''' |
| 355 if len(args) < 1: | 355 if len(args) < 1: |
| 356 raise UsageError, _('Not enough arguments supplied') | 356 raise UsageError, _('Not enough arguments supplied') |
| 357 | 357 |
| 358 # make sure the tracker home can be created | 358 # make sure the tracker home can be created |
| 359 tracker_home = os.path.abspath(tracker_home) | |
| 359 parent = os.path.split(tracker_home)[0] | 360 parent = os.path.split(tracker_home)[0] |
| 360 if not os.path.exists(parent): | 361 if not os.path.exists(parent): |
| 361 raise UsageError, _('Instance home parent directory "%(parent)s"' | 362 raise UsageError, _('Instance home parent directory "%(parent)s"' |
| 362 ' does not exist')%locals() | 363 ' does not exist')%locals() |
| 364 | |
| 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) | |
| 363 | 375 |
| 364 # select template | 376 # select template |
| 365 templates = self.listTemplates() | 377 templates = self.listTemplates() |
| 366 template = len(args) > 1 and args[1] or '' | 378 template = len(args) > 1 and args[1] or '' |
| 367 if not templates.has_key(template): | 379 if not templates.has_key(template): |
| 437 # TODO: move this code to exists() static method in every backend | 449 # TODO: move this code to exists() static method in every backend |
| 438 db_exists = os.path.exists(os.path.join(tracker_home, 'db')) | 450 db_exists = os.path.exists(os.path.join(tracker_home, 'db')) |
| 439 if db_exists: | 451 if db_exists: |
| 440 print _('WARNING: The database is already initialised!') | 452 print _('WARNING: The database is already initialised!') |
| 441 print _('If you re-initialise it, you will lose all the data!') | 453 print _('If you re-initialise it, you will lose all the data!') |
| 442 ok = raw_input(_('Erase it? Y/[N]: ')).strip() | 454 ok = raw_input(_('Erase it? Y/N: ')).strip() |
| 443 if ok.lower() != 'y': | 455 if ok.strip().lower() != 'y': |
| 444 return 0 | 456 return 0 |
| 445 | 457 |
| 446 # Get a database backend in use by tracker | 458 # Get a database backend in use by tracker |
| 447 try: | 459 try: |
| 448 # nuke it | 460 # nuke it |
