Created
October 5, 2009 08:22
-
-
Save co3k/201981 to your computer and use it in GitHub Desktop.
trac から redmine のチケットをインポートするやつ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import xmlrpclib, urllib, urllib2, cookielib, datetime | |
xmlrpc_url = 'http://user:[email protected]/login/xmlrpc' | |
login_url = 'http://redmine.openpne.jp/login' | |
login_account = {'username': 'user', 'password': 'pass'}; | |
newticket_url = 'http://redmine.openpne.jp/projects/op3/issues/new'; | |
def convert_type(type): | |
if type == 'defect': | |
return '1' | |
elif type == 'enhancement': | |
return '2' | |
else: | |
return '3' | |
jar = cookielib.CookieJar() | |
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(jar)) | |
urllib2.install_opener(opener) | |
res = urllib2.urlopen(login_url, urllib.urlencode(login_account)) | |
server = xmlrpclib.Server(xmlrpc_url); | |
for id in server.ticket.query("component=core&status!=closed"): | |
if id in [4173, 4317, 4319, 3690, 4330, 4325, 3316, 3271, 4316, 4300, 4254, 3309, 4329, 4219, 4066, 4283, 3336]: | |
continue | |
ticket = server.ticket.get(id) | |
data = { | |
'issue[tracker_id]': convert_type(ticket[3]['type']), | |
'issue[subject]': ticket[3]['summary'].encode('utf-8'), | |
'issue[description]': (u"以前のチケットは http://trac.openpne.jp/ticket/"+str(ticket[0])+u" です\n<pre>"+ticket[3]['description']+"</pre>").encode('utf-8'), | |
'issue[status_id]': '1', | |
'issue[priority_id]': '3', | |
'issue[assigned_to_id]': '', | |
'issue[start_date]': datetime.datetime.fromtimestamp(ticket[1]).strftime('%Y-%m-%d'), | |
'issue[due_date]': '', | |
'issue[estimated_hours]': '', | |
'issue[done_ratio]': '0', | |
} | |
res = urllib2.urlopen(newticket_url, urllib.urlencode(data)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment