Changeset 1005 for WAeUP_SRP/trunk/Students.py
- Timestamp:
- 7 Dec 2006, 09:29:29 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
WAeUP_SRP/trunk/Students.py
r981 r1005 269 269 update = name.endswith('update') 270 270 no_import = [] 271 s = ','.join(['" (%s)"' % fn for fn in csv_fields])271 s = ','.join(['"%s"' % fn for fn in csv_fields]) 272 272 no_import.append('%s' % s) 273 open("%s/import/%s_not_imported.csv" % (i_home,name),"w").write( 274 '\n'.join(no_import)) 273 current = DateTime.DateTime().strftime("%d-%m-%y_%H_%M_%S") 274 no_import_name = "%s/import/%s_not_imported_%s.csv" % (i_home,name,current) 275 open(no_import_name,"w").write('\n'.join(no_import)) 275 276 no_import = [] 276 277 logger = logging.getLogger('%s_import' % name) … … 285 286 format = ','.join(['"%%(%s)s"' % fn for fn in csv_fields]) 286 287 eduplicate = '"dupplicate",%s' % format 288 added = 'added ,%s' % format 287 289 for jamb in result: 288 290 dict = {} … … 293 295 if len(res) > 0: 294 296 if update: 295 pume.modifyRecord(**dict) 297 try: 298 pume.modifyRecord(**dict) 299 except ValueError: 300 logger.info(eduplicate % jamb) 301 continue 302 except KeyError: 303 pume.addRecord(**dict) 304 logger.info(added % jamb) 305 continue 296 306 else: 297 307 data = res[0] … … 316 326 logger.info('End loading from %s.csv' % name) 317 327 if len(no_import) > 1: 318 open("%s/import/%s_not_imported.csv" % (i_home,name),"w+").write( 319 '\n'.join(no_import)) 328 open(no_import_name,"w+").write('\n'.join(no_import)) 320 329 return self.REQUEST.RESPONSE.redirect("%s" % self.REQUEST.get('URL1')) 321 330 ###)
Note: See TracChangeset for help on using the changeset viewer.