Mercurial > p > roundup > code
comparison roundup/admin.py @ 8240:1189c742e4b3
fix: crash roundup-admin perftest password without rounds= argument.
If the rounds value is taken from the config file, it doesn't need to
be parsed into an int.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Mon, 30 Dec 2024 02:59:27 -0500 |
| parents | 5913ec1673c2 |
| children | 4d3b371ed543 |
comparison
equal
deleted
inserted
replaced
| 8239:6bd11a73f2ed | 8240:1189c742e4b3 |
|---|---|
| 1631 coded into Roundup. List supported schemes by using 'scheme='. | 1631 coded into Roundup. List supported schemes by using 'scheme='. |
| 1632 | 1632 |
| 1633 """ | 1633 """ |
| 1634 from roundup.anypy.time_ import perf_counter | 1634 from roundup.anypy.time_ import perf_counter |
| 1635 | 1635 |
| 1636 # default rounds from db.config is an int not str | |
| 1636 props = {"rounds": self.db.config.PASSWORD_PBKDF2_DEFAULT_ROUNDS, | 1637 props = {"rounds": self.db.config.PASSWORD_PBKDF2_DEFAULT_ROUNDS, |
| 1637 "scheme": password.Password.default_scheme} | 1638 "scheme": password.Password.default_scheme} |
| 1638 | 1639 |
| 1639 print_supported_schemes = lambda: print( | 1640 print_supported_schemes = lambda: print( |
| 1640 "Supported schemes (default is first, case " | 1641 "Supported schemes (default is first, case " |
| 1647 props.update(self.props_from_args(args[1:])) | 1648 props.update(self.props_from_args(args[1:])) |
| 1648 | 1649 |
| 1649 if args[0] == "password": | 1650 if args[0] == "password": |
| 1650 try: | 1651 try: |
| 1651 # convert 10,000,000 or 10.000.000 to 10000000 | 1652 # convert 10,000,000 or 10.000.000 to 10000000 |
| 1652 r = int(re.sub('[,.]', '', props['rounds'])) | 1653 r = int(re.sub('[,.]', '', props['rounds'])) \ |
| 1654 if not isinstance(props['rounds'], int) \ | |
| 1655 else props['rounds'] | |
| 1653 if r < 1000: | 1656 if r < 1000: |
| 1654 print(_("Invalid 'rounds'. Must be larger than 999.")) | 1657 print(_("Invalid 'rounds'. Must be larger than 999.")) |
| 1655 return | 1658 return |
| 1656 props['rounds'] = r | 1659 props['rounds'] = r |
| 1657 except (TypeError, ValueError): | 1660 except (TypeError, ValueError): |
