mirror of
				https://git.launchpad.net/ubuntu-dev-tools
				synced 2025-11-04 07:54:03 +00:00 
			
		
		
		
	Wrap all long lines in Python scripts.
This commit is contained in:
		
							parent
							
								
									a3b5e71547
								
							
						
					
					
						commit
						f8d3f9f2f5
					
				
							
								
								
									
										20
									
								
								404main
									
									
									
									
									
								
							
							
						
						
									
										20
									
								
								404main
									
									
									
									
									
								
							@ -101,7 +101,8 @@ def find_main(cache, pack):
 | 
			
		||||
                for or_deps in all_deps:
 | 
			
		||||
                    base_deps = []
 | 
			
		||||
                    for (name, ver, op) in or_deps:
 | 
			
		||||
                        base_deps.append(apt.package.BaseDependency(name, op, ver, False))
 | 
			
		||||
                        base_deps.append(apt.package.BaseDependency(name, op,
 | 
			
		||||
                                                                    ver, False))
 | 
			
		||||
                    deps.append(apt.package.Dependency(base_deps))
 | 
			
		||||
 | 
			
		||||
        process_deps(cache, deps)
 | 
			
		||||
@ -127,16 +128,22 @@ def main():
 | 
			
		||||
        distro = sys.argv[2]
 | 
			
		||||
        if not get_package_version(cache, distro, 'bash'):
 | 
			
		||||
            print '«%s» is not a valid distribution.' % distro
 | 
			
		||||
            print 'Remember that for 404main to work with a certain distribution it must be in your /etc/apt/sources.list file.'
 | 
			
		||||
            print ('Remember that for 404main to work with a certain '
 | 
			
		||||
                   'distribution it must be in your /etc/apt/sources.list '
 | 
			
		||||
                   'file.')
 | 
			
		||||
            sys.exit(1)
 | 
			
		||||
    else:
 | 
			
		||||
        distro = subprocess.Popen(['lsb_release', '-cs'], stdout=subprocess.PIPE).stdout.read().strip('\n')
 | 
			
		||||
        cmd = ['lsb_release', '-cs']
 | 
			
		||||
        process = subprocess.Popen(cmd, stdout=subprocess.PIPE)
 | 
			
		||||
        distro = process.stdout.read().strip('\n')
 | 
			
		||||
 | 
			
		||||
    if not get_package_version(cache, distro, sys.argv[1]):
 | 
			
		||||
        print 'Can\'t find package «%s» in distribution «%s».' % (sys.argv[1], distro)
 | 
			
		||||
        print 'Can\'t find package «%s» in distribution «%s».' % \
 | 
			
		||||
              (sys.argv[1], distro)
 | 
			
		||||
        sys.exit(1)
 | 
			
		||||
 | 
			
		||||
    print 'Checking package «%s» in distribution «%s»...' % (sys.argv[1], distro)
 | 
			
		||||
    print 'Checking package «%s» in distribution «%s»...' % \
 | 
			
		||||
          (sys.argv[1], distro)
 | 
			
		||||
 | 
			
		||||
    find_main(cache, sys.argv[1])
 | 
			
		||||
 | 
			
		||||
@ -151,7 +158,8 @@ def main():
 | 
			
		||||
            print '  ', package
 | 
			
		||||
 | 
			
		||||
    if all_in_main:
 | 
			
		||||
        print 'Package «%s» and all its dependencies and build dependencies are in main.' % sys.argv[1]
 | 
			
		||||
        print ('Package «%s» and all its dependencies and build dependencies '
 | 
			
		||||
               'are in main.') % sys.argv[1]
 | 
			
		||||
 | 
			
		||||
if __name__ == '__main__':
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										45
									
								
								ack-sync
									
									
									
									
									
								
							
							
						
						
									
										45
									
								
								ack-sync
									
									
									
									
									
								
							@ -39,7 +39,8 @@ UPLOAD_NOT_PERMITTED = 4
 | 
			
		||||
