Changeset 1724
- Timestamp:
- 12/21/06 00:05:00 (2 years ago)
- Files:
-
- mantisimportscript/mantis2trac.py (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
mantisimportscript/mantis2trac.py
r1721 r1724 425 425 c.execute("""INSERT INTO ticket_change (ticket, time, author, field, oldvalue, newvalue) 426 426 VALUES (%s, %s, %s, %s, %s, %s)""", 427 (ticket, time.strftime('%s'), author, 'comment', '', comment ,))427 (ticket, time.strftime('%s'), author, 'comment', '', comment)) 428 428 self.db().commit() 429 429 … … 433 433 c.execute("""INSERT INTO ticket_change (ticket, time, author, field, oldvalue, newvalue) 434 434 VALUES (%s, %s, %s, %s, %s, %s)""", 435 (ticket, time.strftime('%s'), author, field, oldvalue.encode('utf-8'), newvalue.encode('utf-8') ,))435 (ticket, time.strftime('%s'), author, field, oldvalue.encode('utf-8'), newvalue.encode('utf-8'))) 436 436 self.db().commit() 437 437 # Now actually change the ticket because the ticket wont update itself! … … 449 449 def getLoginName(self, cursor, userid): 450 450 if userid not in self.loginNameCache: 451 cursor.execute("SELECT * FROM mantis_user_table WHERE id = %i" % int(userid)) 452 loginName = cursor.fetchall() 453 454 if loginName: 455 loginName = loginName[0]['username'] 451 cursor.execute("SELECT username,email,realname,last_visit FROM mantis_user_table WHERE id = %i" % int(userid)) 452 result = cursor.fetchall() 453 454 if result: 455 loginName = result[0]['username'] 456 print 'Adding user %s to sessions table' % loginName 457 c = self.db().cursor() 458 459 # pre-populate the session table and the realname/email table with user data 460 try: 461 c.execute( 462 """INSERT IGNORE INTO session 463 (sid, authenticated, last_visit) 464 VALUES 465 (%s, 1, %s)""",(result[0]['username'].encode('utf-8'), result[0]['last_visit'].strftime('%s'))) 466 except: 467 print 'could not insert %s into sessions table: sql error %s ' % loginName, self.db().error() 468 self.db().commit() 469 c.execute( 470 """INSERT IGNORE INTO session_attribute 471 (sid, authenticated, name, value) 472 VALUES 473 (%s, %s, %s, %s), (%s, %s, %s, %s)""", 474 (result[0]['username'].encode('utf-8'), '1', 'name', result[0]['realname'].encode('utf-8'), 475 result[0]['username'].encode('utf-8'), '1', 'email', result[0]['email'].encode('utf-8'))) 476 self.db().commit() 456 477 else: 457 478 print 'warning: unknown mantis userid %d, recording as anonymous' % userid … … 555 576 components = mysql_cur.fetchall() 556 577 for component in components: 557 component['owner'] = trac.getLoginName(mysql_cur, component['owner'])578 component['owner'] = trac.getLoginName(mysql_cur, component['owner']) 558 579 trac.setComponentList(components, 'category') 559 580
