1
#!/usr/bin/env python2.7
5
from launchpadlib.launchpad import Launchpad
8
class Error(Exception):
10
A base class for exceptions.
12
def __init__(self, msg=None):
14
msg = self.__doc__.strip()
15
super(Error, self).__init__(msg)
18
class CredentialsError(Error):
20
Can't proceed without Launchpad credential.
24
class UnknownState(Error):
30
A convenience wrapper for the Launchpad object.
32
def __init__(self, name=""):
33
cachedir = os.path.expanduser("~/.launchpadlib/cache/")
34
self.launchpad = Launchpad.login_with(
35
name, 'production', cachedir,
36
credential_save_failed=CredentialsError)
37
self.project = self.get_project()
40
def set_state_map(self):
43
"fixcommitted": self.get_committed_bugs,
46
"fixreleased": self.set_released,
50
def get_project(self, name="txaws"):
51
return self.launchpad.projects["txaws"]
53
def get_committed_bugs(self):
54
return self.project.searchTasks(status="Fix Committed")
56
def set_released(self, bugs=[]):
57
count = int(bugs._wadl_resource.representation['total_size'])
58
print "Found %s bugs." % count
59
for bug_entry in bugs:
60
status = "Fix Released"
61
print "\tUpdating status of %s to '%s' ... " % (
62
bug_entry.title, bug_entry.status),
63
bug_entry.status = status