def get_version(title):
 | 
			
		||||
    m = re.search("[() ][0-9][0-9a-zA-Z.:+-~]*", title)
 | 
			
		||||
    if m is None:
 | 
			
		||||
        print >> sys.stderr, "Version could not be detected. Please specify it with -V."
 | 
			
		||||
        print >> sys.stderr, ("Version could not be detected. Please specify "
 | 
			
		||||
                              "it with -V.")
 | 
			
		||||
        sys.exit(VERSION_DETECTION_FAILED)
 | 
			
		||||
    return m.group(0).strip("() ")
 | 
			
		||||
 | 
			
		||||
@ -82,14 +83,16 @@ def get_source(package, version, section, dist, uploader_name, uploader_email,
 | 
			
		||||
    if not os.path.exists(os.path.join(workdir, dsc_file)):
 | 
			
		||||
        dsc_file = package + "_" + strip_epoch(version) + ".dsc"
 | 
			
		||||
    if not os.path.exists(os.path.join(workdir, dsc_file)):
 | 
			
		||||
        print >> sys.stderr, "E: Failed to find .dsc file created by syncpackage."
 | 
			
		||||
        print >> sys.stderr, ("E: Failed to find .dsc file created by "
 | 
			
		||||
                              "syncpackage.")
 | 
			
		||||
        sys.exit(1)
 | 
			
		||||
    return dsc_file
 | 
			
		||||
 | 
			
		||||
def build_source(dist, dsc_file):
 | 
			
		||||
    try:
 | 
			
		||||
        if sbuild:
 | 
			
		||||
            subprocess.check_call(LogCall(["sbuild", "-d", dist, "-A", dsc_file]))
 | 
			
		||||
            cmd = ["sbuild", "-d", dist, "-A", dsc_file]
 | 
			
		||||
            subprocess.check_call(LogCall(cmd))
 | 
			
		||||
        else:
 | 
			
		||||
            if not os.path.isdir("buildresult"):
 | 
			
		||||
                os.makedirs("buildresult")
 | 
			
		||||
@ -115,14 +118,16 @@ def test_install(dist, dsc_file):
 | 
			
		||||
    try:
 | 
			
		||||
        cmd = ["sudo", "piuparts", "-N", "-W", "--single-changes-list",
 | 
			
		||||
               "--log-level=info", "--ignore=/var/log/apt/history.log",
 | 
			
		||||
               "--mirror=http://archive.ubuntu.com/ubuntu main universe restricted multiverse",
 | 
			
		||||
               changes_file]
 | 
			
		||||
               "--mirror=http://archive.ubuntu.com/ubuntu main universe "
 | 
			
		||||
               "restricted multiverse", changes_file]
 | 
			
		||||
        if sbuild:
 | 
			
		||||
            subprocess.check_call(LogCall(cmd + ["--lvm-volume="+lvm+"/"+dist+"_chroot"]))
 | 
			
		||||
            lvm_volume = lvm + "/" + dist + "_chroot"
 | 
			
		||||
            subprocess.check_call(LogCall(cmd + ["--lvm-volume="+lvm_volume]))
 | 
			
		||||
        else:
 | 
			
		||||
            subprocess.check_call(LogCall(cmd + ["--pbuilder"]))
 | 
			
		||||
    except subprocess.CalledProcessError:
 | 
			
		||||
        print >> sys.stderr, "E: %s failed to install. Please check log" % (changes_file)
 | 
			
		||||
        print >> sys.stderr, "E: %s failed to install. Please check log" % \
 | 
			
		||||
                             (changes_file)
 | 
			
		||||
 | 
			
		||||
def get_email_from_file(name):
 | 
			
		||||
    filename = os.path.expanduser("~/.ack-sync-email.list")
 | 
			
		||||
