diff roundup/admin.py @ 5230:62a88d69ac52

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.
author John Rouillard <rouilj@ieee.org>
date Tue, 11 Apr 2017 21:51:28 -0400
parents cb61b7935fec
children 462b0f76fce8
line wrap: on
line diff
--- a/roundup/admin.py	Tue Apr 11 21:49:18 2017 -0400
+++ b/roundup/admin.py	Tue Apr 11 21:51:28 2017 -0400
@@ -26,7 +26,7 @@
 from roundup import date, hyperdb, roundupdb, init, password, token
 from roundup import __version__ as roundup_version
 import roundup.instance
-from roundup.configuration import CoreConfig
+from roundup.configuration import CoreConfig, NoConfigError
 from roundup.i18n import _
 from roundup.exceptions import UsageError
 
@@ -470,16 +470,29 @@
                 return default
         return argument
 
-    def do_genconfig(self, args):
+    def do_genconfig(self, args, update=False):
         ''"""Usage: genconfig <filename>
         Generate a new tracker config file (ini style) with default values
         in <filename>.
         """
         if len(args) < 1:
             raise UsageError(_('Not enough arguments supplied'))
-        config = CoreConfig()
+        if update:
+            # load current config for writing
+            config = CoreConfig(self.tracker_home)
+        else:
+            # generate default config
+            config = CoreConfig()
         config.save(args[0])
 
+    def do_updateconfig(self, args):
+        ''"""Usage: updateconfig <filename>
+        Generate an updated tracker config file (ini style) in
+        <filename>. Use current settings from existing roundup
+        tracker in tracker home.
+        """
+        self.do_genconfig(args, update=True)
+
     def do_initialise(self, tracker_home, args):
         ''"""Usage: initialise [adminpw]
         Initialise a new Roundup tracker.
@@ -1488,6 +1501,10 @@
             self.tracker_home = ''
             print _("Error: Couldn't open tracker: %(message)s")%locals()
             return 1
+        except NoConfigError, message:
+            self.tracker_home = ''
+            print _("Error: Couldn't open tracker: %(message)s")%locals()
+            return 1
 
         # only open the database once!
         if not self.db:

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