Changeset 4878
- Timestamp:
- 23 Jan 2010, 08:33:21 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
waeup/trunk/src/waeup/utils/batching.py
r4877 r4878 201 201 timedelta, timedelta/(num or 1))) 202 202 fd.write("Processed: %s lines (%s successful/ %s failed)\n" % ( 203 num, num - len(warnings), len(warnings)203 num, num - warnings, warnings 204 204 )) 205 fd.write("-" * 70 + '\n')206 failnum = 1207 for linenum, text in sorted(warnings.items()):208 fd.write("line %s (%s): %s\n" % (failnum, linenum, text))209 failnum += 1210 fd.close()211 205 return 212 206 … … 240 234 failed_writer.writerow(dict([(x,x) for x in failed_headers])) 241 235 242 warnings = dict()243 236 num =0 237 num_warns = 0 244 238 site = grok.getSite() 245 239 for raw_row in reader: … … 249 243 copy.deepcopy(string_row), converters) 250 244 if len(conv_warnings): 251 warnings[num] = ', '.join(conv_warnings)245 num_warns += 1 252 246 self.writeFailedRow(failed_writer, string_row, conv_warnings) 253 #failed_writer.writerow(string_row)254 247 continue 255 248 256 249 if mode == 'create': 257 250 if not self.parentsExist(row, site): 258 warnings[num] = "Not all parents do exist yet. Skipping"251 num_warns += 1 259 252 self.writeFailedRow( 260 253 failed_writer, string_row, … … 262 255 continue 263 256 if self.entryExists(row, site): 264 warnings[num] = 'This object already exists. Skipping.'257 num_warns += 1 265 258 self.writeFailedRow( 266 259 failed_writer, string_row, … … 273 266 elif mode == 'remove': 274 267 if not self.entryExists(row, site): 275 warnings[num] = "Cannot remove: no such entry."268 num_warns += 1 276 269 self.writeFailedRow( 277 270 failed_writer, string_row, … … 282 275 obj = self.getEntry(row, site) 283 276 if obj is None: 284 warnings[num] = "Cannot update: no such entry."277 num_warns += 1 285 278 self.writeFailedRow( 286 279 failed_writer, string_row, … … 296 289 os.rename(failed_path, path) 297 290 failed_path = path 298 self.createLogfile(path, failed_path, num, warnings, mode, user,291 self.createLogfile(path, failed_path, num, num_warns, mode, user, 299 292 timedelta) 300 if len(warnings)== 0:293 if num_warns == 0: 301 294 del failed_writer 302 295 os.unlink(failed_path) 303 return (num, warnings)296 return (num, num_warns) 304 297 305 298 class FacultyProcessor(BatchProcessor):
Note: See TracChangeset for help on using the changeset viewer.