Changeset 4885
- Timestamp:
- 23 Jan 2010, 18:02:10 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
waeup/trunk/src/waeup/utils/batching.py
r4878 r4885 188 188 189 189 def createLogfile(self, path, fail_path, num, warnings, mode, user, 190 timedelta): 191 """Write a log file. 192 """ 193 failmsg_path = "%s.%s.msg" % (path, mode) 194 fd = open(failmsg_path, 'wb') 195 fd.write("Source: %s\n" % path) 196 fd.write("Mode: %s\n" % mode) 197 fd.write("Date: %s\n" % time.ctime()) 198 fd.write("User: %s\n" % user) 199 fd.write("Failed datasets: %s\n" % fail_path) 200 fd.write("Processing time: %0.3f s (%0.4f s/item)\n" % ( 201 timedelta, timedelta/(num or 1))) 202 fd.write("Processed: %s lines (%s successful/ %s failed)\n" % ( 203 num, num - warnings, warnings 190 timedelta, logger=None): 191 """Write to log file. 192 """ 193 if logger is None: 194 return 195 status = 'OK' 196 if warnings > 0: 197 status = 'FAILED' 198 logger.info("-" * 20) 199 logger.info("%s: Batch processing finished: %s" % (user, status)) 200 logger.info("%s: Source: %s" % (user, path)) 201 logger.info("%s: Mode: %s" % (user, mode)) 202 #logger.info("Date: %s" % time.ctime()) 203 logger.info("%s: User: %s" % (user, user)) 204 if warnings > 0: 205 logger.info("%s: Failed datasets: %s" % (user, fail_path)) 206 logger.info("%s: Processing time: %0.3f s (%0.4f s/item)" % ( 207 user, timedelta, timedelta/(num or 1))) 208 logger.info("%s: Processed: %s lines (%s successful/ %s failed)" % ( 209 user, num, num - warnings, warnings 204 210 )) 211 logger.info("-" * 20) 205 212 return 206 213 … … 217 224 return 218 225 219 def doImport(self, path, headerfields, mode='create', user='Unknown'): 226 def doImport(self, path, headerfields, mode='create', user='Unknown', 227 logger=None): 220 228 """Perform actual import. 221 229 """ … … 227 235 228 236 failed_path = "%s.%s.pending" % (path, mode, ) 229 failed_headers = [x for x in mapping.values() 230 237 failed_headers = [x for x in mapping.values()] 238 # if x != '--IGNORE--'] 231 239 failed_headers.append('--ERRORS--') 232 240 failed_writer = csv.DictWriter(open(failed_path, 'wb'), … … 290 298 failed_path = path 291 299 self.createLogfile(path, failed_path, num, num_warns, mode, user, 292 timedelta )300 timedelta, logger=logger) 293 301 if num_warns == 0: 294 302 del failed_writer
Note: See TracChangeset for help on using the changeset viewer.