@ -140,7 +145,8 @@ def unsubscribe_sponsors(launchpad, bug):
 | 
			
		||||
        bug.unsubscribe(person=ums)
 | 
			
		||||
        print "ubuntu-main-sponsors unsubscribed (for backward compatibility)"
 | 
			
		||||
    except lazr.restfulclient.errors.HTTPError, http_error:
 | 
			
		||||
        print "failed to unsubscribe ubuntu-main-sponsors: " + http_error.content
 | 
			
		||||
        print "failed to unsubscribe ubuntu-main-sponsors: " + \
 | 
			
		||||
              http_error.content
 | 
			
		||||
 | 
			
		||||
    us = launchpad.people['ubuntu-sponsors']
 | 
			
		||||
    bug.unsubscribe(person=us)
 | 
			
		||||
@ -178,10 +184,14 @@ def main(bug_numbers, all_package, all_version, all_section, update,
 | 
			
		||||
                uploader_email = get_email_from_file(uploader.name)
 | 
			
		||||
                if uploader_email is None:
 | 
			
		||||
                    if not silent:
 | 
			
		||||
                        print >> sys.stderr, "E: Bug owner '%s' does not have a public email address. Specify uploader with '-e'." % (uploader_name)
 | 
			
		||||
                        print >> sys.stderr, ("E: Bug owner '%s' does not have "
 | 
			
		||||
                                              "a public email address. Specify "
 | 
			
		||||
                                              "uploader with '-e'.") % \
 | 
			
		||||
                                             (uploader_name)
 | 
			
		||||
                    sys.exit(PRIVATE_USER_EMAIL)
 | 
			
		||||
                elif not silent:
 | 
			
		||||
                    print "Taking email address from local file: " + uploader_email
 | 
			
		||||
                    print "Taking email address from local file: " + \
 | 
			
		||||
                          uploader_email
 | 
			
		||||
 | 
			
		||||
        task = list(bug.bug_tasks)[0]
 | 
			
		||||
 | 
			
		||||
@ -219,7 +229,8 @@ def main(bug_numbers, all_package, all_version, all_section, update,
 | 
			
		||||
                if e.response.status == 403:
 | 
			
		||||
                    can_upload = False
 | 
			
		||||
                elif e.response.status == 400:
 | 
			
		||||
                    print "W: Package is probably not in Ubuntu. Can't check upload rights."
 | 
			
		||||
                    print ("W: Package is probably not in Ubuntu. Can't check "
 | 
			
		||||
                           "upload rights.")
 | 
			
		||||
                    can_upload = True
 | 
			
		||||
                else:
 | 
			
		||||
                    raise e
 | 
			
		||||
@ -233,7 +244,8 @@ def main(bug_numbers, all_package, all_version, all_section, update,
 | 
			
		||||
            print "assigned me"
 | 
			
		||||
            task.lp_save()
 | 
			
		||||
        if task.assignee != launchpad.me:
 | 
			
		||||
            print >> sys.stderr, "E: %s is already assigned to https://launchpad.net/bugs/%i" % \
 | 
			
		||||
            print >> sys.stderr, ("E: %s is already assigned to "
 | 
			
		||||
                                  "https://launchpad.net/bugs/%i") % \
 | 
			
		||||
                                 (task.assignee.display_name, bug.id)
 | 
			
		||||
            sys.exit(1)
 | 
			
		||||
        old_status = task.status
 | 
			
		||||
@ -267,7 +279,8 @@ def main(bug_numbers, all_package, all_version, all_section, update,
 | 
			
		||||
        print '%s (was %s)' % (task.status, old_status)
 | 
			
		||||
        print "Uploader:", uploader_name + " <" + uploader_email + ">"
 | 
			
		||||
        if upload:
 | 
			
		||||
            print "Will upload sync directly, rather than subscribing ubuntu-archive"
 | 
			
		||||
            print ("Will upload sync directly, rather than subscribing "
 | 
			
		||||
                   "ubuntu-archive")
 | 
			
		||||
        try:
 | 
			
		||||
            raw_input('Press [Enter] to continue or [Ctrl-C] to abort.')
 | 
			
		||||
        except KeyboardInterrupt:
 | 
			
		||||
@ -290,7 +303,8 @@ def main(bug_numbers, all_package, all_version, all_section, update,
 | 
			
		||||
            cmd = ["dpkg-architecture", "-qDEB_BUILD_ARCH"]
 | 
			
		||||
            process = subprocess.Popen(cmd, stdout=subprocess.PIPE)
 | 
			
		||||
            architecture = process.communicate()[0].strip()
 | 
			
		||||
            content = "%s %s builds on %s. Sync request ACK'd." % (package, version, architecture)
 | 
			
		||||
            content = "%s %s builds on %s. Sync request ACK'd." % \
 | 
			
		||||
                      (package, version, architecture)
 | 
			
		||||
            bug.newMessage(content=content, subject="ack-sync")
 | 
			
		||||
            bug.subscribe(person=launchpad.people['ubuntu-archive'])
 | 
			
		||||
            print "subscribed ubuntu-archive"
 | 
			
		||||
@ -324,7 +338,8 @@ if __name__ == '__main__':
 | 
			
		||||
        long_opts = ["help", "key=", "lvm=", "package=", "section=", "silent",
 | 
			
		||||
                     "update", "upload", "verbose", "version=", "with-sbuild",
 | 
			
		||||
                     "pbuilder=", "with-piuparts", "lpinstance=", "no-conf"]
 | 
			
		||||
        opts, args = getopt.gnu_getopt(sys.argv[1:], "e:hk:p:PsSC:uUvV:", long_opts)
 | 
			
		||||
        opts, args = getopt.gnu_getopt(sys.argv[1:], "e:hk:p:PsSC:uUvV:",
 | 
			
		||||
                                       long_opts)
 | 
			
		||||
    except getopt.GetoptError, e:
 | 
			
		||||
        # will print something like "option -a not recognized"
 | 
			
		||||
        print >> sys.stderr, str(e)
 | 
			
		||||
 | 
			
		||||
@ -278,7 +278,8 @@ def do_backport(workdir, package, dscfile, version, suffix, release, build,
 | 
			
		||||
        bp_version = bp_version[bp_version.find(':')+1:]
 | 
			
		||||
 | 
			
		||||
    if build:
 | 
			
		||||
        if 0 != do_build(workdir, package, release, bp_version, builder, update):
 | 
			
		||||
        if 0 != do_build(workdir, package, release, bp_version, builder,
 | 
			
		||||
                         update):
 | 
			
		||||
            sys.exit(1)
 | 
			
		||||
    if upload:
 | 
			
		||||
        do_upload(workdir, package, bp_version, upload, prompt)
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										8
									
								
								dgetlp
									
									
									
									
									
								
							
							
						
						
									
										8
									
								
								dgetlp
									
									
									
									
									
								
							@ -87,7 +87,8 @@ class DscParse(object):
 | 
			
		||||
        Given the contents of a .dsc, parse it and extract it's content
 | 
			
		||||
        """
 | 
			
		||||
        self.entries = getEntries(Unsign(data))
 | 
			
		||||
        self.files = [x.strip().split() for x in self.entries['Files'].splitlines()]
 | 
			
		||||
        self.files = [x.strip().split() for x in
 | 
			
		||||
                      self.entries['Files'].splitlines()]
 | 
			
		||||
 | 
			
		||||
    def verify_all(self):
 | 
			
		||||
        """
 | 
			
		||||
@ -266,7 +267,8 @@ if __name__ == "__main__":
 | 
			
		||||
        url = url.replace("www.", "", 1)
 | 
			
		||||
 | 
			
		||||
    if getHost(url) != getHost(base_url):
 | 
			
		||||
        error(1, "Error: This utility only works for files on %s.\nMaybe you want to try dget?", base_url)
 | 
			
		||||
        error(1, "Error: This utility only works for files on %s.\n"
 | 
			
		||||
                 "Maybe you want to try dget?", base_url)
 | 
			
		||||
 | 
			
		||||
    (number, filename) = url.split('/')[3:]
 | 
			
		||||
 | 
			
		||||
@ -289,7 +291,7 @@ if __name__ == "__main__":
 | 
			
		||||
        dsc_data = fd.read()
 | 
			
		||||
        fd.close()
 | 
			
		||||
    except Exception, e:
 | 
			
		||||
        status("Error: Please report this bug, providing the URL and attach"\
 | 
			
		||||
        status("Error: Please report this bug, providing the URL and attach"
 | 
			
		||||
               " the following backtrace")
 | 
			
		||||
        raise
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -98,7 +98,8 @@ def main():
 | 
			
		||||
 | 
			
		||||
        if not os.path.exists(branch.name):
 | 
			
		||||
            print "Branching %s ..." % branch.display_name
 | 
			
		||||
            subprocess.call(["bzr", operation_type, branch.bzr_identity, branch.name])
 | 
			
		||||
            cmd = ["bzr", operation_type, branch.bzr_identity, branch.name]
 | 
			
		||||
            subprocess.call(cmd)
 | 
			
		||||
        else:
 | 
			
		||||
            print "Merging %s ..." % branch.display_name
 | 
			
		||||
            os.chdir(branch.name)
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										12
									
								
								hugdaylist
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								hugdaylist
									
									
									
									
									
								
							@ -32,7 +32,8 @@
 | 
			
		||||
import sys
 | 
			
		||||
from optparse import OptionParser
 | 
			
		||||
 | 
			
		||||
from ubuntutools.lp.libsupport import get_launchpad, translate_web_api, translate_api_web
 | 
			
		||||
from ubuntutools.lp.libsupport import (get_launchpad, translate_web_api,
 | 
			
		||||
                                       translate_api_web)
 | 
			
		||||
 | 
			
		||||
def check_args():
 | 
			
		||||
    howmany = -1
 | 
			
		||||
@ -69,7 +70,8 @@ def filter_unsolved(task):
 | 
			
		||||
    #   the given task
 | 
			
		||||
    # Filter out special types of bugs:
 | 
			
		||||
    # - https://wiki.ubuntu.com/Bugs/HowToTriage#Special%20types%20of%20bugs
 | 
			
		||||
    subscriptions = set(s.person.name for s in task.bug.subscriptions) #this is expensive, parse name out of self_link instead?
 | 
			
		||||
    # this is expensive, parse name out of self_link instead?
 | 
			
		||||
    subscriptions = set(s.person.name for s in task.bug.subscriptions)
 | 
			
		||||
    if (task.status != "Fix Committed" and
 | 
			
		||||
        (not task.assignee or task.assignee.name in ['motu','desktop-bugs']) and
 | 
			
		||||
         'ubuntu-sponsors' not in subscriptions and
 | 
			
		||||
@ -80,7 +82,8 @@ def filter_unsolved(task):
 | 
			
		||||
def main():
 | 
			
		||||
    (howmany, url) = check_args()
 | 
			
		||||
    if len(url.split("?", 1)) == 2:
 | 
			
		||||
        # search options not supported, because there is no mapping web ui options <-> API options
 | 
			
		||||
        # search options not supported, because there is no mapping web ui
 | 
			
		||||
        # options <-> API options
 | 
			
		||||
        print >> sys.stderr, "Options in url are not supported, url: %s" % url
 | 
			
		||||
        sys.exit(1)
 | 
			
		||||
 | 
			
		||||
@ -97,7 +100,8 @@ def main():
 | 
			
		||||
    except Exception, e:
 | 
			
		||||
        x = getattr(e, "response", {})
 | 
			
		||||
        if x.get("status", None) == "404":
 | 
			
		||||
            print >> sys.stderr, "The URL at '%s' does not appear to be a valid url to a product" % url
 | 
			
		||||
            print >> sys.stderr, ("The URL at '%s' does not appear to be a "
 | 
			
		||||
                                  "valid url to a product") % url
 | 
			
		||||
            sys.exit(1)
 | 
			
		||||
        else:
 | 
			
		||||
            raise
 | 
			
		||||
 | 
			
		||||
@ -26,7 +26,8 @@ from launchpadlib.errors import HTTPError
 | 
			
		||||
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
 | 
			
		||||
    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)
 | 
			
		||||
@ -50,7 +51,8 @@ def create_release(project, version):
 | 
			
		||||
        else:
 | 
			
		||||
            print "Using series named '%s'" % series.name
 | 
			
		||||
    else:
 | 
			
		||||
        print >> sys.stderr, 'Does not support creating releases if no series exists.'
 | 
			
		||||
        print >> sys.stderr, ('Does not support creating releases if no '
 | 
			
		||||
                              'series exists.')
 | 
			
		||||
        sys.exit(3)
 | 
			
		||||
 | 
			
		||||
    release_date = datetime.date.today().strftime('%Y-%m-%d')
 | 
			
		||||
@ -60,8 +62,8 @@ def create_release(project, version):
 | 
			
		||||
 | 
			
		||||
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.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])
 | 
			
		||||
    content = ''
 | 
			
		||||
@ -108,7 +110,8 @@ try:
 | 
			
		||||
    signature = tarball + '.asc'
 | 
			
		||||
    if not os.path.exists(signature):
 | 
			
		||||
        print 'Calling GPG to create tarball signature...'
 | 
			
		||||
        if subprocess.call(['gpg', '--armor', '--sign', '--detach-sig', tarball]) != 0:
 | 
			
		||||
        cmd = ['gpg', '--armor', '--sign', '--detach-sig', tarball]
 | 
			
		||||
        if subprocess.call(cmd) != 0:
 | 
			
		||||
            print >> sys.stderr, 'gpg failed, aborting'
 | 
			
		||||
 | 
			
		||||
    if os.path.exists(signature):
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										11
									
								
								lp-shell
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								lp-shell
									
									
									
									
									
								
							@ -50,13 +50,14 @@ if len(args) >= 2:
 | 
			
		||||
        print 'I: Falling back to "1.0".'
 | 
			
		||||
 | 
			
		||||
if options.anonymous:
 | 
			
		||||
    lp = Launchpad.login_anonymously('udt-lp-shell', instance, version=api_version)
 | 
			
		||||
    banner = 'Connected anonymously to LP service "%s" with API version "%s":' % (
 | 
			
		||||
            instance, api_version)
 | 
			
		||||
    lp = Launchpad.login_anonymously('udt-lp-shell', instance,
 | 
			
		||||
                                     version=api_version)
 | 
			
		||||
    banner = 'Connected anonymously to LP service "%s" with API version "%s":' \
 | 
			
		||||
             % (instance, api_version)
 | 
			
		||||
else:
 | 
			
		||||
    lp = Launchpad.login_with('udt-lp-shell', instance, version=api_version)
 | 
			
		||||
    banner = 'Connected to LP service "%s" with API version "%s":' % (
 | 
			
		||||
            instance, api_version)
 | 
			
		||||
    banner = 'Connected to LP service "%s" with API version "%s":' % \
 | 
			
		||||
             (instance, api_version)
 | 
			
		||||
 | 
			
		||||
banner += '\nNote: LP can be accessed through the "lp" object.'
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -42,7 +42,8 @@ class CmdOptions(OptionParser):
 | 
			
		||||
            dest="output", default=None),
 | 
			
		||||
        make_option("-l", "--level", action="store", type="int",
 | 
			
		||||
            dest="level", default=0,
 | 
			
		||||
            help="integer representing the access-level (default: 0), mapping: %s" %LEVEL),
 | 
			
		||||
            help="integer representing the access-level (default: 0), "
 | 
			
		||||
                 "mapping: %s" % LEVEL),
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
    TOOLS = {
 | 
			
		||||
@ -58,7 +59,8 @@ class CmdOptions(OptionParser):
 | 
			
		||||
 | 
			
		||||
    def parse_args(self, args=None, values=None):
 | 
			
		||||
        options, args = OptionParser.parse_args(self, args, values)
 | 
			
		||||
        given_options = set(i for i, k in self.defaults.iteritems() if not getattr(options, i) == k)
 | 
			
		||||
        given_options = set(i for i, k in self.defaults.iteritems()
 | 
			
		||||
                            if not getattr(options, i) == k)
 | 
			
		||||
 | 
			
		||||
        if not args:
 | 
			
		||||
            self.error("Please define a sub-tool you would like to use")
 | 
			
		||||
@ -70,17 +72,20 @@ class CmdOptions(OptionParser):
 | 
			
		||||
                self.error("Unknown tool '%s'" %tool)
 | 
			
		||||
        needed_options = set(self.TOOLS[tool][0]) - given_options
 | 
			
		||||
        if needed_options:
 | 
			
		||||
            self.error("Please define the following options: %s" %", ".join(needed_options))
 | 
			
		||||
            self.error("Please define the following options: %s" % \
 | 
			
		||||
                       ", ".join(needed_options))
 | 
			
		||||
        optional_options = given_options - set(sum(self.TOOLS[tool], ()))
 | 
			
		||||
        if optional_options:
 | 
			
		||||
            self.error("The following options are not allowed for this tool: %s" %", ".join(optional_options))
 | 
			
		||||
            self.error("The following options are not allowed for this tool: "
 | 
			
		||||
                       "%s" % ", ".join(optional_options))
 | 
			
		||||
        options.service = lookup_service_root(options.service)
 | 
			
		||||
        if options.level in LEVEL:
 | 
			
		||||
            options.level = LEVEL[options.level]
 | 
			
		||||
        elif options.level.upper() in LEVEL.values():
 | 
			
		||||
            options.level = options.level.upper()
 | 
			
		||||
        else:
 | 
			
		||||
            self.error("Unknown access-level '%s', level must be in %s" %(options.level, LEVEL))
 | 
			
		||||
            self.error("Unknown access-level '%s', level must be in %s" %
 | 
			
		||||
                       (options.level, LEVEL))
 | 
			
		||||
        return tool, options
 | 
			
		||||
 | 
			
		||||
def create_credentials(options):
 | 
			
		||||
@ -110,7 +115,8 @@ def create_credentials(options):
 | 
			
		||||
 | 
			
		||||
def list_tokens(options):
 | 
			
		||||
    print "Not implemented yet."
 | 
			
		||||
    print "To get a list of your tokens, please visit %speople/+me/+oauth-tokens" % translate_api_web(options.service)
 | 
			
		||||
    print ("To get a list of your tokens, please visit "
 | 
			
		||||
           "%speople/+me/+oauth-tokens") % translate_api_web(options.service)
 | 
			
		||||
    return 1
 | 
			
		||||
 | 
			
		||||
def main():
 | 
			
		||||
 | 
			
		||||
@ -28,11 +28,13 @@ from tempfile import mkstemp
 | 
			
		||||
try:
 | 
			
		||||
    from debian.changelog import Changelog
 | 
			
		||||
except ImportError:
 | 
			
		||||
    print 'This utility requires modules from the «python-debian» package, which isn\'t currently installed.'
 | 
			
		||||
    print ('This utility requires modules from the «python-debian» package, '
 | 
			
		||||
           'which isn\'t currently installed.')
 | 
			
		||||
    sys.exit(1)
 | 
			
		||||
 | 
			
		||||
if not os.path.exists('/usr/bin/reportbug'):
 | 
			
		||||
    print 'This utility requires the «reportbug» package, which isn\'t currently installed.'
 | 
			
		||||
    print ('This utility requires the «reportbug» package, which isn\'t '
 | 
			
		||||
           'currently installed.')
 | 
			
		||||
    sys.exit(1)
 | 
			
		||||
 | 
			
		||||
def get_most_recent_debian_version(changelog):
 | 
			
		||||
@ -41,7 +43,7 @@ def get_most_recent_debian_version(changelog):
 | 
			
		||||
            return v.full_version
 | 
			
		||||
 | 
			
		||||
def get_bug_body(changelog):
 | 
			
		||||
    return '''In Ubuntu, the attached patch was applied to achieve the following:
 | 
			
		||||
    msg = """In Ubuntu, the attached patch was applied to achieve the following:
 | 
			
		||||
 | 
			
		||||
## ---------------- REPLACE THIS WITH ACTUAL INFORMATION ---------------------
 | 
			
		||||
## Please add all necessary information about why the change needed to go in
 | 
			
		||||
@ -53,7 +55,8 @@ def get_bug_body(changelog):
 | 
			
		||||
%s
 | 
			
		||||
 | 
			
		||||
Thanks for considering the patch.
 | 
			
		||||
''' % ("\n".join([a for a in changelog._blocks[0].changes()]))
 | 
			
		||||
""" % ("\n".join([a for a in changelog._blocks[0].changes()]))
 | 
			
		||||
    return msg
 | 
			
		||||
 | 
			
		||||
def gen_debdiff(changelog):
 | 
			
		||||
    pkg = changelog.package
 | 
			
		||||
@ -66,7 +69,8 @@ def gen_debdiff(changelog):
 | 
			
		||||
 | 
			
		||||
    if os.system('bzr diff -r tag:%s > /dev/null 2>&1' % oldver) == 256:
 | 
			
		||||
        print "Extracting bzr diff between %s and %s" % (oldver, newver)
 | 
			
		||||
        cmd = 'bzr diff -r tag:%s | filterdiff -x "*changelog*" > %s' % (oldver, debdiff)
 | 
			
		||||
        cmd = 'bzr diff -r tag:%s | filterdiff -x "*changelog*" > %s' % \
 | 
			
		||||
              (oldver, debdiff)
 | 
			
		||||
        run_cmd(cmd)
 | 
			
		||||
    else:
 | 
			
		||||
        if oldver.epoch is not None:
 | 
			
		||||
@ -81,7 +85,8 @@ def gen_debdiff(changelog):
 | 
			
		||||
        check_file(newdsc)
 | 
			
		||||
 | 
			
		||||
        print "Generating debdiff between %s and %s" % (oldver, newver)
 | 
			
		||||
        cmd = 'debdiff %s %s | filterdiff -x "*changelog*" > %s' % (olddsc, newdsc, debdiff)
 | 
			
		||||
        cmd = 'debdiff %s %s | filterdiff -x "*changelog*" > %s' % \
 | 
			
		||||
              (olddsc, newdsc, debdiff)
 | 
			
		||||
        run_cmd(cmd)
 | 
			
		||||
 | 
			
		||||
    return debdiff
 | 
			
		||||
@ -99,7 +104,10 @@ def edit_debdiff(debdiff):
 | 
			
		||||
    run_cmd(cmd)
 | 
			
		||||
 | 
			
		||||
def submit_bugreport(body, debdiff, changelog):
 | 
			
		||||
    cmd = 'reportbug -P "User: ubuntu-devel@lists.ubuntu.com" -P "Usertags: origin-ubuntu natty ubuntu-patch" -T patch -A %s -B debian -i %s -V %s %s' % (debdiff, body, deb_version, changelog.package)
 | 
			
		||||
    cmd = ('reportbug -P "User: ubuntu-devel@lists.ubuntu.com" '
 | 
			
		||||
           '-P "Usertags: origin-ubuntu natty ubuntu-patch" -T patch -A %s '
 | 
			
		||||
           '-B debian -i %s -V %s %s') % \
 | 
			
		||||
          (debdiff, body, deb_version, changelog.package)
 | 
			
		||||
    run_cmd(cmd)
 | 
			
		||||
 | 
			
		||||
def run_cmd(cmd):
 | 
			
		||||
@ -107,7 +115,8 @@ def run_cmd(cmd):
 | 
			
		||||
        print "%s\n" % cmd
 | 
			
		||||
    os.system(cmd)
 | 
			
		||||
 | 
			
		||||
changelog_file = check_file('debian/changelog', critical = False) or check_file('../debian/changelog')
 | 
			
		||||
changelog_file = (check_file('debian/changelog', critical = False) or
 | 
			
		||||
                  check_file('../debian/changelog'))
 | 
			
		||||
changelog = Changelog(file(changelog_file).read())
 | 
			
		||||
 | 
			
		||||
deb_version = get_most_recent_debian_version(changelog)
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user