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()
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
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"
"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",
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:
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':
import pwd
import apt_pkg, apt_inst
import examine_package
+import subprocess
import daklib.daksubprocess
from sqlalchemy import or_
suite_name = upload.target_suite.suite_name
handler = PolicyQueueUploadHandler(upload, session)
missing = [(m['type'], m["package"]) for m in handler.missing_overrides(hints=missing)]
+
+ less_cmd = ("less", "-R", "-")
+ less_process = daklib.daksubprocess.Popen(less_cmd, bufsize=0, stdin=subprocess.PIPE)
try:
- sys.stdout = os.popen("less -R -", 'w', 0)
+ sys.stdout = less_process.stdin
print examine_package.display_changes(suite_name, changes)
source = upload.source
print examined
print examine_package.output_package_relations()
+ less_process.stdin.close()
except IOError as e:
if e.errno == errno.EPIPE:
utils.warn("[examine_package] Caught EPIPE; skipping.")
except KeyboardInterrupt:
utils.warn("[examine_package] Caught C-c; skipping.")
finally:
+ less_process.wait()
sys.stdout = save_stdout
################################################################################