Mercurial > p > roundup > code
comparison roundup/admin.py @ 3637:31c79e3aa600
Fix verbose option for roundup-admin (for import and export)
Fixes [SF#1505645] "Verbose option for import does not work + patch"
| author | Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net> |
|---|---|
| date | Sat, 15 Jul 2006 10:04:32 +0000 |
| parents | 064515f658e8 |
| children | eab067227e81 |
comparison
equal
deleted
inserted
replaced
| 3636:fa7becc62534 | 3637:31c79e3aa600 |
|---|---|
| 14 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | 14 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
| 15 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" | 15 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" |
| 16 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, | 16 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, |
| 17 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. | 17 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. |
| 18 # | 18 # |
| 19 # $Id: admin.py,v 1.99 2006-04-27 03:38:53 richard Exp $ | 19 # $Id: admin.py,v 1.100 2006-07-15 10:04:32 schlatterbeck Exp $ |
| 20 | 20 |
| 21 '''Administration commands for maintaining Roundup trackers. | 21 '''Administration commands for maintaining Roundup trackers. |
| 22 ''' | 22 ''' |
| 23 __docformat__ = 'restructuredtext' | 23 __docformat__ = 'restructuredtext' |
| 24 | 24 |
| 1096 fields.append('is retired') | 1096 fields.append('is retired') |
| 1097 writer.writerow(fields) | 1097 writer.writerow(fields) |
| 1098 | 1098 |
| 1099 # all nodes for this class | 1099 # all nodes for this class |
| 1100 for nodeid in cl.getnodeids(): | 1100 for nodeid in cl.getnodeids(): |
| 1101 if self.verbose: | |
| 1102 sys.stdout.write ('Exporting %s - %d\r'%(classname, nodeid)) | |
| 1103 sys.stdout.flush () | |
| 1101 writer.writerow(cl.export_list(propnames, nodeid)) | 1104 writer.writerow(cl.export_list(propnames, nodeid)) |
| 1102 if hasattr(cl, 'export_files'): | 1105 if hasattr(cl, 'export_files'): |
| 1103 cl.export_files(dir, nodeid) | 1106 cl.export_files(dir, nodeid) |
| 1104 | 1107 |
| 1105 # close this file | 1108 # close this file |
| 1106 f.close() | 1109 f.close() |
| 1107 | 1110 |
| 1108 # export the journals | 1111 # export the journals |
| 1109 jf = open(os.path.join(dir, classname+'-journals.csv'), 'wb') | 1112 jf = open(os.path.join(dir, classname+'-journals.csv'), 'wb') |
| 1113 if self.verbose: | |
| 1114 sys.stdout.write ("\nExporting Journal for %s\n" % classname) | |
| 1115 sys.stdout.flush () | |
| 1110 journals = csv.writer(jf, colon_separated) | 1116 journals = csv.writer(jf, colon_separated) |
| 1111 map(journals.writerow, cl.export_journals()) | 1117 map(journals.writerow, cl.export_journals()) |
| 1112 jf.close() | 1118 jf.close() |
| 1113 return 0 | 1119 return 0 |
| 1114 | 1120 |
| 1160 for n, r in enumerate(reader): | 1166 for n, r in enumerate(reader): |
| 1161 if file_props is None: | 1167 if file_props is None: |
| 1162 file_props = r | 1168 file_props = r |
| 1163 continue | 1169 continue |
| 1164 | 1170 |
| 1165 sys.stdout.write('Importing %s - %d\r'%(classname, n)) | 1171 if self.verbose : |
| 1166 sys.stdout.flush() | 1172 sys.stdout.write('Importing %s - %d\r'%(classname, n)) |
| 1173 sys.stdout.flush() | |
| 1167 | 1174 |
| 1168 # do the import and figure the current highest nodeid | 1175 # do the import and figure the current highest nodeid |
| 1169 nodeid = int(cl.import_list(file_props, r)) | 1176 nodeid = int(cl.import_list(file_props, r)) |
| 1170 if hasattr(cl, 'import_files'): | 1177 if hasattr(cl, 'import_files'): |
| 1171 cl.import_files(dir, nodeid) | 1178 cl.import_files(dir, nodeid) |
| 1397 self.db.commit() | 1404 self.db.commit() |
| 1398 return 0 | 1405 return 0 |
| 1399 | 1406 |
| 1400 def main(self): | 1407 def main(self): |
| 1401 try: | 1408 try: |
| 1402 opts, args = getopt.getopt(sys.argv[1:], 'i:u:hcdsS:v') | 1409 opts, args = getopt.getopt(sys.argv[1:], 'i:u:hcdsS:vV') |
| 1403 except getopt.GetoptError, e: | 1410 except getopt.GetoptError, e: |
| 1404 self.usage(str(e)) | 1411 self.usage(str(e)) |
| 1405 return 1 | 1412 return 1 |
| 1406 | 1413 |
| 1407 # handle command-line args | 1414 # handle command-line args |
