Mercurial > p > roundup > code
comparison roundup/admin.py @ 7228:07ce4e4110f5
flake8 fixes: whitespace, remove unused imports
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Sat, 18 Mar 2023 14:16:31 -0400 |
| parents | c1227f883177 |
| children | bd2dc1484b39 |
comparison
equal
deleted
inserted
replaced
| 7227:1e004afe87bb | 7228:07ce4e4110f5 |
|---|---|
| 651 try: | 651 try: |
| 652 tracker.init(password.Password(adminpw, config=tracker.config), | 652 tracker.init(password.Password(adminpw, config=tracker.config), |
| 653 tx_Source='cli') | 653 tx_Source='cli') |
| 654 except OptionUnsetError as e: | 654 except OptionUnsetError as e: |
| 655 raise UsageError("In %(tracker_home)s/config.ini - %(error)s" % { | 655 raise UsageError("In %(tracker_home)s/config.ini - %(error)s" % { |
| 656 'error': str(e), 'tracker_home': tracker_home }) | 656 'error': str(e), 'tracker_home': tracker_home}) |
| 657 | 657 |
| 658 return 0 | 658 return 0 |
| 659 | 659 |
| 660 def do_get(self, args): | 660 def do_get(self, args): |
| 661 ''"""Usage: get property designator[,designator]* | 661 ''"""Usage: get property designator[,designator]* |
| 1737 | 1737 |
| 1738 It's safe to run this even if it's not required, so just get | 1738 It's safe to run this even if it's not required, so just get |
| 1739 into the habit. | 1739 into the habit. |
| 1740 """ | 1740 """ |
| 1741 if self.db.db_version_updated: | 1741 if self.db.db_version_updated: |
| 1742 print(_('Tracker updated to schema version %s.') % | 1742 print(_('Tracker updated to schema version %s.') % |
| 1743 self.db.database_schema['version']) | 1743 self.db.database_schema['version']) |
| 1744 self.db_uncommitted = True | 1744 self.db_uncommitted = True |
| 1745 else: | 1745 else: |
| 1746 print(_('No migration action required. At schema version %s.') % | 1746 print(_('No migration action required. At schema version %s.') % |
| 1747 self.db.database_schema['version']) | 1747 self.db.database_schema['version']) |
| 1748 return 0 | 1748 return 0 |
| 1749 | 1749 |
| 1750 def do_perftest(self, args): | 1750 def do_perftest(self, args): |
| 1751 ''"""Usage: perftest [mode] [arguments]* | 1751 ''"""Usage: perftest [mode] [arguments]* |
| 1752 | 1752 |
| 1761 coded into Roundup. List supported schemes by using 'scheme='. | 1761 coded into Roundup. List supported schemes by using 'scheme='. |
| 1762 | 1762 |
| 1763 """ | 1763 """ |
| 1764 from roundup.anypy.time_ import perf_counter | 1764 from roundup.anypy.time_ import perf_counter |
| 1765 | 1765 |
| 1766 props = { "rounds": self.db.config.PASSWORD_PBKDF2_DEFAULT_ROUNDS, | 1766 props = {"rounds": self.db.config.PASSWORD_PBKDF2_DEFAULT_ROUNDS, |
| 1767 "scheme": password.Password.known_schemes[0] | 1767 "scheme": password.Password.known_schemes[0]} |
| 1768 } | |
| 1769 | 1768 |
| 1770 print_supported_schemes = lambda: print( | 1769 print_supported_schemes = lambda: print( |
| 1771 "Supported schemes (default is first, case " | 1770 "Supported schemes (default is first, case " |
| 1772 "sensitive):\n %s." % | 1771 "sensitive):\n %s." % |
| 1773 ", ".join(password.Password.known_schemes)) | 1772 ", ".join(password.Password.known_schemes)) |
| 1774 | 1773 |
| 1775 if (args[0].find("=") != -1): | 1774 if (args[0].find("=") != -1): |
| 1776 args.insert(0, 'password') | 1775 args.insert(0, 'password') |
| 1777 | 1776 |
| 1778 props.update(self.props_from_args(args[1:])) | 1777 props.update(self.props_from_args(args[1:])) |
| 1779 | 1778 |
| 1780 if args[0] == "password": | 1779 if args[0] == "password": |
| 1781 try: | 1780 try: |
| 1782 # convert 10,000,000 or 10.000.000 to 10000000 | 1781 # convert 10,000,000 or 10.000.000 to 10000000 |
| 1783 r = int(re.sub('[,.]','',props['rounds'])) | 1782 r = int(re.sub('[,.]', '', props['rounds'])) |
| 1784 if r < 1000: | 1783 if r < 1000: |
| 1785 print(_("Invalid 'rounds'. Must be larger than 999.")) | 1784 print(_("Invalid 'rounds'. Must be larger than 999.")) |
| 1786 return | 1785 return |
| 1787 props['rounds'] = r | 1786 props['rounds'] = r |
| 1788 except (TypeError, ValueError): | 1787 except (TypeError, ValueError): |
| 1789 print(_("Invalid 'rounds'. It must be an integer not: %s") % | 1788 print(_("Invalid 'rounds'. It must be an integer not: %s") % |
| 1790 props['rounds']) | 1789 props['rounds']) |
| 1791 return | 1790 return |
| 1792 if props['scheme'] == None: | 1791 if props['scheme'] is None: |
| 1793 print_supported_schemes() | 1792 print_supported_schemes() |
| 1794 return | 1793 return |
| 1795 | 1794 |
| 1796 self.db.config.PASSWORD_PBKDF2_DEFAULT_ROUNDS = props['rounds'] | 1795 self.db.config.PASSWORD_PBKDF2_DEFAULT_ROUNDS = props['rounds'] |
| 1797 | 1796 |
