lptools-0.2.0/0000775000202700020270000000000012030601767013433 5ustar dobeydobey00000000000000lptools-0.2.0/bin/0000775000202700020270000000000012030601767014203 5ustar dobeydobey00000000000000lptools-0.2.0/bin/lp-capture-bug-counts0000775000202700020270000000537712030130502020265 0ustar dobeydobey00000000000000#! /usr/bin/python import sys from lptools import config project_name = 'bzr' def get_project(): sys.stderr.write('getting project... ') project = launchpad.projects[project_name] sys.stderr.write('%s (%s)\n' % (project.name, project.title)) return project class BugCategory(object): """Holds a set of logically-related bugs""" def __init__(self): self.bugs = set() def add(self, bt): self.bugs.add(bt) def count_bugs(self): return len(self.bugs) def get_link_url(self): return None class HasPatchBugCategory(BugCategory): def get_name(self): return 'HasPatch' def get_link_url(self): return 'https://bugs.edge.launchpad.net/%s/+bugs' \ '?search=Search&field.has_patch=on' \ % (project_name) class StatusBugCategory(BugCategory): def __init__(self, status): BugCategory.__init__(self) self.status = status def get_name(self): return self.status def get_link_url(self): return 'https://bugs.edge.launchpad.net/%s/+bugs?search=Search&field.status=%s' \ % (project_name, self.status) class CannedQuery(object): def __init__(self, project): self.project = project def _run_query(self, from_collection): sys.stderr.write(self.get_name()) for bt in from_collection: yield bt sys.stderr.write('.') sys.stderr.write('\n') def show_text(self): # print self.get_name() for category in self.query_categories(): print '%6d %s %s' % (category.count_bugs(), category.get_name(), category.get_link_url() or '') print class PatchCannedQuery(CannedQuery): def get_collection(self): return self.project.searchTasks(has_patch=True) def get_name(self): return 'Bugs with patches' def query_categories(self): has_patches = HasPatchBugCategory() for bt in self._run_query( self.project.searchTasks(has_patch=True)): has_patches.add(bt) return [has_patches] class StatusCannedQuery(CannedQuery): def get_name(self): return 'By Status' def query_categories(self): by_status = {} for bugtask in self._run_query(self.project.searchTasks()): if bugtask.status not in by_status: by_status[bugtask.status] = StatusBugCategory(bugtask.status) by_status[bugtask.status].add(bugtask) return by_status.values() def show_bug_report(project): for query_class in StatusCannedQuery, PatchCannedQuery: query_class(project).show_text() launchpad = config.get_launchpad("capture-bug-counts") project = get_project() show_bug_report(project) lptools-0.2.0/bin/lp-attach0000775000202700020270000000420212030130502015764 0ustar dobeydobey00000000000000#! /usr/bin/python # # Copyright (C) 2010 Canonical Ltd """lp-attach Attach a file to a Launchpad bug usage: lp_attach BUGNUMBER Attaches a file (read from stdin) as an attachment on a named Launchpad bug. """ # TODO: option to set the attachment name, and to set whether it's a patch # # TODO: option to open the bug after attaching # # TODO: option to add a comment as well as the attachment # # TODO: option to set the subject of the comment # # TODO: option to comment on a merge proposal or question rather than a bug # # TODO: option to add a comment rather than an attachment # # TODO: option to use staging -- for now use # export LAUNCHPAD_API=https://api.staging.launchpad.net/ # # TODO: option to set mime type # # TODO: detect mime type if not set - could use python-magic import sys from lptools import config def guess_mime_type(attachment_bytes): try: import magic except ImportError, e: sys.stderr.write("can't guess mime-types without the python-magic library: %s" % e) mimetype = None else: mime = magic.open(magic.MAGIC_MIME) mimetype = mime.buffer(attachment_bytes) if mimetype is None: mimetype = 'application/binary' print 'attachment type %s' % mimetype return mimetype def main(argv): if len(argv) != 2 or argv[1] == '--help': print __doc__ return 3 try: bugnumber = int(argv[1]) except TypeError: sys.stderr.write("please give a Launchpad bug number\n") return 1 lp = config.get_launchpad("attach") print "getting bug %s" % bugnumber bug = lp.bugs[bugnumber] print 'Attaching to %s' % bug attachment_bytes = sys.stdin.read() print '%d bytes to attach' % len(attachment_bytes) mime_type = guess_mime_type(attachment_bytes) # mime type must be specified otherwise # assumes it's # chemical/x-mopac-input print bug.addAttachment(comment='', data=attachment_bytes, description='', filename='attachment', content_type=mime_type) if __name__ == '__main__': sys.exit(main(sys.argv)) lptools-0.2.0/bin/lp-milestone2ical0000775000202700020270000000642412030130502017442 0ustar dobeydobey00000000000000#!/usr/bin/python # # Author: Rodney Dawes # # Copyright 2009 Canonical Ltd. # # This program is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License version 3, as published # by the Free Software Foundation. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranties of # MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR # PURPOSE. See the GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program. If not, see . from __future__ import with_statement import os import sys from xdg.BaseDirectory import xdg_cache_home from threading import Thread from launchpadlib.launchpad import Launchpad, EDGE_SERVICE_ROOT from launchpadlib.credentials import Credentials class MSMain(object): def __init__(self, project): self.project = project self.cachedir = os.path.join(xdg_cache_home, "lptools") if not os.path.isdir(self.cachedir): os.makedirs(self.cachedir) self.launchpad = None self.thread = None self.buffer = [] def __start_calendar(self): self.buffer.append("BEGIN:VCALENDAR") self.buffer.append("VERSION:2.0") self.buffer.append("PRODID:-//Canonical/lptools/NONSGML v1.0//EN") def __end_calendar(self): self.buffer.append("END:VCALENDAR") def __convert_to_ical(self, item): for milestone in item.all_milestones: if not milestone.date_targeted: continue self.buffer.append("BEGIN:VEVENT") date = milestone.date_targeted.strftime("%Y%m%dT%H%M%SZ") self.buffer.append("DTSTART:%s" % date) self.buffer.append("SUMMARY:%s" % milestone.name) self.buffer.append("END:VEVENT") def __login_and_go(self): credsfile = os.path.join(self.cachedir, "credentials") if os.path.exists(credsfile): creds = Credentials() with file(credsfile) as f: creds.load(f) self.launchpad = Launchpad(creds, EDGE_SERVICE_ROOT) else: self.launchpad = Launchpad.get_token_and_login( 'lptools', EDGE_SERVICE_ROOT, self.cachedir) with file(credsfile, "w") as f: self.launchpad.credentials.save(f) self.__start_calendar() try: lp_project = self.launchpad.project_groups[self.project] except KeyError: lp_project = self.launchpad.projects[self.project] finally: self.__convert_to_ical(lp_project) self.__end_calendar() print self.calendar() def run(self): self.thread = Thread(target=self.__login_and_go).start() def stop(self): self.thread.join() def calendar(self): return "\n".join(self.buffer) if __name__ == "__main__": try: project = sys.argv[1] except IndexError: print "Usage: %s " % sys.argv[0] exit(1) try: mt = MSMain(project=sys.argv[1]) mt.run() except KeyboardInterrupt: mt.stop() lptools-0.2.0/bin/lp-review-list0000775000202700020270000001353512030130502017003 0ustar dobeydobey00000000000000#!/usr/bin/python # # Author: Rodney Dawes # # Copyright 2009 Canonical Ltd. # # This program is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License version 3, as published # by the Free Software Foundation. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranties of # MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR # PURPOSE. See the GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program. If not, see . from __future__ import with_statement import re import subprocess from threading import Thread import pygtk pygtk.require('2.0') import gobject import gtk from lptools import config VOTES = { "Approve" : "#00ff00", "Needs Fixing" : "#993300", "Disapprove" : "#ff0000", "Resubmit" : "#ff0000", "Pending" : "#ff6600", "Abstain" : "#909090", "Needs Information" : "#909090", } class Window(gtk.Window): def __init__(self): gtk.Window.__init__(self) self.set_title("Pending Reviews") self.set_default_size(320, 400) self.connect("destroy", lambda w: gtk.main_quit()) self.connect("delete_event", lambda w,x: gtk.main_quit()) vbox = gtk.VBox() self.add(vbox) vbox.show() toolbar = gtk.Toolbar() vbox.pack_start(toolbar, expand=False, fill=False) toolbar.show() button = gtk.ToolButton(gtk.STOCK_REFRESH) button.connect("clicked", self.__refresh) toolbar.insert(button, -1); button.show() scrollwin = gtk.ScrolledWindow() scrollwin.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC) vbox.pack_start(scrollwin, expand=True, fill=True) scrollwin.show() self.store = gtk.ListStore(str, str) view = gtk.TreeView(self.store) view.connect("row-activated", self.__open_link) scrollwin.add(view) view.show() cell = gtk.CellRendererText() col = gtk.TreeViewColumn("Branch", cell, markup=0) view.append_column(col) self.launchpad = None self.me = None self.thread = None self.id = 0 Thread(target=self.__lp_login).start() def __lp_login(self): self.launchpad = config.get_launchpad("review-list") self.me = self.launchpad.me print "Allo, %s" % self.me.name gtk.gdk.threads_enter() self.__refresh(None) gtk.gdk.threads_leave() return False def __refresh(self, button, data=None): if self.id != 0: gobject.source_remove(self.id) self.id = 0 self.__timeout() self.id = gobject.timeout_add_seconds(5 * 60, self.__timeout) return False def __open_link(self, view, path, column, data=None): row = self.store.get_iter(path) url, = self.store.get(row, 1) if url == "": return ret = subprocess.call(["xdg-open", url]) if ret != 0: dialog = gtk.MessageDialog(self, 0, gtk.MESSAGE_ERROR, gtk.BUTTONS_CLOSE, "Failed to run 'xdg-open %s'\n" % url) dialog.run() dialog.destroy() def __load_merges(self): merges = [] mine = self.me.getRequestedReviews(status=[u'Needs review']) for merge in mine: merges.append(merge) for team in self.me.super_teams: for merge in team.getRequestedReviews(status=[u'Needs review']): if merge not in merges: merges.append(merge) for merge in merges: votes = {} for key in VOTES.keys(): votes[key] = 0 for vote in merge.votes: if not vote.comment: continue else: votes[vote.comment.vote] += 1 for key in votes.keys(): if votes[key] == 0: votes.pop(key, None) vstr = ", ".join( ["%s: %d" \ % (VOTES[key], key, votes[key]) \ for key in votes.keys()] ) if vstr == "": vstr = "No Reviews" status = "%s\n%s" % (merge.source_branch.display_name, vstr) urlp = re.compile( 'http[s]?://api\.(.*)launchpad\.net/[^/]+/') merge_url = urlp.sub( 'http://launchpad.net/', merge.self_link) gtk.gdk.threads_enter() self.store.append((status, merge_url)) gtk.gdk.threads_leave() def __timeout(self): self.store.clear() if self.thread and self.thread.isAlive(): return True if self.thread is None: thread = Thread(target=self.__load_merges) thread.start() return True if __name__ == "__main__": gobject.threads_init() gtk.gdk.threads_init() try: win = Window() win.show() gtk.gdk.threads_enter() gtk.main() gtk.gdk.threads_leave() except KeyboardInterrupt: gtk.main_quit() lptools-0.2.0/bin/lp-review-notifier0000775000202700020270000002353712030130502017652 0ustar dobeydobey00000000000000#!/usr/bin/python # # Author: Rodney Dawes # # Copyright 2009 Canonical Ltd. # # This program is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License version 3, as published # by the Free Software Foundation. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranties of # MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR # PURPOSE. See the GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program. If not, see . from __future__ import with_statement import os import sys import gobject import gtk import pygtk import pynotify from ConfigParser import ConfigParser import subprocess from xdg.BaseDirectory import ( xdg_config_home, ) from lptools import config pygtk.require('2.0') import indicate from time import time ICON_NAME = "bzr-icon-64" class Preferences(object): def __init__(self): self.filename = os.path.join(xdg_config_home, "lptools", "lptools.conf") self.config = ConfigParser() self.config.read(self.filename) if not os.path.isdir(os.path.dirname(self.filename)): os.makedirs(os.path.dirname(self.filename)) if not self.config.has_section("lptools"): self.config.add_section("lptools") if self.config.has_option("lptools", "projects"): self.projects = self.config.get("lptools", "projects").split(",") else: self.projects = [] # gtk.ListStore for the dialog self.store = None self.dialog = self.__build_dialog() def __build_dialog(self): dialog = gtk.Dialog() dialog.set_title("Pending Reviews Preferences") dialog.set_destroy_with_parent(True) dialog.set_has_separator(False) dialog.set_default_size(240, 320) area = dialog.get_content_area() vbox = gtk.VBox(spacing=6) vbox.set_border_width(12) area.add(vbox) vbox.show() label = gtk.Label("%s" % "_Projects") label.set_use_underline(True) label.set_use_markup(True) label.set_alignment(0.0, 0.5) vbox.pack_start(label, expand=False, fill=False) label.show() hbox = gtk.HBox(spacing=12) vbox.pack_start(hbox, expand=True, fill=True) hbox.show() misc = gtk.Label() hbox.pack_start(misc, expand=False, fill=False) misc.show() scrollwin = gtk.ScrolledWindow() scrollwin.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC) hbox.pack_start(scrollwin, expand=True, fill=True) scrollwin.show() self.store = gtk.ListStore(str) view = gtk.TreeView(self.store) label.set_mnemonic_widget(view) view.set_headers_visible(False) scrollwin.add(view) view.show() cell = gtk.CellRendererText() cell.set_property("editable", True) cell.connect("editing_started", self.__edit_started) cell.connect("edited", self.__edit_finished) col = gtk.TreeViewColumn("Project", cell, markup=0) view.append_column(col) dialog.connect("close", self.__dialog_closed, 0) dialog.connect("response", self.__dialog_closed) return dialog def __edit_started(self, cell, editable, path): return def __edit_finished(self, sell, path, text): if text == "Click here to add a project...": return treeiter = self.store.get_iter_from_string(path) label = "%s" % "Click here to add a project..." self.store.set(treeiter, 0, label) self.projects.append(text) self.store.append([text,]) def __dialog_closed(self, dialog, response): dialog.hide() if len(self.projects) > 0: self.config.set("lptools", "projects", ",".join(self.projects)) with open(self.filename, "w+b") as f: self.config.write(f) def show_dialog(self, parent): if not self.dialog.get_transient_for(): self.dialog.set_transient_for(parent) self.store.clear() text = "%s" % "Click here to add a project..." self.store.append([text,]) if len(self.projects) != 0: for project in self.projects: self.store.append([project,]) self.dialog.run() def server_display (server): ret = subprocess.call(["./review-list"]) if ret != 0: sys.stderr.write("Failed to run './review-list'\n") def indicator_display (indicator): name = indicator.get_property("name") url = "http://code.launchpad.net/" + name + "/+activereviews" ret = subprocess.call(["xdg-open", url]) if ret != 0: sys.stderr.write("Failed to run 'xdg-open %s'\n" % url) class Main(object): def __init__(self): self.id = 0 self.cached_candidates = {} self.indicators = { } server = indicate.indicate_server_ref_default() server.set_type("message.instant") server.set_desktop_file(os.path.join(os.getcwd(), "review-tools.desktop")) server.connect("server-display", server_display) server.show() self.launchpad = config.get_launchpad("review-notifier") self.me = self.launchpad.me self.project_idle_ids = {} self.config = Preferences() if len(self.config.projects) == 0: print "No Projects specified" sys.exit(1) for project in self.config.projects: ind = indicate.Indicator() ind.set_property("name", project) ind.set_property("count", "%d" % 0) ind.connect("user-display", indicator_display) ind.hide() self.indicators[project] = ind pynotify.init("Review Notifier") self.timeout() def timeout(self): for project in self.config.projects: self.project_idle_ids[project] = gobject.idle_add(self.project_idle, project) return True def project_idle (self, project): lp_project = None lp_focus = None try: lp_project = self.launchpad.projects[project] focus = lp_project.development_focus.branch except AttributeError: print "Project %s has no development focus." % project return False except KeyError: print "Project %s not found." % project return False if not focus: print "Project %s has no development focus." % project return False trunk = focus if trunk.landing_candidates: self.indicators[project].show() for c in trunk.landing_candidates: gobject.idle_add(self.landing_idle, project, c) else: self.indicators[project].hide() return False def landing_idle (self, project, c): c_name = c.source_branch.unique_name status = None try: status = self.cached_candidates[c_name] except KeyError: status = None # If the proposal hasn't changed, get on with it if status and status == c.queue_status: return False self.cached_candidates[c_name] = c.queue_status n = pynotify.Notification("Review Notification") updated = False # Source and target branch URIs source = c.source_branch.display_name target = c.target_branch.display_name if c.queue_status == "Needs review": # First time we see the branch n.update("Branch Proposal", "%s has proposed merging %s into %s." % ( c.registrant.display_name, source, target), ICON_NAME) updated = True elif c.queue_status == "Approved": # Branch was approved n.update("Branch Approval", "%s was approved for merging into %s." % ( source, target), ICON_NAME) udpated = True elif c.queue_status == "Rejected": # Branch was rejected n.update("Branch Rejected", """The proposal to merge %s into %s has been rejected.""" % ( source, target), ICON_NAME) updated = True elif c.queue_status == "Merged": # Code has landed in the target branch n.update("Branch Merged", "%s has been merged into %s." % (source, target), ICON_NAME) updated = True else: print "%s status is %s." % (source, c.queue_status) if updated: n.set_urgency(pynotify.URGENCY_LOW) n.set_hint("x-canonical-append", "allow") n.show() self.indicators[project].set_property_time("time", time()) else: n.close() def run(self): self.id = gobject.timeout_add_seconds(5 * 60, self.timeout) gtk.main() if __name__ == "__main__": gobject.threads_init() gtk.gdk.threads_init() try: foo = Main() gtk.gdk.threads_enter() foo.run() gtk.gdk.threads_leave() except KeyboardInterrupt: gtk.main_quit() lptools-0.2.0/bin/lp-list-bugs0000775000202700020270000000367312030130502016444 0ustar dobeydobey00000000000000#! /usr/bin/python # -*- coding: UTF-8 -*- """Briefly list status of Launchpad bugs.""" # Copyright (c) 2010 Canonical Ltd. # # lp-set-dup is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the # Free Software Foundation; either version 3, or (at your option) any # later version. # # lp-set-dup is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with lp-set-dup; see the file COPYING. If not, write to the Free # Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA # 02110-1301, USA. # # Authors: # Colin Watson import sys from optparse import OptionParser from lptools import config from launchpadlib.errors import HTTPError def main(): usage = "Usage: %prog [...]" parser = OptionParser(usage) args = parser.parse_args()[1] if len(args) < 1: parser.error("Need at least one bug number") launchpad = config.get_launchpad("list-bugs") for bugnum in args: try: bug = launchpad.bugs[bugnum] print "Bug %s: %s" % (bugnum, bug.title) for task in bug.bug_tasks: print " %s: %s" % (task.bug_target_name, task.status) except HTTPError, error: if error.response.status == 401: print >> sys.stderr, \ ("E: Don't have enough permissions to access bug %s" % bugnum) print >> sys.stderr, error.content continue elif error.response.status == 404: print >> sys.stderr, "E: Bug %s not found" % bugnum else: raise if __name__ == '__main__': main() lptools-0.2.0/bin/lp-check-membership0000775000202700020270000000320612030130502017731 0ustar dobeydobey00000000000000#! /usr/bin/python # # Copyright (C) 2009 Canonical Ltd # lp-check-membership is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the # Free Software Foundation; either version 3, or (at your option) any # later version. # # lp-check-membership is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with lp-check-membership; see the file COPYING. If not, write to the Free # Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA # 02110-1301, USA. # # Authors: # Martin Pool """lp-check-membership: Check whether a user is a member of a team. example: lp-check-membership mbp bzr Part of lptools """ import optparse import sys from lptools import config def main(argv): parser = optparse.OptionParser('%prog [options] PERSON GROUP') opts, args = parser.parse_args() if len(args) != 2: print __doc__ return 2 user_name = args[0] group_name = args[1] lp = config.get_launchpad("check-membership") user = lp.people[user_name] for user_team in user.super_teams: if user_team.name == group_name: print '%s is a member of %s' % (user_name, group_name) return 0 else: print '%s is not a member of %s' % (user_name, group_name) return 1 if __name__ == '__main__': sys.exit(main(sys.argv)) lptools-0.2.0/bin/lp-force-branch-mirror0000775000202700020270000000152212030130502020363 0ustar dobeydobey00000000000000#! /usr/bin/python # vi: expandtab:sts=4 # Copyright (C) 2011 Jelmer Vernooij """Force a new import """ import optparse import sys from lptools import config def main(argv): parser = optparse.OptionParser('%prog [options] BRANCH...\n\n' ' PROJECT is the launchpad project to inspect (eg bzr)') opts, args = parser.parse_args() if len(args) != 1: parser.print_usage() return 1 lp = config.get_launchpad("force-branch-mirror") branches = lp.branches.getByUrls(urls=args) for url, branch_dict in branches.iteritems(): if branch_dict is None: print "Branch %s not found" % url else: branch = lp.load(branch_dict["self_link"]) print "%s: %s" % (branch.bzr_identity, branch.requestMirror()) if __name__ == '__main__': sys.exit(main(sys.argv)) lptools-0.2.0/bin/lp-recipe-status0000775000202700020270000002241012030130502017311 0ustar dobeydobey00000000000000#!/usr/bin/python # vi: expandtab:sts=4 # Copyright (C) 2011 Jelmer Vernooij # # ################################################################## # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; version 3. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # See file /usr/share/common-licenses/GPL-3 for more details. # # ################################################################## # """Show the status of the recipes owned by a particular user. """ from cStringIO import StringIO import gzip import optparse import os import re import sys import urllib from lptools import config try: import tdb except ImportError: cache = {} else: cache = tdb.Tdb("recipe-status-cache.tdb", 1000, tdb.DEFAULT, os.O_RDWR|os.O_CREAT) def gather_per_distroseries_source_builds(recipe): last_per_distroseries = {} for build in recipe.completed_builds: if build.distro_series.self_link not in recipe.distroseries: # Skip distro series that are no longer being build continue distro_series_name = build.distro_series.name previous_build = last_per_distroseries.get(distro_series_name) if previous_build is None or previous_build.datecreated < build.datecreated: last_per_distroseries[distro_series_name] = build return last_per_distroseries def build_failure_link(build): if build.buildstate == "Failed to upload": return build.upload_log_url elif build.buildstate in ("Failed to build", "Dependency wait", "Chroot problem"): return build.build_log_url else: return None version_matcher = re.compile("^dpkg-buildpackage: source version (.*)$") source_name_matcher = re.compile("^dpkg-buildpackage: source package (.*)$") def source_build_find_version(source_build): cached_version = cache.get("version/%s" % str(source_build.self_link)) if cached_version: return tuple(cached_version.split(" ")) # FIXME: Find a more efficient way to retrieve the package/version that was built build_log_gz = urllib.urlopen(source_build.build_log_url) build_log = gzip.GzipFile(fileobj=StringIO(build_log_gz.read())) version = None source_name = None for l in build_log.readlines(): m = version_matcher.match(l) if m: version = m.group(1) m = source_name_matcher.match(l) if m: source_name = m.group(1) if not source_name: raise Exception("unable to find source name in %s" % source_build.build_log_url) if not version: raise Exception("unable to find version in %s" % source_build.build_log_url) cache["version/%s" % str(source_build.self_link)] = "%s %s" % ( source_name, version) return (source_name, version) def find_binary_builds(recipe, source_builds): """Gather binary builds for a set of source builds. :param recipe: Recipe to build :param source_builds: Source builds to analyse :return: Dictionary mapping series name to binary builds """ ret = {} for source_build in source_builds: archive = source_build.archive (source_name, version) = source_build_find_version(source_build) sources = archive.getPublishedSources( distro_series=source_build.distro_series, exact_match=True, pocket="Release", source_name=source_name, version=version) assert len(sources) == 1 source = sources[0] ret[source_build.distro_series.name] = source.getBuilds() return ret def build_failure_summary(build): # FIXME: Perhaps parse the relevant logs and extract a summary line? return build.buildstate def build_class(build): """Determine the CSS class for a build status. :param build: Launchpad build object :return: CSS class name """ return { "Failed to build": "failed-to-build", "Failed to upload": "failed-to-upload", "Dependency wait": "dependency-wait", "Chroot problem": "chroot-problem", "Uploading build": "uploading-build", "Currently building": "currently-building", "Build for superseded Source": "superseded-source", "Successfully built": "successfully-built", "Needs building": "needs-building", }[build.buildstate] def filter_source_builds(builds): """Filter out successful and failed builds. :param builds: List of builds :return: Tuple with set of successful and set of failed builds """ sp_success = set() sp_failures = set() for build in builds: if build.buildstate == "Successfully built": sp_success.add(build) else: sp_failures.add(build) return (sp_success, sp_failures) def recipe_status_html(launchpad, person, recipes, outf): """Render a recipe status table in HTML. :param launchpad: launchpadlib Launchpad object :param person: Person owning all the recipes :param recipes: List of recipes to render :param outf: File-like object to write HTML to """ from chameleon.zpt.loader import TemplateLoader tl = TemplateLoader(os.path.join(config.data_dir(), "templates")) relevant_distroseries = set() source_builds = {} binary_builds = {} all_binary_builds_ok = {} for recipe in recipes: sys.stderr.write("Processing recipe %s\n" % recipe.name) last_per_distroseries = gather_per_distroseries_source_builds(recipe) source_builds[recipe.name] = last_per_distroseries relevant_distroseries.update(set(last_per_distroseries)) (sp_success, sp_failures) = filter_source_builds(last_per_distroseries.values()) binary_builds[recipe.name] = find_binary_builds(recipe, sp_success) all_binary_builds_ok[recipe.name] = {} for distroseries, recipe_binary_builds in binary_builds[recipe.name].iteritems(): all_binary_builds_ok[recipe.name][distroseries] = all( [bb.buildstate == "Successfully built" for bb in recipe_binary_builds]) relevant_distroseries = list(relevant_distroseries) relevant_distroseries.sort() page = tl.load("recipe-status.html") outf.write(page.render(person=person, relevant_distroseries=relevant_distroseries, recipes=person.recipes, source_builds=source_builds, build_failure_summary=build_failure_summary, build_failure_link=build_failure_link, binary_builds=binary_builds, ubuntu=launchpad.distributions["ubuntu"], build_class=build_class, all_binary_builds_ok=all_binary_builds_ok)) def recipe_status_text(recipes, outf): """Display a recipe status table in plain text. :param recipes: List of recipes to display status of :param outf: file-like object to write to """ for recipe in recipes: last_per_distroseries = gather_per_distroseries_source_builds(recipe) (sp_success, sp_failures) = filter_source_builds( last_per_distroseries.values()) sp_success_distroseries = [build.distro_series.name for build in sp_success] if sp_failures: outf.write("%s source build failures (%s successful):\n" % ( recipe.name, ", ".join(sp_success_distroseries))) for failed_build in sp_failures: url = build_failure_link(failed_build) outf.write(" %s(%s)" % ( failed_build.distro_series.name, failed_build.buildstate)) if url: outf.write(": %s" % url) outf.write("\n") elif sp_success: outf.write("%s source built successfully on %s\n" % ( recipe.name, ", ".join(sp_success_distroseries))) else: outf.write("%s never built\n" % recipe.name) binary_builds = find_binary_builds(recipe, sp_success) for source_build in sp_success: for binary_build in binary_builds.get(source_build, []): if binary_build.buildstate != "Successfully built": url = build_failure_link(binary_build) outf.write(" %s,%s(%s)" % (binary_build.distro_series.name, binary_build.arch_tag, binary_build.buildstate)) if url: outf.write(": %s" % url) outf.write("\n") def main(argv): parser = optparse.OptionParser('%prog [options] PERSON\n\n' ' PERSON is the launchpad person or team whose recipes to check') parser.add_option("--html", help="Generate HTML", action="store_true") opts, args = parser.parse_args() if len(args) != 1: parser.print_usage() return 1 person = args[0] launchpad = config.get_launchpad("recipe-status") person = launchpad.people[person] if opts.html: recipe_status_html(launchpad, person, person.recipes, sys.stdout) else: recipe_status_text(person.recipes, sys.stdout) if __name__ == '__main__': sys.exit(main(sys.argv)) lptools-0.2.0/bin/lp-get-branches0000775000202700020270000000772212030130502017074 0ustar dobeydobey00000000000000#!/usr/bin/python # -*- coding: utf-8 -*- # # Copyright (C) 2007 Canonical Ltd. # Created by Daniel Holbach # Modified by Jonathan Patrick Davies # # ################################################################## # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; version 3. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # See file /usr/share/common-licenses/GPL-3 for more details. # # ################################################################## # # This script is used to checkout or branch all the Bazaar branches # of a Launchpad team. # import os import subprocess import sys from lptools import config from optparse import OptionParser def main(): usage = "Usage: %prog [-d ] -t [-o ]" usage += "\nUsage: %prog " opt_parser = OptionParser(usage) # Our options. opt_parser.add_option("-d", "--directory", action="store", type="string", dest="directory", default=os.getcwd(), help="Directory to download branches to.") opt_parser.add_option("-t", "--team", action="store", type="string", dest="lpteam", help="Launchpad team to download branches from.") opt_parser.add_option("-o", "--operation", action="store", type="string", dest="operation", default="branch", help="Whether to branch or checkout the Bazaar " "branches. May be either 'branch' or " "'checkout'.") (options, args) = opt_parser.parse_args() launchpad = config.get_launchpad("get-branches") # Fetch our current directory to return to later. pwd = os.getcwd() # Parse our options. if len(args) != 1 and options.lpteam == None: opt_parser.error("No team has been specified.") # Dictionary settings. directory = options.directory if not os.path.isdir(directory): # Check that it is a directory. opt_parser.error("%s is not a valid directory." % directory) os.chdir(directory) # Type of Bazaar operation to perform. operation_type = options.operation.lower() if operation_type not in ("branch", "checkout"): opt_parser.error("Invalid operation '%s' for '-o' flag." % \ operation_type) # Launchpad team setting. if options.lpteam: team = options.lpteam.lower() if args: team = args[0].lower() try: team = launchpad.people[team] except KeyError: print >> sys.stderr, "E: The team '%s' doesn't exist." % team # Get a list of branches branches = team.getBranches() print "Downloading all branches for the '%s' team. This may take some " \ "time." % team.display_name try: os.makedirs(team.name) except: pass os.chdir(team.name) for branch in branches: project_name = branch.project.name if not os.path.exists(project_name): os.makedirs(project_name) os.chdir(project_name) if not os.path.exists(branch.name): print "Branching %s ..." % branch.display_name cmd = ["bzr", operation_type, branch.bzr_identity, branch.name] subprocess.call(cmd) else: print "Merging %s ..." % branch.display_name os.chdir(branch.name) subprocess.call(["bzr", "merge", "--pull", "--remember"]) os.chdir(os.path.join(directory, team.name)) os.chdir(pwd) sys.exit(0) if __name__ == "__main__": try: main() except KeyboardInterrupt: print "Operation was interrupted by user." lptools-0.2.0/bin/lp-shell0000775000202700020270000001077512030130502015643 0ustar dobeydobey00000000000000#!/usr/bin/python # Open an interactive launchpadlib Python shell. # It supports all known LP service instances and API versions. The login # can optionally happen anonymously. # Author: Martin Pitt # Copyright: (C) 2010 Canonical Ltd. # # This package is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, at version 2. # # This package is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. import sys import code from optparse import OptionParser from launchpadlib.launchpad import Launchpad from launchpadlib.uris import lookup_service_root def run_command(command, lp): exec(command) def main(): instance = 'production' valid_api_versions = ('beta', '1.0', 'devel') api_version = '1.0' usage = 'Usage: %prog [-a] [instance] [LP API version]' opt_parser = OptionParser(usage) opt_parser.add_option('-a', action='store_true', dest='anonymous', default=False, help='Login anonymously into LP.') opt_parser.add_option('-c', type=str, dest='command', default=None, help='Run code passed as string.') opt_parser.add_option('--ipython', action='store_const', dest='shell', const='ipython', default="ipython", help='Use ipython shell (default).') opt_parser.add_option('--python', action='store_const', dest='shell', const='python', help='Use python shell.') (options, args) = opt_parser.parse_args() if len(args) >= 1: try: instance = lookup_service_root(args[0]) except ValueError, err: print 'E: %s' % (err) print 'I: Falling back to "production".' if len(args) >= 2: if args[1] in valid_api_versions: api_version = args[1] else: print 'E: "%s" is not a valid LP API version.' % (args[1]) print 'I: Falling back to "1.0".' if options.anonymous: launchpad = Launchpad.login_anonymously('lp-shell', instance, version=api_version) banner = ('Connected anonymously to LP service "%s" with API version ' '"%s":' % (instance, api_version)) else: launchpad = Launchpad.login_with('lp-shell', instance, version=api_version) banner = 'Connected to LP service "%s" with API version "%s":' % \ (instance, api_version) if options.command is not None: run_command(options.command, launchpad) return banner += '\nNote: LP can be accessed through the "lp" object.' sh = None if options.shell == "ipython": try: try: # ipython >= 0.11 from IPython.frontend.terminal.embed import InteractiveShellEmbed sh = InteractiveShellEmbed(banner2=banner, user_ns={'lp': launchpad}) except ImportError: # ipython < 0.11 # pylint does not handle nested try-except, disable import error # pylint: disable-msg=E0611 from IPython.Shell import IPShellEmbed sh = IPShellEmbed(argv=[], user_ns={'lp': launchpad}) sh.set_banner(sh.IP.BANNER + '\n' + banner) sh.excepthook = sys.__excepthook__ except ImportError: print "E: ipython not available. Using normal python shell." if sh: sh() else: class CompleterConsole(code.InteractiveConsole): def __init__(self): local = {'lp': launchpad} code.InteractiveConsole.__init__(self, locals=local) try: import readline except ImportError: print 'I: readline module not available.' else: import rlcompleter readline.parse_and_bind("tab: complete") # Disable default apport hook, as lp-shell is intended for interactive use # and thus exceptions often bubble up to the top level. sys.excepthook = sys.__excepthook__ console = CompleterConsole() console.interact(banner) if __name__ == '__main__': main() lptools-0.2.0/bin/lp-remove-team-members0000775000202700020270000000266212030130502020401 0ustar dobeydobey00000000000000#!/usr/bin/python # # Copyright 2011 Canonical Ltd. # # This program is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License version 3, as published # by the Free Software Foundation. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranties of # MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR # PURPOSE. See the GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program. If not, see . """Remove members from a Launchpad team. Usage: lp-remove-team-members TEAM MEMBER... """ import socket import sys from lptools.config import ( get_launchpad) def main(args): if len(args) < 3: print __doc__ return 1 lp = get_launchpad('lptools on %s' % (socket.gethostname(),)) team_name = args[1] team = lp.people[team_name] members_details = team.members_details for exile_name in args[2:]: print 'remove %s from %s...' % (exile_name, team_name), for m in members_details: if m.member.name == exile_name: m.setStatus(status='Deactivated') print 'done' break else: print 'not a member?' if __name__ == '__main__': sys.exit(main(sys.argv)) lptools-0.2.0/bin/lp-set-dup0000775000202700020270000001050212030130502016101 0ustar dobeydobey00000000000000#!/usr/bin/python # -*- coding: UTF-8 -*- """Sets the "duplicate of" bug of a bug and its dups.""" # Copyright (c) 2009 Canonical Ltd. # # lp-set-dup is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the # Free Software Foundation; either version 3, or (at your option) any # later version. # # lp-set-dup is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with lp-set-dup; see the file COPYING. If not, write to the Free # Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA # 02110-1301, USA. # # Authors: # Loïc Minier import sys from optparse import OptionParser from launchpadlib.errors import HTTPError from lptools import config def die(message): print >> sys.stderr, "Fatal: " + message sys.exit(1) def main(): usage = "Usage: %prog [-f] [...]" opt_parser = OptionParser(usage) opt_parser.add_option("-f", help="Skip confirmation prompt", dest="force", default=False, action="store_true") opt_parser.add_option("-l", "--lpinstance", metavar="INSTANCE", help="Launchpad instance to connect to " "(default: production)", dest="lpinstance", default=None) opt_parser.add_option("--no-conf", help="Don't read config files or " "environment variables.", dest="no_conf", default=False, action="store_true") (options, args) = opt_parser.parse_args() if len(args) < 2: opt_parser.error("Need at least a new main bug and a bug to dup") launchpad = config.get_launchpad("set-dup") # check that the new main bug isn't a duplicate try: new_main_bug = launchpad.bugs[args[0]] except HTTPError, error: if error.response.status == 401: print >> sys.stderr, ("E: Don't have enough permissions to access " "bug %s") % (args[0]) die(error.content) else: raise new_main_dup_of = new_main_bug.duplicate_of if new_main_dup_of is not None: answer = None try: answer = raw_input("Bug %s is a duplicate of %s; would you like to " "use %s as the new main bug instead? [y/N]" % \ (new_main_bug.id, new_main_dup_of.id, new_main_dup_of.id)) except: die("Aborted") if answer.lower() not in ("y", "yes"): die("User aborted") new_main_bug = new_main_dup_of # build list of bugs to process, first the dups then the bug bugs_to_process = [] for bug_number in args[1:]: print "Processing %s" % (bug_number) try: bug = launchpad.bugs[bug_number] except HTTPError, error: if error.response.status == 401: print >> sys.stderr, ("W: Don't have enough permissions to " "access bug %s") % (bug_number) print >> sys.stderr, "W: %s" % (error.content) continue else: raise dups = bug.duplicates if dups is not None: bugs_to_process.extend(dups) print "Found %i dups for %s" % (len(dups), bug_number) bugs_to_process.append(bug) # process dups first, then their main bug print "Would set the following bugs as duplicates of %s: %s" % \ (new_main_bug.id, " ".join([str(b.id) for b in bugs_to_process])) if not options.force: answer = None try: answer = raw_input("Proceed? [y/N]") except: die("Aborted") if answer.lower() not in ("y", "yes"): die("User aborted") for bug in bugs_to_process: print "Marking bug %s as a duplicate of %s" % (bug.id, new_main_bug.id) bug.duplicate_of = new_main_bug bug.lp_save() if __name__ == '__main__': main() lptools-0.2.0/bin/lp-project0000775000202700020270000001152112030130502016170 0ustar dobeydobey00000000000000#!/usr/bin/python # # Author: Robert Collins # # Copyright 2010 Canonical Ltd. # # This program is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License version 3, as published # by the Free Software Foundation. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranties of # MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR # PURPOSE. See the GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program. If not, see . """lp-project -- An lptools command to work with projects in Launchpad. https://launchpad.net/lptools/ lp-project help commands -- list commands """ import os # Might want to make errors import lazy. from bzrlib import bzrdir from lptools.command import * class cmd_create(LaunchpadCommand): """Create a project. This creates two teams - a management/committer team owner by you and a -dev mailing list owned by the mgmt team. It then creates the project, makes it owned by the committer team, creates a new empty bzr branch for trunk and then fires up a web browser pointing at the project for you to fine tune. After running this command you need to: - set what LP features you are using (https://bugs.launchpad.net/launchpad/+bug/537269) - describe your project (title, summary, description) - upload your code to lp:PROJECT - turn on the mailing list by hand (https://bugs.launchpad.net/launchpad/+bug/537258) lp-project create projectname """ takes_args = ['project'] def run(self, project): self.outf.write('creating project %s\n' % project) # load the lp plugin - we needs it, but don't want its commands shown. from bzrlib.plugins import launchpad project_d = {'project':project} mgmt = self.launchpad.people.newTeam( display_name='%s committers' % project, name=project, subscription_policy='Moderated Team', team_description="This is the" " %(project)s project maintainers and committers team. Membership " "in this team grants commit access to the %(project)s trunk and " "release branches, and owner access to the project. To become a " "member of this team, please contact the project via the " "%(project)s-dev mailing list." % {'project':project}) dev = self.launchpad.people.newTeam( display_name='%s mailing list' % project, name='%s-dev' % project, subscription_policy='Open Team', team_description="This is the" " %(project)s (https://launchpad.net/%(project)s) development " "discussion mailing list. To subscribe to the list join this team " "(it does not receive bug mail or other such dross)." % project_d) dev.team_owner = mgmt dev.lp_save() proj = self.launchpad.projects.new_project( display_name=project, name=project, registrant=mgmt, title="Put what you want to show in browser window titles for %s " "here" % project, description="""Put a long description of the %(project)s project here. A mailing list for discussion, usage and development is at https://launchpad.net/~%(project)s-dev - all are welcome to join. Some folk hang out on #%(project)s on irc.freenode.net. """ % project_d, home_page_url="https://launchpad.net/%s" % project, summary="Put a pithy summary of %s here." % project, ) proj.bug_reporting_guidelines = """Enough data to reproduce the behaviour if possible. If that is not possible, just describe as well as you can what is happening and we will talk through the issue with you. """ proj.owner = mgmt proj.lp_save() branch_path = '~%(project)s/%(project)s/trunk' % project_d lp_host = os.environ.get('LAUNCHPAD_API', '') if lp_host: lp_host = '//%s/' % lp_host branch = bzrdir.BzrDir.create_branch_convenience( 'lp:%s%s' % (lp_host, branch_path), force_new_tree=False) series = proj.getSeries(name='trunk') series.branch_link = self.launchpad.load(branch_path) series.lp_save() self.outf.write(""" Project created at %s (sorry about the url. (https://bugs.launchpad.net/launchpadlib/+bug/316694)). You now need to: - set what LP features you are using (https://bugs.launchpad.net/launchpad/+bug/537269) - describe your project (title, summary, description) - upload your code to lp:PROJECT - turn on the mailing list by hand (https://bugs.launchpad.net/launchpad/+bug/537258) """ % proj.self_link) if __name__ == "__main__": main() lptools-0.2.0/bin/lp-bug-dupe-properties0000775000202700020270000001010412030130502020420 0ustar dobeydobey00000000000000#!/usr/bin/python # # Copyright (C) 2012, Canonical Ltd. # Written by Brian Murray # # ################################################################## # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; version 3. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # See file /usr/share/common-licenses/GPL-3 for more details. # # ################################################################## from lptools import config from datetime import datetime import argparse import sys release_tags = [] def check_duplicate(bug, prop, key): if prop == 'reporter': return bug.owner.name if prop == 'month': return datetime.strftime(bug.date_created, '%Y-%m') if prop == 'day': return datetime.strftime(bug.date_created, '%Y-%m-%d') if prop == 'tags': return ' '.join(bug.tags) if prop == 'rtags': rtags = set(release_tags).intersection(bug.tags) return ' '.join(list(rtags)) if prop == 'desc': APPORT_TAGS = ['apport-crash', 'apport-bug', 'apport-kerneloops', 'apport-package'] if not set(APPORT_TAGS).intersection(bug.tags): return description = bug.description if key not in description: return for line in description.splitlines(): if not line.startswith(key): continue if key == line.split(': ')[0]: value = line.split(': ')[-1] return value def main(): parser = argparse.ArgumentParser(prog='lp-bug-dupe-properties') group = parser.add_mutually_exclusive_group() group.add_argument('-r', '--reporter', default=False, action='store_true', help='Display reporter of duplicates') group.add_argument('-m', '--month', default=False, action='store_true', help='Display month duplicates were reported') group.add_argument('-d', '--day', default=False, action='store_true', help='Display day duplicates were reported') group.add_argument('-t', '--tags', default=False, action='store_true', help='Display tags of duplicates') group.add_argument('-rt', '--rtags', default=False, action='store_true', help='Display Ubuntu release tags of duplicates') group.add_argument('-D', '--desc', default=False, type=str, help='Search apport bug description for this key e.g. Package') parser.add_argument('-b', '--bug', type=int, help='Bug number of which to check the duplicates') opts = parser.parse_args() launchpad = config.get_launchpad("bug-dupe-properties") bug_number = opts.bug bug = launchpad.bugs[bug_number] dupe_props = {} if opts.reporter: search = 'reporter' if opts.month: search = 'month' if opts.day: search = 'day' if opts.tags: search = 'tags' if opts.rtags: search = 'rtags' ubuntu = launchpad.distributions['ubuntu'] for series in ubuntu.series: release_tags.append(series.name) if opts.desc: search = 'desc' key = opts.desc else: key = None if bug.number_of_duplicates == 0: print('LP: #%s has no duplicates!' % bug_number) sys.exit(1) for dupe in bug.duplicates: dupe_num = dupe.id prop = check_duplicate(dupe, search, key) if prop in dupe_props.keys(): dupe_props[prop].append(str(dupe_num)) else: dupe_props[prop] = [str(dupe_num)] dupe_count = bug.number_of_duplicates if dupe_count > 1: print('LP: #%s has %s duplicates' % (bug_number, dupe_count)) elif dupe_count == 1: print('LP: #%s has %s duplicate' % (bug_number, dupe_count)) for prop, bugs in sorted(dupe_props.items()): print(' %s: %s' % (prop, ' '.join(bugs))) if __name__ == '__main__': main() lptools-0.2.0/bin/lp-milestones0000775000202700020270000001056012030130502016706 0ustar dobeydobey00000000000000#!/usr/bin/python # # Author: Robert Collins # # Copyright 2010 Canonical Ltd. # # This program is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License version 3, as published # by the Free Software Foundation. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranties of # MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR # PURPOSE. See the GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program. If not, see . """lp-milestones -- An lptools command to work with milestones in launchpad. https://launchpad.net/lptools/ lp-milestones help commands -- list commands """ import time # Might want to make errors import lazy. from bzrlib import errors from launchpadlib.errors import HTTPError from lptools.command import * class cmd_create(LaunchpadCommand): """Create a milestone. lp-milestone create projectname/seriesname/milestonename """ takes_args = ['milestone'] def run(self, milestone): components = milestone.split('/') if len(components) != 3: raise errors.BzrCommandError("milestone (%s) too short or too long." % milestone) projectname, seriesname, milestonename = components # Direct access takes 50% of the time of doing traversal. #proj = self.launchpad.projects[projectname] #series = proj.getSeries(name=seriesname) series = self.launchpad.load(projectname + '/' + seriesname) milestone = series.newMilestone(name=milestonename) class cmd_delete(LaunchpadCommand): """Delete a milestone. lp-milestone delete projectname/milestonename Note that this cannot delete a milestone with releases on it (yet). The server will throw a 500 error, and you may see File "/srv/////lib/lp/registry/model/milestone.py", line 209, in destroySelf "You cannot delete a milestone which has a product release " AssertionError: You cannot delete a milestone which has a product release associated with it. In the trace if you have appropriate access. """ takes_args = ['milestone'] def run(self, milestone): components = milestone.split('/') if len(components) != 2: raise errors.BzrCommandError("milestone (%s) too short or too long." % milestone) m = self.launchpad.load('%s/+milestone/%s' % tuple(components)) try: m.delete() except HTTPError, e: if e.response.status == 404: pass elif e.response.status == 500: self.outf.write("Perhaps the milestone has been released?\n") self.outf.write("If so you can undo this in the web UI.\n") raise else: raise class cmd_release(LaunchpadCommand): """Create a release from a milestone. lp-milestone release projectname/milestonename """ takes_args = ['milestone'] def run(self, milestone): components = milestone.split('/') if len(components) != 2: raise errors.BzrCommandError("milestone (%s) too short or too long." % milestone) m = self.launchpad.load('%s/+milestone/%s' % tuple(components)) now = time.strftime('%Y-%m-%d-%X', time.gmtime()) # note: there is a bug with how the releases are created, don't be surprised # if they are created 'X hours ago' where 'X' is the hour in UTC. m.createProductRelease(date_released=now) class cmd_rename(LaunchpadCommand): """Rename a milestone. lp-milestone rename projectname/milestonename newname """ takes_args = ['milestone', 'newname'] def run(self, milestone, newname): components = milestone.split('/') if len(components) != 2: raise errors.BzrCommandError("milestone (%s) too short or too long." % milestone) if '/' in newname: raise errors.BzrCommandError( "milestones can only be renamed within a project.") m = self.launchpad.load('%s/+milestone/%s' % tuple(components)) m.name = newname m.lp_save() if __name__ == "__main__": main() lptools-0.2.0/bin/lp-grab-attachments0000775000202700020270000000721112030130502017747 0ustar dobeydobey00000000000000#!/usr/bin/python # # Copyright (C) 2007, Canonical Ltd. # Written by Daniel Holbach, # Stefano Rivera, # Brian Murray # # ################################################################## # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; version 3. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # See file /usr/share/common-licenses/GPL-3 for more details. # # ################################################################## from optparse import OptionParser import codecs import errno import os from lptools import config USAGE = "lp-grab-attachments " def download_attachments(bug, descriptions): bug_folder_name = 'bug-%s' % bug.id try: os.mkdir(bug_folder_name) except OSError, error: if error.errno == errno.EEXIST: return if descriptions: description = bug.description filename = os.path.join(os.getcwd(), bug_folder_name, 'Description.txt') local_file = codecs.open(filename, encoding="utf-8", mode="w") local_file.write(description) local_file.close() for attachment in bug.attachments: f = attachment.data.open() filename = os.path.join(os.getcwd(), bug_folder_name, f.filename) local_file = open(filename, "w") local_file.write(f.read()) f.close() local_file.close() def main(): parser = OptionParser('Usage: %prog [options] ') parser.add_option('-d', '--duplicates', default=False, action='store_true', help='Download attachments from duplicates too') parser.add_option('-p', '--package', help='Download attachments from all bugs with an ' 'open task for this Ubuntu source package') parser.add_option('-P', '--project', help='Download attachments from all bugs with a ' 'open task for this project') parser.add_option('-D', '--descriptions', default=False, action='store_true', help='Also download bug descriptions as Description.txt') opts, args = parser.parse_args() if len(args) < 1 and not opts.package and not opts.project: parser.error('No bug numbers provided') launchpad = config.get_launchpad("grab-attachments") if opts.package: ubuntu = launchpad.projects['ubuntu'] src_package = ubuntu.getSourcePackage(name=opts.package) if src_package is None: parser.error('Unable to find package %s' % opts.package) for task in src_package.searchTasks(): args.append(task.bug.id) if opts.project: try: project = launchpad.projects['%s' % opts.project] except KeyError: parser.error('Unable to find project %s' % opts.project) for task in project.searchTasks(): args.append(task.bug.id) for arg in args: try: bug_number = int(arg) except ValueError: parser.error("'%s' is not a valid bug number." % arg) bug = launchpad.bugs[bug_number] download_attachments(bug, opts.descriptions) if opts.duplicates is True: for bug in bug.duplicates: download_attachments(bug, opts.descriptions) if __name__ == '__main__': main() lptools-0.2.0/bin/lp-project-upload0000775000202700020270000001422612030130502017457 0ustar dobeydobey00000000000000#!/usr/bin/python # Copyright (c) 2009 Canonical Ltd. # # This program is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the # Free Software Foundation; either version 2, or (at your option) any # later version. # # lp-project-upload is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # Authors: # Martin Pitt , based on # http://blog.launchpad.net/api/recipe-for-uploading-files-via-the-api # Dustin Kirkland # - support files for changelog and release notes '''Upload a release tarball to a Launchpad project.''' import datetime import os import sys import tempfile from launchpadlib.errors import HTTPError import subprocess from lptools import config def create_release(project, version): '''Create new release and milestone for LP project.''' print 'Release %s could not be found for project. Create it? (Y/n)' % \ version answer = sys.stdin.readline().strip() if answer.startswith('n'): sys.exit(0) n_series = len(project.series) if n_series == 1: series = project.series[0] elif n_series > 1: msg = 'More than one series exist. Which one would you like to ' \ 'upload to? Possible series are (listed as index, name):' print msg for idx, serie in enumerate(project.series): print '\t%i - %s' % (idx, serie.name) print 'Enter series index: ' answer = sys.stdin.readline().strip() try: series = project.series[int(answer)] except (ValueError, IndexError): print >> sys.stderr, 'The series index is invalid (%s).' % answer sys.exit(3) else: print "Using series named '%s'" % series.name else: print >> sys.stderr, ('Does not support creating releases if no ' 'series exists.') sys.exit(3) release_date = datetime.date.today().strftime('%Y-%m-%d') milestone = series.newMilestone(name=version, date_targeted=release_date) return milestone.createProductRelease(date_released=release_date) def edit_file(prefix, description): (fd, f) = tempfile.mkstemp(prefix=prefix+'.') os.write(fd, '\n\n#------\n# Please enter the %s here. ' 'Lines which start with "#" are ignored.\n' % description) os.close(fd) subprocess.call(['sensible-editor', f]) return cat_file(f) def cat_file(f): content = '' for line in open(f): if line.startswith('#'): continue content += line return content.strip() def main(): if len(sys.argv) < 4 or len(sys.argv) > 7: print >> sys.stderr, '''Upload a release tarball to a Launchpad project. Usage: %s [new milestone] [changelog file] [releasenotes file]''' % sys.argv[0] sys.exit(1) new_milestone = None changelog_file = None releasenotes_file = None if len(sys.argv) == 4: (project, version, tarball) = sys.argv[1:] elif len(sys.argv) == 5: (project, version, tarball, new_milestone) = sys.argv[1:] elif len(sys.argv) == 6: (project, version, tarball, new_milestone, changelog_file) = sys.argv[1:] elif len(sys.argv) == 7: (project, version, tarball, new_milestone, changelog_file, releasenotes_file) = sys.argv[1:] launchpad = config.get_launchpad("project-upload") try: # Look up the project using the Launchpad instance. proj = launchpad.projects[project] # Find the release in the project's releases collection. release = None for rel in proj.releases: if rel.version == version: release = rel break if not release: for milestone in proj.all_milestones: if milestone.name == version: today = datetime.date.today().strftime('%Y-%m-%d') release = milestone.createProductRelease(date_released=today) if not release: release = create_release(proj, version) # Get the file contents. file_content = open(tarball, 'r').read() # Get the signature, if available. signature = tarball + '.asc' if not os.path.exists(signature): print 'Calling GPG to create tarball signature...' cmd = ['gpg', '--armor', '--sign', '--detach-sig', tarball] if subprocess.call(cmd) != 0: print >> sys.stderr, 'gpg failed, aborting' if os.path.exists(signature): signature_content = open(signature, 'r').read() else: signature_content = None # Create a new product release file. filename = os.path.basename(tarball) release.add_file(filename=filename, description='release tarball', file_content=file_content, content_type='application/x-gzip', file_type='Code Release Tarball', signature_filename=signature, signature_content=signature_content) if changelog_file is not None: changelog = cat_file(changelog_file) else: changelog = edit_file('changelog', 'changelog') if changelog: release.changelog = changelog if releasenotes_file is not None: release_notes = cat_file(releasenotes_file) else: release_notes = edit_file('releasenotes', 'release notes') if release_notes: release.release_notes = release_notes release.lp_save() # Create a new milestone if requested if new_milestone is not None: mil = release.milestone for series in proj.series: if mil.name in [milestone.name for milestone in series.all_milestones]: series.newMilestone(name=new_milestone) except HTTPError, error: print 'An error happened in the upload:', error.content sys.exit(1) if __name__ == '__main__': main() lptools-0.2.0/PKG-INFO0000664000202700020270000000344212030601767014533 0ustar dobeydobey00000000000000Metadata-Version: 1.1 Name: lptools Version: 0.2.0 Summary: A collection of tools for developers who use launchpad Home-page: https://launchpad.net/lptools Author: Rodney Dawes Author-email: rodney.dawes@canonical.com License: GPLv3 Description: These are some tools for use with projects hosted on Launchpad. * review-notifier [[project2] ...] This tool will present notifications for changes to merge proposals on a project. You currently must pass the list of projects on the command line. * review-list [[project2] ...] This tool will present a list of all the branches currently in the Needs Review state. The list includes the branch name, and the votes on the proposal. You can double-click on a row to open the merge proposal page in your browser. Both tools use launchpadlib, and refresh automatically every 5 minutes as a hardcoded value. The former is not particularly useful with the new review-list script, but I've included it here for completeness. * milestone2ical This tool will convert all the milestones on a project or project group, into an iCalendar 2.0 format file, for importing into a calendar program. * recipe-status This tool will render a status table for all of the recipe builds owned by the specified person. Platform: UNKNOWN Classifier: Development Status :: 4 - Beta Classifier: Intended Audience :: Developers Classifier: License :: OSI Approved :: GNU General Public License v3 (GPL3)Operating System :: OS Independent Classifier: Programming Language :: Python Classifier: Topic :: Software Development lptools-0.2.0/MANIFEST.in0000664000202700020270000000005512030130502015151 0ustar dobeydobey00000000000000include COPYING include MANIFEST.in MANIFEST lptools-0.2.0/lptools/0000775000202700020270000000000012030601767015127 5ustar dobeydobey00000000000000lptools-0.2.0/lptools/__init__.py0000664000202700020270000000147312030130502017225 0ustar dobeydobey00000000000000# Author: Robert Collins # # Copyright 2010 Canonical Ltd. # # This program is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License version 3, as published # by the Free Software Foundation. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranties of # MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR # PURPOSE. See the GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program. If not, see . """LP-tools is largely command line tools. The package contains various helpers. See lptools.config for configuration support logic. """ lptools-0.2.0/lptools/launchpad.py0000664000202700020270000000243612030130502017425 0ustar dobeydobey00000000000000# Author: Robert Collins # # Copyright 2010 Canonical Ltd. # # This program is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License version 3, as published # by the Free Software Foundation. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranties of # MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR # PURPOSE. See the GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program. If not, see . __all__ = [ 'Launchpad', ] """Wrapper class for launchpadlib with tweaks.""" from launchpadlib.launchpad import Launchpad as UpstreamLaunchpad class Launchpad(UpstreamLaunchpad): """Launchpad object with bugfixes.""" def load(self, url_string): """Load an object. Extended to support url_string being a relative url. Needed until bug 524775 is fixed. """ if not url_string.startswith('https:'): return UpstreamLaunchpad.load(self, str(self._root_uri) + url_string) else: return UpstreamLaunchpad.load(self, url_string) lptools-0.2.0/lptools/config.py0000664000202700020270000000365712030130502016741 0ustar dobeydobey00000000000000# Author: Robert Collins # # Copyright 2010 Canonical Ltd. # # This program is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License version 3, as published # by the Free Software Foundation. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranties of # MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR # PURPOSE. See the GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program. If not, see . from __future__ import with_statement """Configuration glue for lptools.""" __all__ = [ "data_dir", "ensure_dir", "get_launchpad", ] import os import os.path from launchpadlib.launchpad import Launchpad def ensure_dir(dir): """Ensure that dir exists.""" if not os.path.isdir(dir): os.makedirs(dir) def get_launchpad(appname, instance=None): """Get a login to launchpad for lptools caching in cachedir. Note that caching is not multiple-process safe in launchpadlib, and the appname parameter is used to create per-app cachedirs. :param appname: The name of the app used to create per-app cachedirs. :param instance: Launchpad instance to use """ if instance is None: instance = os.getenv("LPINSTANCE") if instance is None: instance = "production" return Launchpad.login_with("lptools-%s" % appname, instance) def data_dir(): """Return the arch-independent data directory. """ # Running from source directory? ret = os.path.join(os.path.dirname(__file__), "..") if os.path.exists(os.path.join(ret, "templates")): return ret else: return os.path.abspath(os.path.join(os.path.dirname(__file__), "../../../../share/lptools")) lptools-0.2.0/lptools/command.py0000664000202700020270000000577312030130502017113 0ustar dobeydobey00000000000000# Author: Robert Collins # # Copyright 2010 Canonical Ltd. # # This program is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License version 3, as published # by the Free Software Foundation. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranties of # MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR # PURPOSE. See the GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program. If not, see . """Command abstraction for the CLI parts of lptools. To use: * in your front end script define a docstring - this is used for global help. * from this module import * * derive commands from LaunchpadCommand and call them cmd_NAME. * At the bottom of your script, do:: if __name__ == '__main__': main() """ __all__ = [ 'LaunchpadCommand', 'main', ] import os import sys from bzrlib import commands, ui, version_info as bzr_version_info from lptools import config def list_commands(command_names): mod = sys.modules['__main__'] command_names.update(commands._scan_module_for_commands(mod)) return command_names def get_command(cmd_or_None, cmd_name): if cmd_name is None: return cmd_help() elif cmd_name == 'help': return cmd_help() klass = getattr(sys.modules['__main__'], 'cmd_' + cmd_name, None) if klass is not None: return klass() return cmd_or_None class LaunchpadCommand(commands.Command): """Base class for commands working with launchpad.""" def run_argv_aliases(self, argv, alias_argv=None): # This might not be unique-enough for a cachedir; can do # $frontend/cmdname if needed. self.launchpad = config.get_launchpad(os.path.basename(sys.argv[0])) return commands.Command.run_argv_aliases(self, argv, alias_argv) class cmd_help(commands.Command): """Show help on a command or other topic.""" # Can't use the stock bzrlib help, because the help indices aren't quite # generic enough. takes_args = ['topic?'] def run(self, topic=None): if topic is None: self.outf.write(sys.modules['__main__'].__doc__) else: import bzrlib.help bzrlib.help.help(topic) def do_run_bzr(argv): if bzr_version_info > (2, 2, 0): # in bzr 2.2 we can disable bzr plugins so bzr commands don't show # up. return commands.run_bzr(argv, lambda:None, lambda:None) else: return commands.run_bzr(argv) def main(): commands.Command.hooks.install_named_hook('list_commands', list_commands, "list") commands.Command.hooks.install_named_hook('get_command', get_command, "get") ui.ui_factory = ui.make_ui_for_terminal(sys.stdin, sys.stdout, sys.stderr) sys.exit(commands.exception_to_return_code(do_run_bzr, sys.argv[1:])) lptools-0.2.0/README0000664000202700020270000000202712030130502014274 0ustar dobeydobey00000000000000These are some tools for use with projects hosted on Launchpad. * review-notifier [[project2] ...] This tool will present notifications for changes to merge proposals on a project. You currently must pass the list of projects on the command line. * review-list [[project2] ...] This tool will present a list of all the branches currently in the Needs Review state. The list includes the branch name, and the votes on the proposal. You can double-click on a row to open the merge proposal page in your browser. Both tools use launchpadlib, and refresh automatically every 5 minutes as a hardcoded value. The former is not particularly useful with the new review-list script, but I've included it here for completeness. * milestone2ical This tool will convert all the milestones on a project or project group, into an iCalendar 2.0 format file, for importing into a calendar program. * recipe-status This tool will render a status table for all of the recipe builds owned by the specified person. lptools-0.2.0/COPYING0000664000202700020270000010451312030130502014452 0ustar dobeydobey00000000000000 GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU General Public License is a free, copyleft license for software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: Copyright (C) This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read . lptools-0.2.0/templates/0000775000202700020270000000000012030601767015431 5ustar dobeydobey00000000000000lptools-0.2.0/templates/recipe-status.html0000664000202700020270000000453012030130502021071 0ustar dobeydobey00000000000000 Recipe status for <omit tal:replace="person.name"/>
Recipe
N/A OK

