Mercurial > p > roundup > code
comparison roundup/admin.py @ 7427:36916abe36e9
Handle traceback when OptionValueError raised during init.
Turn it into a UsageError for now. This causes it to report the
failing config option and print the help text for init. Printing the
help text may not be needed, but it works for now.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Mon, 29 May 2023 18:12:50 -0400 |
| parents | 6795bd384115 |
| children | f7dc37df61b7 |
comparison
equal
deleted
inserted
replaced
| 7426:a6d6c728240f | 7427:36916abe36e9 |
|---|---|
| 34 | 34 |
| 35 from roundup import date, hyperdb, init, password, token_r | 35 from roundup import date, hyperdb, init, password, token_r |
| 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, OptionUnsetError, | 38 from roundup.configuration import (CoreConfig, NoConfigError, OptionUnsetError, |
| 39 ParsingOptionError, UserConfig) | 39 OptionValueError, 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 |
| 44 | 44 |
| 1105 raise UsageError(_('Instance home does not exist') % locals()) | 1105 raise UsageError(_('Instance home does not exist') % locals()) |
| 1106 try: | 1106 try: |
| 1107 tracker = roundup.instance.open(tracker_home) | 1107 tracker = roundup.instance.open(tracker_home) |
| 1108 except roundup.instance.TrackerError: | 1108 except roundup.instance.TrackerError: |
| 1109 raise UsageError(_('Instance has not been installed') % locals()) | 1109 raise UsageError(_('Instance has not been installed') % locals()) |
| 1110 except OptionValueError as e: | |
| 1111 raise UsageError(e) | |
| 1110 | 1112 |
| 1111 # is there already a database? | 1113 # is there already a database? |
| 1112 if tracker.exists(): | 1114 if tracker.exists(): |
| 1113 if not self.force: | 1115 if not self.force: |
| 1114 ok = self.my_input(_( | 1116 ok = self.my_input(_( |
