Skip to content

Commit 1126f31

Browse files
committed
Add new command updateconfig to admin command. This acts like
genconfig but loads the current tracker's config.ini rather than a new default config.
1 parent 38c3896 commit 1126f31

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

roundup/admin.py

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
from roundup import date, hyperdb, roundupdb, init, password, token
2727
from roundup import __version__ as roundup_version
2828
import roundup.instance
29-
from roundup.configuration import CoreConfig
29+
from roundup.configuration import CoreConfig, NoConfigError
3030
from roundup.i18n import _
3131
from roundup.exceptions import UsageError
3232

@@ -470,16 +470,29 @@ def _get_choice(self, list_name, prompt, options, argument, default=None):
470470
return default
471471
return argument
472472

473-
def do_genconfig(self, args):
473+
def do_genconfig(self, args, update=False):
474474
''"""Usage: genconfig <filename>
475475
Generate a new tracker config file (ini style) with default values
476476
in <filename>.
477477
"""
478478
if len(args) < 1:
479479
raise UsageError(_('Not enough arguments supplied'))
480-
config = CoreConfig()
480+
if update:
481+
# load current config for writing
482+
config = CoreConfig(self.tracker_home)
483+
else:
484+
# generate default config
485+
config = CoreConfig()
481486
config.save(args[0])
482487

488+
def do_updateconfig(self, args):
489+
''"""Usage: updateconfig <filename>
490+
Generate an updated tracker config file (ini style) in
491+
<filename>. Use current settings from existing roundup
492+
tracker in tracker home.
493+
"""
494+
self.do_genconfig(args, update=True)
495+
483496
def do_initialise(self, tracker_home, args):
484497
''"""Usage: initialise [adminpw]
485498
Initialise a new Roundup tracker.
@@ -1488,6 +1501,10 @@ def run_command(self, args):
14881501
self.tracker_home = ''
14891502
print _("Error: Couldn't open tracker: %(message)s")%locals()
14901503
return 1
1504+
except NoConfigError, message:
1505+
self.tracker_home = ''
1506+
print _("Error: Couldn't open tracker: %(message)s")%locals()
1507+
return 1
14911508

14921509
# only open the database once!
14931510
if not self.db:

0 commit comments

Comments
 (0)