mirror of
https://git.launchpad.net/ubuntu-dev-tools
synced 2025-03-13 08:01:09 +00:00
Merge branch 'ubuntutools-misc' of git+ssh://git.launchpad.net/ubuntu-dev-tools
MR: https://code.launchpad.net/~ubuntu-dev/ubuntu-dev-tools/+git/ubuntu-dev-tools/+merge/372627 Signed-off-by: Mattia Rizzolo <mattia@debian.org>
This commit is contained in:
commit
c8602ba8a2
12
debian/changelog
vendored
12
debian/changelog
vendored
@ -1,9 +1,13 @@
|
||||
ubuntu-dev-tools (0.174) UNRELEASED; urgency=medium
|
||||
ubuntu-dev-tools (0.174) UNRLEASED; urgency=medium
|
||||
|
||||
* reverse-depends: Support Reverse-Testsuite-Triggers and
|
||||
Reverse-Build-Depends-Arch (LP: #1843614)
|
||||
[ Stefano Rivera ]
|
||||
* reverse-depends:
|
||||
+ Support reverse test dependencies as well. LP: #1843614
|
||||
* ubuntutools.misc:
|
||||
+ Replace Popen() calls with check_output(). Closes: #940040
|
||||
+ Use a context manager to open file, to be sure to close them.
|
||||
|
||||
-- Stefano Rivera <stefanor@debian.org> Wed, 11 Sep 2019 16:00:27 -0300
|
||||
-- Mattia Rizzolo <mattia@debian.org> Thu, 12 Sep 2019 14:34:16 +0200
|
||||
|
||||
ubuntu-dev-tools (0.173) unstable; urgency=medium
|
||||
|
||||
|
@ -23,10 +23,10 @@
|
||||
# ##################################################################
|
||||
|
||||
# Modules.
|
||||
from subprocess import Popen, PIPE
|
||||
import locale
|
||||
import os
|
||||
import sys
|
||||
from subprocess import check_output, CalledProcessError
|
||||
|
||||
import distro_info
|
||||
|
||||
@ -47,29 +47,22 @@ def system_distribution_chain():
|
||||
global _system_distribution_chain
|
||||
if len(_system_distribution_chain) == 0:
|
||||
try:
|
||||
p = Popen(('dpkg-vendor', '--query', 'Vendor'),
|
||||
stdout=PIPE, encoding='utf-8')
|
||||
_system_distribution_chain.append(p.communicate()[0].strip())
|
||||
except OSError:
|
||||
vendor = check_output(('dpkg-vendor', '--query', 'Vendor'),
|
||||
encoding='utf-8').strip()
|
||||
_system_distribution_chain.append(vendor)
|
||||
except CalledProcessError:
|
||||
print('Error: Could not determine what distribution you are running.')
|
||||
return []
|
||||
|
||||
while True:
|
||||
try:
|
||||
p = Popen(('dpkg-vendor',
|
||||
'--vendor', _system_distribution_chain[-1],
|
||||
'--query', 'Parent'),
|
||||
stdout=PIPE, encoding='utf-8')
|
||||
parent = p.communicate()[0].strip()
|
||||
# Don't check return code, because if a vendor has no
|
||||
# parent, dpkg-vendor returns 1
|
||||
if not parent:
|
||||
parent = check_output((
|
||||
'dpkg-vendor', '--vendor', _system_distribution_chain[-1],
|
||||
'--query', 'Parent'), encoding='utf-8').strip()
|
||||
except CalledProcessError:
|
||||
# Vendor has no parent
|
||||
break
|
||||
_system_distribution_chain.append(parent)
|
||||
except Exception:
|
||||
print(('Error: Could not determine the parent of the '
|
||||
'distribution %s' % _system_distribution_chain[-1]))
|
||||
return []
|
||||
|
||||
return _system_distribution_chain
|
||||
|
||||
@ -91,14 +84,18 @@ def host_architecture():
|
||||
architecture can't be determined, print an error message and return None.
|
||||
"""
|
||||
|
||||
arch = Popen(['dpkg', '--print-architecture'], stdout=PIPE,
|
||||
stderr=PIPE).communicate()[0].split()
|
||||
try:
|
||||
arch = check_output(('dpkg', '--print-architecture'),
|
||||
encoding='utf-8').strip()
|
||||
except CalledProcessError:
|
||||
arch = None
|
||||
|
||||
if not arch or 'not found' in arch[0]:
|
||||
print('Error: Not running on a Debian based system; could not detect its architecture.')
|
||||
if not arch or 'not found' in arch:
|
||||
print('Error: Not running on a Debian based system; '
|
||||
'could not detect its architecture.')
|
||||
return None
|
||||
|
||||
return arch[0]
|
||||
return arch
|
||||
|
||||
|
||||
def readlist(filename, uniq=True):
|
||||
@ -112,7 +109,8 @@ def readlist(filename, uniq=True):
|
||||
print('File "%s" does not exist.' % filename)
|
||||
return False
|
||||
|
||||
content = open(filename).read().replace('\n', ' ').replace(',', ' ')
|
||||
with open(filename) as f:
|
||||
content = f.read().replace('\n', ' ').replace(',', ' ')
|
||||
|
||||
if not content.strip():
|
||||
print('File "%s" is empty.' % filename)
|
||||
|
Loading…
x
Reference in New Issue
Block a user