Mercurial > p > roundup > code
comparison roundup/admin.py @ 6557:8687c096a945
Handle configparser.InterpolationSyntaxError
Under Python 3, an option value with a single % (e.g. this % is a
test) throws
configparser.InterpolationSyntaxError: '%' must be followed by
'%' or '(', found: '%s))'
Added code to capture this, raise a different exception. roundup-admin
handles the error and exits cleanly. Other code shows the traceback.
The new error message reports the file, section and option causing the
problem to allow easier repair.
Also updated roundup translations and added tests.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Mon, 13 Dec 2021 12:48:57 -0500 |
| parents | 5ad7fb912227 |
| children | d4371b131c9c |
comparison
equal
deleted
inserted
replaced
| 6556:d92e0d059c3a | 6557:8687c096a945 |
|---|---|
| 26 import csv, getopt, getpass, os, re, shutil, sys, operator | 26 import csv, getopt, getpass, os, re, shutil, sys, operator |
| 27 | 27 |
| 28 from roundup import date, hyperdb, init, password, token | 28 from roundup import date, hyperdb, init, password, token |
| 29 from roundup import __version__ as roundup_version | 29 from roundup import __version__ as roundup_version |
| 30 import roundup.instance | 30 import roundup.instance |
| 31 from roundup.configuration import CoreConfig, NoConfigError, UserConfig | 31 from roundup.configuration import (CoreConfig, NoConfigError, |
| 32 ParsingOptionError, UserConfig) | |
| 32 from roundup.i18n import _ | 33 from roundup.i18n import _ |
| 33 from roundup.exceptions import UsageError | 34 from roundup.exceptions import UsageError |
| 34 from roundup.anypy.my_input import my_input | 35 from roundup.anypy.my_input import my_input |
| 35 from roundup.anypy.strings import repr_export | 36 from roundup.anypy.strings import repr_export |
| 36 | 37 |
| 1705 return 1 | 1706 return 1 |
| 1706 except NoConfigError as message: # noqa: F841 | 1707 except NoConfigError as message: # noqa: F841 |
| 1707 self.tracker_home = '' | 1708 self.tracker_home = '' |
| 1708 print(_("Error: Couldn't open tracker: %(message)s") % locals()) | 1709 print(_("Error: Couldn't open tracker: %(message)s") % locals()) |
| 1709 return 1 | 1710 return 1 |
| 1711 except ParsingOptionError as message: | |
| 1712 print("%(message)s" % locals()) | |
| 1713 return 1 | |
| 1710 | 1714 |
| 1711 # only open the database once! | 1715 # only open the database once! |
| 1712 if not self.db: | 1716 if not self.db: |
| 1713 self.db = tracker.open(self.name) | 1717 self.db = tracker.open(self.name) |
| 1714 | 1718 |