Generated using recipe-status. For the source see lptools.

lptools-0.2.0/templates/recipe-status.css0000664000202700020270000000105112030130502020710 0ustar dobeydobey00000000000000body { background: url(background.png) repeat; color: #222222; font-family: "UbuntuBeta", Ubuntu, "Bitstream Vera Sans", "DejaVu Sans", Tahoma, sans-serif; font-size: 12px; } a { text-decoration: none; } a:hover { text-decoration: underline; } a:visited { color: blue; } .failed-to-upload, .failed-to-build { background: red; } .chroot-problem, .dependency-wait { background: orange; } .not-available { background: gray; } .successfully-built { background: chartreuse; } .partial-success { background: yellow; } lptools-0.2.0/setup.py0000775000202700020270000000177412030130570015146 0ustar dobeydobey00000000000000#!/usr/bin/python from glob import glob from distutils.core import setup import os.path description = file(os.path.join(os.path.dirname(__file__), 'README'), 'rb').read() setup( name='lptools', version='0.2.0', url='https://launchpad.net/lptools', author='Rodney Dawes', author_email='rodney.dawes@canonical.com', license='GPLv3', description='A collection of tools for developers who use launchpad', long_description=description, py_modules=[], data_files=[('share/lptools/templates', ['templates/recipe-status.css', 'templates/recipe-status.html'])], packages=['lptools'], scripts=glob('bin/*'), classifiers = [ 'Development Status :: 4 - Beta', 'Intended Audience :: Developers', 'License :: OSI Approved :: GNU General Public License v3 (GPL3)' 'Operating System :: OS Independent', 'Programming Language :: Python', 'Topic :: Software Development', ], )