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
|
#!/usr/bin/env python2.7
import os
import sys
from launchpadlib.launchpad import Launchpad
class Error(Exception):
"""
A base class for exceptions.
"""
def __init__(self, msg=None):
if msg == None:
msg = self.__doc__.strip()
super(Error, self).__init__(msg)
class CredentialsError(Error):
"""
Can't proceed without Launchpad credential.
"""
class UnknownState(Error):
pass
class Client(object):
"""
A convenience wrapper for the Launchpad object.
"""
def __init__(self, name=""):
cachedir = os.path.expanduser("~/.launchpadlib/cache/")
self.launchpad = Launchpad.login_with(
name, 'production', cachedir,
credential_save_failed=CredentialsError)
self.project = self.get_project()
self.set_state_map()
def set_state_map(self):
self.state_map = {
"begin_state": {
"fixcommitted": self.get_committed_bugs,
},
"end_state": {
"fixreleased": self.set_released,
},
}
def get_project(self, name="txaws"):
return self.launchpad.projects["txaws"]
def get_committed_bugs(self):
return self.project.searchTasks(status="Fix Committed")
def set_released(self, bugs=[]):
count = int(bugs._wadl_resource.representation['total_size'])
print "Found %s bugs." % count
for bug_entry in bugs:
status = "Fix Released"
print "\tUpdating status of %s to '%s' ... " % (
bug_entry.title, bug_entry.status),
bug_entry.status = status
bug_entry.lp_save()
print "Done."
|