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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
#!/usr/bin/python
# Create Trello cards from LP
#
# Process will be:
# - Review bugs with rls-w-incoming tag
# - Select bugs for sprint and add tag "XYZ"
# - Trello cards will get created in the Backlog column
# - Do work
# Secret stuff:
# API Key: 829d0e6c978aa1623fffb7183c26d528
# Secret: [ Speak to Will if you need this ]
# Auth: e026e087a1eff164a3862b02556a6ec066c1281e702337b6ca3a59cbdbfe92a6
# U7 Trello board ID: 9YvUSYqq
# sudo pip install trello
from trello import TrelloApi
from launchpadlib.launchpad import Launchpad
import os
cachedir = os.path.expanduser("/tmp/lp-cache")
try: os.makedirs(cachedir)
except: pass
DEBUG = True
api_key = '829d0e6c978aa1623fffb7183c26d528'
token = 'e026e087a1eff164a3862b02556a6ec066c1281e702337b6ca3a59cbdbfe92a6'
board = '9YvUSYqq'
trello = TrelloApi(api_key,token)
lp = Launchpad.login_with('BugScrubber', 'production', cachedir, version='devel')
project_name = "unity"
ubuntu = lp.distributions['ubuntu']
src_project = ubuntu.getSourcePackage(name=project_name)
src_bugs = src_project.searchTasks(tags=["u7-trello-import"], status=["New", "Confirmed", "Triaged"])
print "Found %s bugs" % src_bugs.total_size
compiz_label = 'yellow'
nux_label = 'green'
unity_label = 'purple'
incoming_bug_list = "Backlog"
def log(message):
if DEBUG: print message
def get_list_id_from_name(board, name):
a = trello.boards.get_list(board)
if len(a) > 0:
for each in a:
if each['name'] == name:
return each['id']
else:
log("No lists found for board")
return False
def create_card(listid, descr, name, label_colour=None):
a = trello.cards.new(name, listid, descr)
if label_colour is not None:
b = trello.cards.new_label(a['id'], label_colour)
return a['id']
def set_label(card_id, colour):
a = trello.cards.new_label(card_id, colour)
if src_bugs.total_size > 0:
list_id = get_list_id_from_name(board, incoming_bug_list)
for each in src_bugs:
bug = each.bug
id = str(bug.id)
title = bug.title
link = each.web_link
descr = bug.description[:16000]
create_card(list_id, link+"\n\n\n"+descr, title, unity_label)
|