X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=dak%2Fexamine_package.py;h=63ee8af5ce303d01fbe19afcbff0386d881b9666;hb=fdbef587c29814f97c192de5a8b7e9f09cc45fa4;hp=56bb477e49a34801f6363a8f691d3c4b24e6f12b;hpb=dfcf4071605b938bc472062973545e0abe392bfc;p=dak.git diff --git a/dak/examine_package.py b/dak/examine_package.py index 56bb477e..63ee8af5 100755 --- a/dak/examine_package.py +++ b/dak/examine_package.py @@ -56,7 +56,7 @@ import md5 import apt_pkg import apt_inst import shutil -import commands +import subprocess import threading from daklib import utils @@ -67,6 +67,7 @@ from daklib.regexes import html_escaping, re_html_escaping, re_version, re_space re_contrib, re_nonfree, re_localhost, re_newlinespace, \ re_package, re_doc_directory from daklib.dak_exceptions import ChangesUnicodeError +import daklib.daksubprocess ################################################################################ @@ -455,12 +456,16 @@ def output_deb_info(suite, filename, packagename, session = None): to_print += " "+format_field(key,field_value)+'\n' return to_print -def do_command (command, filename, escaped=False): - o = os.popen("%s %s" % (command, filename)) - if escaped: - return escaped_text(o.read()) - else: - return formatted_text(o.read()) +def do_command (command, escaped=False): + process = daklib.daksubprocess.Popen(command, stdout=subprocess.PIPE) + o = process.stdout + try: + if escaped: + return escaped_text(o.read()) + else: + return formatted_text(o.read()) + finally: + process.wait() def do_lintian (filename): cnf = Config() @@ -474,9 +479,9 @@ def do_lintian (filename): if use_html: color = 'html' - cmd.extend(['lintian', '--show-overrides', '--color', color]) + cmd.extend(['lintian', '--show-overrides', '--color', color, "--", filename]) - return do_command(' '.join(cmd), filename, escaped=True) + return do_command(cmd, escaped=True) def get_copyright (deb_filename): global printed @@ -508,19 +513,20 @@ def get_readme_source (dsc_filename): tempdir = utils.temp_dirname() os.rmdir(tempdir) - cmd = "dpkg-source --no-check --no-copy -x %s %s" % (dsc_filename, tempdir) - (result, output) = commands.getstatusoutput(cmd) - if (result != 0): + cmd = ('dpkg-source', '--no-check', '--no-copy', '-x', dsc_filename, tempdir) + try: + daklib.daksubprocess.check_output(cmd, stderr=1) + except subprocess.CalledProcessError as e: res = "How is education supposed to make me feel smarter? Besides, every time I learn something new, it pushes some\n old stuff out of my brain. Remember when I took that home winemaking course, and I forgot how to drive?\n" res += "Error, couldn't extract source, WTF?\n" - res += "'dpkg-source -x' failed. return code: %s.\n\n" % (result) - res += output + res += "'dpkg-source -x' failed. return code: %s.\n\n" % (e.returncode) + res += e.output return res path = os.path.join(tempdir, 'debian/README.source') res = "" if os.path.exists(path): - res += do_command("cat", path) + res += do_command(["cat", "--", path]) else: res += "No README.source in this package\n\n" @@ -563,7 +569,7 @@ def check_deb (suite, deb_filename, session = None): "binary-%s-lintian"%packagename, do_lintian(deb_filename)) + "\n" result += foldable_output("contents of %s" % (filename), "binary-%s-contents"%packagename, - do_command("dpkg -c", deb_filename)) + "\n" + do_command(["dpkg", "-c", deb_filename])) + "\n" if is_a_udeb: result += foldable_output("skipping copyright for udeb", @@ -631,7 +637,9 @@ def main (): try: if not Options["Html-Output"]: # Pipe output for each argument through less - less_fd = os.popen("less -R -", 'w', 0) + less_cmd = ("less", "-R", "-") + less_process = daklib.daksubprocess.Popen(less_cmd, stdin=subprocess.PIPE, bufsize=0) + less_fd = less_process.stdin # -R added to display raw control chars for colour sys.stdout = less_fd try: @@ -650,6 +658,7 @@ def main (): if not Options["Html-Output"]: # Reset stdout here so future less invocations aren't FUBAR less_fd.close() + less_process.wait() sys.stdout = stdout_fd except IOError as e: if errno.errorcode[e.errno] == 'EPIPE':