comparison roundup/admin.py @ 1434:b953750bdc04

trackers on mysql can be initialised added mechanism for backends to detect and clear database
author Andrey Lebedev <kedder@users.sourceforge.net>
date Sat, 15 Feb 2003 23:19:01 +0000
parents 8dc60d87ab42
children 378081f066cc
comparison
equal deleted inserted replaced
1433:8429095241d7 1434:b953750bdc04
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.36 2003-02-06 05:43:47 richard Exp $ 19 # $Id: admin.py,v 1.37 2003-02-15 23:19:01 kedder Exp $
20 20
21 '''Administration commands for maintaining Roundup trackers. 21 '''Administration commands for maintaining Roundup trackers.
22 ''' 22 '''
23 23
24 import sys, os, getpass, getopt, re, UserDict, shlex, shutil 24 import sys, os, getpass, getopt, re, UserDict, shlex, shutil
366 confirm = getpass.getpass(_(' Confirm: ')) 366 confirm = getpass.getpass(_(' Confirm: '))
367 367
368 # make sure the tracker home is installed 368 # make sure the tracker home is installed
369 if not os.path.exists(tracker_home): 369 if not os.path.exists(tracker_home):
370 raise UsageError, _('Instance home does not exist')%locals() 370 raise UsageError, _('Instance home does not exist')%locals()
371 if not os.path.exists(os.path.join(tracker_home, 'html')): 371 try:
372 tracker = roundup.instance.open(tracker_home)
373 except roundup.instance.TrackerError:
372 raise UsageError, _('Instance has not been installed')%locals() 374 raise UsageError, _('Instance has not been installed')%locals()
373 375
374 # is there already a database? 376 # is there already a database?
375 if os.path.exists(os.path.join(tracker_home, 'db')): 377 try:
378 db_exists = tracker.select_db.Database.exists(tracker.config)
379 except AttributeError:
380 # TODO: move this code to exists() static method in every backend
381 db_exists = os.path.exists(os.path.join(tracker_home, 'db'))
382 if db_exists:
376 print _('WARNING: The database is already initialised!') 383 print _('WARNING: The database is already initialised!')
377 print _('If you re-initialise it, you will lose all the data!') 384 print _('If you re-initialise it, you will lose all the data!')
378 ok = raw_input(_('Erase it? Y/[N]: ')).strip() 385 ok = raw_input(_('Erase it? Y/[N]: ')).strip()
379 if ok.lower() != 'y': 386 if ok.lower() != 'y':
380 return 0 387 return 0
381 388
382 # nuke it 389 # Get a database backend in use by tracker
383 shutil.rmtree(os.path.join(tracker_home, 'db')) 390 try:
391 # nuke it
392 tracker.select_db.Database.nuke(tracker.config)
393 except AttributeError:
394 # TODO: move this code to nuke() static method in every backend
395 shutil.rmtree(os.path.join(tracker_home, 'db'))
384 396
385 # GO 397 # GO
386 init.initialise(tracker_home, adminpw) 398 init.initialise(tracker_home, adminpw)
387 399
388 return 0 400 return 0

Roundup Issue Tracker: http://roundup-tracker.org/