From 5f15b0d94c4a9703315f96fe3ce63b9b3906ea84 Mon Sep 17 00:00:00 2001 From: Eric Rasche Date: Thu, 24 Sep 2015 10:30:13 -0500 Subject: [PATCH] Replace backported one with just the code used Sorry bjoern, ripped out what you'd added and just used the code because the doctest was failing for some unknown reason and we didn't ever need to reuse the function, so ... easier this way --- .../web/base/interactive_environments.py | 37 ++++--------------- 1 file changed, 8 insertions(+), 29 deletions(-) diff --git a/lib/galaxy/web/base/interactive_environments.py b/lib/galaxy/web/base/interactive_environments.py index baffdf539b9..27f42f2a0cd 100644 --- a/lib/galaxy/web/base/interactive_environments.py +++ b/lib/galaxy/web/base/interactive_environments.py @@ -5,7 +5,6 @@ import json import stat import random import tempfile -import subprocess from subprocess import Popen, PIPE from galaxy.util.bunch import Bunch @@ -17,32 +16,6 @@ import logging log = logging.getLogger(__name__) -# Python 2.6 does not support the check_output command. -# As a workaround we use a backport from https://gist.github.com/edufelipe/1027906 -# until we do not support Python 2.6 anymore. - -if "check_output" not in dir( subprocess ): - def check_output(*popenargs, **kwargs): - r"""Run command with arguments and return its output as a byte string. - Backported from Python 2.7 as it's implemented as pure python on stdlib. - >>> check_output(['/usr/bin/python', '--version']) - Python 2.6.2 - """ - process = subprocess.Popen(stdout=subprocess.PIPE, *popenargs, **kwargs) - output, unused_err = process.communicate() - retcode = process.poll() - if retcode: - cmd = kwargs.get("args") - if cmd is None: - cmd = popenargs[0] - error = subprocess.CalledProcessError(retcode, cmd) - error.output = output - raise error - return output -else: - from subprocess import check_output - - class InteractiveEnviornmentRequest(object): def __init__(self, trans, plugin): @@ -287,8 +260,14 @@ class InteractiveEnviornmentRequest(object): container_id, command )) - output = check_output(command, shell=True) - inspect_data = json.loads(output) + + p = Popen(command, stdout=PIPE, stderr=PIPE, close_fds=True, shell=True) + stdout, stderr = p.communicate() + if p.returncode != 0 or len(stderr): + log.error( "%s\n%s" % (stdout, stderr) ) + return None + + inspect_data = json.loads(stdout) # [{ # "NetworkSettings" : { # "Ports" : {