Merge ~racb/ubuntu-dev-tools:pull-debian-source-edge-cases into ubuntu-dev-tools:master

Proposed by Robie Basak
Status: Merged
Merged at revision: 3f87486de37dc6d1505dbfa85f6ae5230e7dd087
Proposed branch: ~racb/ubuntu-dev-tools:pull-debian-source-edge-cases
Merge into: ubuntu-dev-tools:master
Diff against target: 120 lines (+20/-15)
2 files modified
pull-debian-source (+13/-8)
ubuntutools/archive.py (+7/-7)
Reviewer Review Type Date Requested Status
Mattia Rizzolo Approve
Review via email: mp+326608@code.launchpad.net

Description of the change

Fix some pull-debian-source edge cases

To post a comment you must log in.
Revision history for this message
Mattia Rizzolo (mapreri) wrote :

tbh I'd rather have https://code.launchpad.net/~ddstreet/ubuntu-dev-tools/+git/ubuntu-dev-tools/+merge/322863 in and obsolete this one, if @ddstreet gets around to submit it :)

Revision history for this message
Mattia Rizzolo (mapreri) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/pull-debian-source b/pull-debian-source
2index d4e0519..6bfc5fb 100755
3--- a/pull-debian-source
4+++ b/pull-debian-source
5@@ -1,4 +1,4 @@
6-#!/usr/bin/python
7+#!/usr/bin/python3
8 #
9 # pull-debian-source -- pull a source package from Launchpad
10 # Copyright (C) 2011, Stefano Rivera <stefanor@ubuntu.com>
11@@ -19,7 +19,8 @@
12 import json
13 import optparse
14 import sys
15-import urllib2
16+import urllib.request
17+import urllib.error
18
19 from distro_info import DebianDistroInfo, DistroDataOutdated
20
21@@ -54,17 +55,17 @@ def source_package_for(binary, release):
22 """Query DDE to find the source package for a particular binary"""
23 try:
24 release = DebianDistroInfo().codename(release, default=release)
25- except DistroDataOutdated, e:
26+ except DistroDataOutdated as e:
27 Logger.warn(e)
28 url = ('http://dde.debian.net/dde/q/udd/dist/d:debian/r:%s/p:%s/?t=json'
29 % (release, binary))
30 data = None
31 try:
32- data = json.load(urllib2.urlopen(url))['r']
33- except urllib2.URLError, e:
34+ data = json.load(urllib.request.urlopen(url))['r']
35+ except urllib.error.URLError as e:
36 Logger.error('Unable to retrieve package information from DDE: '
37 '%s (%s)', url, str(e))
38- except ValueError, e:
39+ except ValueError as e:
40 Logger.error('Unable to parse JSON response from DDE: '
41 '%s (%s)', url, str(e))
42 if not data:
43@@ -89,6 +90,10 @@ def main():
44 parser.add_option('--no-conf',
45 dest='no_conf', default=False, action='store_true',
46 help="Don't read config files or environment variables")
47+ parser.add_option('--no-verify-signature',
48+ dest='verify_signature', default=True,
49+ action='store_false',
50+ help="Allow signature verification failure")
51 (options, args) = parser.parse_args()
52 if not args:
53 parser.error('Must specify package name')
54@@ -128,8 +133,8 @@ def main():
55 mirrors=[options.debian_mirror,
56 options.debsec_mirror])
57 try:
58- srcpkg.pull()
59- except DownloadError, e:
60+ srcpkg.pull(verify_signature=options.verify_signature)
61+ except DownloadError as e:
62 Logger.error('Failed to download: %s', str(e))
63 sys.exit(1)
64 if not options.download_only:
65diff --git a/ubuntutools/archive.py b/ubuntutools/archive.py
66index 9324313..0e6e219 100644
67--- a/ubuntutools/archive.py
68+++ b/ubuntutools/archive.py
69@@ -303,10 +303,10 @@ class SourcePackage(object):
70 else:
71 Logger.info(message)
72
73- def _write_dsc(self):
74+ def _write_dsc(self, verify_signature=True):
75 "Write dsc file to workdir"
76 if self._dsc is None:
77- self.pull_dsc()
78+ self.pull_dsc(verify_signature=verify_signature)
79 with open(self.dsc_pathname, 'wb') as f:
80 f.write(self.dsc.raw_text)
81
82@@ -359,9 +359,9 @@ class SourcePackage(object):
83 return False
84 return True
85
86- def pull(self):
87+ def pull(self, verify_signature=True):
88 "Pull into workdir"
89- self._write_dsc()
90+ self._write_dsc(verify_signature=verify_signature)
91 for entry in self.dsc['Files']:
92 name = entry['name']
93 for url in self._source_urls(name):
94@@ -471,7 +471,7 @@ class DebianSourcePackage(SourcePackage):
95 if self.snapshot_list:
96 yield self._snapshot_url(name)
97
98- def pull_dsc(self):
99+ def pull_dsc(self, verify_signature=True):
100 "Retrieve dscfile and parse"
101 try:
102 super(DebianSourcePackage, self).pull_dsc()
103@@ -489,7 +489,7 @@ class DebianSourcePackage(SourcePackage):
104 break
105 else:
106 raise DownloadError('dsc could not be found anywhere')
107- self._check_dsc(verify_signature=True)
108+ self._check_dsc(verify_signature=verify_signature)
109
110 # Local methods:
111 @property
112@@ -636,7 +636,7 @@ def rmadison(url, package, suite=None, arch=None):
113
114 # pylint bug: http://www.logilab.org/ticket/46273
115 # pylint: disable=E1103
116- for line in output.strip().splitlines():
117+ for line in output.decode().strip().splitlines():
118 # pylint: enable=E1103
119 pkg, ver, dist, archs = [x.strip() for x in line.split('|')]
120 comp = 'main'

Subscribers

People subscribed via source and target branches