comparison roundup/admin.py @ 7076:d3d20e145cea

bug: cleaner error message on OptionUnsetError in initialize We got a scary traceback when a: roundup.configuration.OptionUnsetError exception was raised during tracker.init(). Capture the exception and raise a UsageError that is printed more cleanly. It now reads: Error: In tracker/config.ini - MAIL_DOMAIN is not set and has no default
author John Rouillard <rouilj@ieee.org>
date Thu, 24 Nov 2022 20:57:17 -0500
parents 3211745e8d7c
children 537b24c593af
comparison
equal deleted inserted replaced
7075:739b9f017d2c 7076:d3d20e145cea
33 import sys 33 import sys
34 34
35 from roundup import date, hyperdb, init, password, token 35 from roundup import date, hyperdb, init, password, token
36 from roundup import __version__ as roundup_version 36 from roundup import __version__ as roundup_version
37 import roundup.instance 37 import roundup.instance
38 from roundup.configuration import (CoreConfig, NoConfigError, 38 from roundup.configuration import (CoreConfig, NoConfigError, OptionUnsetError,
39 ParsingOptionError, UserConfig) 39 ParsingOptionError, UserConfig)
40 from roundup.i18n import _, get_translation 40 from roundup.i18n import _, get_translation
41 from roundup.exceptions import UsageError 41 from roundup.exceptions import UsageError
42 from roundup.anypy.my_input import my_input 42 from roundup.anypy.my_input import my_input
43 from roundup.anypy.strings import repr_export 43 from roundup.anypy.strings import repr_export
614 614
615 # nuke it 615 # nuke it
616 tracker.nuke() 616 tracker.nuke()
617 617
618 # GO 618 # GO
619 tracker.init(password.Password(adminpw, config=tracker.config), 619 try:
620 tx_Source='cli') 620 tracker.init(password.Password(adminpw, config=tracker.config),
621 tx_Source='cli')
622 except OptionUnsetError as e:
623 raise UsageError("In %(tracker_home)s/config.ini - %(error)s" % {
624 'error': str(e), 'tracker_home': tracker_home })
621 625
622 return 0 626 return 0
623 627
624 def do_get(self, args): 628 def do_get(self, args):
625 ''"""Usage: get property designator[,designator]* 629 ''"""Usage: get property designator[,designator]*

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