From eee4c697d51a9bee3dac45235a8e6819a34ca9f9 Mon Sep 17 00:00:00 2001 From: Jonathan Davies Date: Fri, 2 Jan 2009 13:18:53 +0000 Subject: [PATCH] * requestsync: Implemented sleeps to --lp bug reporting in case of a slow Launchpad to stop mass bug filing (LP: #311289). --- debian/changelog | 2 ++ requestsync | 20 ++++++++++++++++---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/debian/changelog b/debian/changelog index eb32110..8959ba2 100644 --- a/debian/changelog +++ b/debian/changelog @@ -8,6 +8,8 @@ ubuntu-dev-tools (0.51) UNRELEASED; urgency=low - Use optparse instead of getopt for option parsing. - Skip existing bug report check if python-launchpad-bugs is not installed. + - Implemented sleeps to --lp bug reporting in case of a slow + Launchpad to stop mass bug filing (LP: #311289). -- Jonathan Davies Tue, 30 Dec 2008 15:51:55 +0000 diff --git a/requestsync b/requestsync index 5a799cd..e24a2bb 100755 --- a/requestsync +++ b/requestsync @@ -32,6 +32,7 @@ import urllib import urllib2 from debian_bundle.changelog import Version from optparse import OptionParser +from time import sleep # Use functions from ubuntu-dev-tools to create Launchpad cookie file. sys.path.append('/usr/share/ubuntu-dev-tools/') @@ -339,12 +340,11 @@ def post_bug(source_package, subscribe, status, bugtitle, bugtext): try: import launchpadbugs.connector + from launchpadbugs.lpconstants import HTTPCONNECTION except ImportError: print >> sys.stderr, 'Importing launchpadbugs failed. Is python-launchpad-bugs installed?' return False - print "Using cookie file at", launchpad_cookiefile - if source_package: product = {'name': source_package, 'target': 'ubuntu'} else: @@ -366,20 +366,32 @@ def post_bug(source_package, subscribe, status, bugtitle, bugtext): in_confirm_loop = False break else: - print "Invalid answer" + print "Invalid answer." # Create bug Bug = launchpadbugs.connector.ConnectBug() - Bug.authentication = launchpad_cookiefile + # Force the usage of stable Launchpad. + Bug.set_connection_mode(HTTPCONNECTION.MODE.STABLE) + # Use our cookie file for authentication. + Bug.authentication = launchpad_cookiefile + print "Using LP cookie at: %s for authentication." % launchpad_cookiefile + + # Submit bug report. bug = Bug.New(product = product, summary = bugtitle, description = bugtext) + sleep(2) # Wait in case of slow Launchpad. + try: bug.importance = 'Wishlist' except IOError, s: print "Warning: setting importance failed: %s" % s + bug.status = status bug.subscriptions.add(subscribe) + sleep(1) # Wait. + bug.commit() + sleep(1) # Wait. print 'Sync request filed as bug #%i: https://launchpad.net/bugs/%i' % (bug.bugnumber, bug.bugnumber)