Mercurial > p > roundup > code
comparison roundup/admin.py @ 7847:d523d5c648e9
feat: add Progress output for admin export/exporttables
This provides feedback on how far along the export is.
Detailed per node output with -V (for use when identifying exactly
what node is hanging the output) is kind of ugly when used with
Progress. But it's functional and not the expected operation mode.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Sat, 30 Mar 2024 23:29:02 -0400 |
| parents | b530069f3120 |
| children | 9a74dfeb8620 |
comparison
equal
deleted
inserted
replaced
| 7846:8ef97f7cfb6d | 7847:d523d5c648e9 |
|---|---|
| 45 ParsingOptionError, | 45 ParsingOptionError, |
| 46 UserConfig, | 46 UserConfig, |
| 47 ) | 47 ) |
| 48 from roundup.exceptions import UsageError | 48 from roundup.exceptions import UsageError |
| 49 from roundup.i18n import _, get_translation | 49 from roundup.i18n import _, get_translation |
| 50 from roundup import support | |
| 50 | 51 |
| 51 try: | 52 try: |
| 52 from UserDict import UserDict | 53 from UserDict import UserDict |
| 53 except ImportError: | 54 except ImportError: |
| 54 from collections import UserDict | 55 from collections import UserDict |
| 651 not cl.is_retired(i), # noqa: B023 cl is not loop var | 652 not cl.is_retired(i), # noqa: B023 cl is not loop var |
| 652 ) | 653 ) |
| 653 all_nodes.sort(key=keysort) | 654 all_nodes.sort(key=keysort) |
| 654 # if there is no classkey no need to sort | 655 # if there is no classkey no need to sort |
| 655 | 656 |
| 656 for nodeid in all_nodes: | 657 for nodeid in support.Progress( "Exporting %s" % |
| 658 classname, all_nodes): | |
| 657 if self.verbose: | 659 if self.verbose: |
| 658 sys.stdout.write('\rExporting %s - %s' % | 660 sys.stdout.write('\rExporting %s - %s ' % |
| 659 (classname, nodeid)) | 661 (classname, nodeid)) |
| 660 sys.stdout.flush() | 662 sys.stdout.flush() |
| 661 node = cl.getnode(nodeid) | 663 node = cl.getnode(nodeid) |
| 662 exp = cl.export_list(propnames, nodeid) | 664 exp = cl.export_list(propnames, nodeid) |
| 663 lensum = sum([len(repr_export(node[p])) for | 665 lensum = sum([len(repr_export(node[p])) for |
| 681 if self.verbose: | 683 if self.verbose: |
| 682 sys.stdout.write("\nExporting Journal for %s\n" % | 684 sys.stdout.write("\nExporting Journal for %s\n" % |
| 683 classname) | 685 classname) |
| 684 sys.stdout.flush() | 686 sys.stdout.flush() |
| 685 journals = csv.writer(jf, colon_separated) | 687 journals = csv.writer(jf, colon_separated) |
| 686 for row in cl.export_journals(): | 688 for row in support.Progress(" Writing journals", |
| 689 cl.export_journals()): | |
| 687 journals.writerow(row) | 690 journals.writerow(row) |
| 688 if max_len > self.db.config.CSV_FIELD_SIZE: | 691 if max_len > self.db.config.CSV_FIELD_SIZE: |
| 689 print("Warning: config csv_field_size should be at least %s" % | 692 print("Warning: config csv_field_size should be at least %s" % |
| 690 max_len, file=sys.stderr) | 693 max_len, file=sys.stderr) |
| 691 return 0 | 694 return 0 |
| 1759 reindex issue:23-1000 | 1762 reindex issue:23-1000 |
| 1760 | 1763 |
| 1761 to reindex issue class items 23-1000. Missing items | 1764 to reindex issue class items 23-1000. Missing items |
| 1762 are reported but do not stop indexing of the range. | 1765 are reported but do not stop indexing of the range. |
| 1763 """ | 1766 """ |
| 1764 from roundup import support | |
| 1765 if args: | 1767 if args: |
| 1766 for arg in args: | 1768 for arg in args: |
| 1767 m = desre.match(arg) | 1769 m = desre.match(arg) |
| 1768 r = desrng.match(arg) | 1770 r = desrng.match(arg) |
| 1769 if m: | 1771 if m: |
