My Site
Categories
Migrating from Trac to Launchpad

I love trac. LOVE it. With the recent exaile.org hack, however, I wanted my bugs and code to be in a place that isn’t going anywhere soon. I chose Launchpad.

I was faced with a problem – all of our bugs were in trac. Lots and lots of bugs. I had to somehow migrate them from trac to Launchpad, so I wrote up a script to do so fairly painlessly. You use it like this:

./trac2lp lpusername lppassword project /path/to/trac.db

Here’s the script:


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/env python
from pysqlite2 import dbapi2 as sqlite
from mechanize import Browser
import sys

try:
    username = sys.argv[1]
    password = sys.argv[2]
    project = sys.argv[3]
    db_location = sys.argv[4]
except:
    print "Useage: trac2lp.py username password project trac.db"
    sys.exit(1)

br = Browser()
br.open(https://launchpad.net/+login)
br.select_form(name=login)
br[loginpage_email] = username
br[loginpage_password] = password
response = br.submit()

db = sqlite.connect(db_location)
cur = db.cursor()
cur.execute(SELECT id, summary, reporter, description FROM 
    ticket WHERE resolution IS NULL ORDER BY id ASC)

# Here, we can keep track of tickets that have already been processed so that
# if something goes wrong, they don’t get processed again
tickets = []
for line in open(tickets.txt).readlines():
    line = line.strip()
    tickets.append(int(line))

h = open(tickets.txt, a)

for row in cur.fetchall():
    if int(row[0]) in tickets: continue
    h.write(%d % row[0])

    try:
        br.open(https://launchpad.net/%s/+filebug % project)
        br.select_form(nr=2)
        br[field.title] = row[1]
        response = br.submit()

        br.select_form(nr=2)
        br[field.title] = row[1]
        br[field.comment] = %s\n\n\n%s\n%s % (row[2],
            "This ticket was migrated from the old trac: re #%d" % row[0],
            "Originally reported by: %s" % row[3])

        try:
            br.find_control(field.actions.this_is_my_bug).disabled = True
            control = br.find_control(field.bug_already_reported_as)
            control.items[len(control.items)  1].selected = True
        except:
            pass
        response = br.submit(id=field.actions.submit_bug)
    except:
        pass

Note: This only migrates open tickets.

vim tip: Ron colorscheme

If you’re like me, you are used to having your terminal being a white foreground on a black background. When using vim in a terminal, I’ve found that the default colorscheme is hard on the eyes, or just plain hard to read with a black background. I tried out all the schemes that Vim comes with, and the winner is Ron. Try it: :colorscheme ron. IMHO, much better on the eyes.

Filed under: Miscellaneous
Comments:

From synic on Oct. 31 @ 8:41 p.m. 2007

The ron colorscheme rocks.

Add a comment:
captcha

Optional, for comment reply notifications
 
Note: If you enter your email address, you will be subscribed to this article and will recieve comment updates via email. This is the only thing your address will be used for. A link will be provided at the end of each email that will allow you to unsubscribe should you need to, or you can go to http://synicworld.com//unsubscribe to unsubscribe from any/all updates.