Commit 2de7734a authored by Julien Muchembled's avatar Julien Muchembled

Clean up use of subprocess

parent a2b331d9
......@@ -1048,7 +1048,7 @@ process as the recipe tried.
Installing package.
package: Checking whether package is installed at shared path: .../slapos.recipe.cmmi/slapos/recipe/cmmi/shared/package/...
package: [ENV] FOO = bar
package: Command failed with exit code 127: ./configure --prefix=".../slapos.recipe.cmmi/slapos/recipe/cmmi/shared/package/..."
package: Command './configure --prefix=".../slapos.recipe.cmmi/slapos/recipe/cmmi/shared/package/..."' returned non-zero exit status 127
package: Compilation error. The package is left as is at .../slapos.recipe.cmmi/slapos/recipe/cmmi/shared/package/...__compile__ where you can inspect what went wrong.
A shell script slapos.recipe.build.env.sh has been generated. You can source it in your shell to reproduce build environment.
/bin/sh: 1: ./configure: not found
......
......@@ -213,17 +213,10 @@ class Recipe(object):
log = logging.getLogger(self.name)
args = ['find', self.buildout_prefix, '-cnewer', ref_file, '!', '-type', 'd']
try:
p = subprocess.Popen(args, stdout=subprocess.PIPE, universal_newlines=True)
files, _ = p.communicate()
retcode = p.returncode
if retcode < 0:
log.error('Command received signal %s: %s' % (-retcode, args))
raise zc.buildout.UserError('System error')
elif retcode > 0:
log.error('Command failed with exit code %s: %s' % (retcode, args))
raise zc.buildout.UserError('System error')
except OSError as e:
log.error('Command failed: %s: %s' % (e, args))
files = subprocess.check_output(args,
universal_newlines=True, close_fds=True)
except Exception as e:
log.error(e)
raise zc.buildout.UserError('System error')
return files.splitlines()
......@@ -262,16 +255,10 @@ class Recipe(object):
"""Run the given ``cmd`` in a child process."""
log = logging.getLogger(self.name)
try:
retcode = subprocess.call(cmd, shell=True, env=self.augmented_environment(), close_fds=True)
if retcode < 0:
log.error('Command received signal %s: %s' % (-retcode, cmd))
raise zc.buildout.UserError('System error')
elif retcode > 0:
log.error('Command failed with exit code %s: %s' % (retcode, cmd))
raise zc.buildout.UserError('System error')
except OSError as e:
log.error('Command failed: %s: %s' % (e, cmd))
subprocess.check_call(cmd, shell=True,
env=self.augmented_environment(), close_fds=True)
except Exception as e:
log.error(e)
raise zc.buildout.UserError('System error')
def install(self):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment