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. ...@@ -1048,7 +1048,7 @@ process as the recipe tried.
Installing package. Installing package.
package: Checking whether package is installed at shared path: .../slapos.recipe.cmmi/slapos/recipe/cmmi/shared/package/... package: Checking whether package is installed at shared path: .../slapos.recipe.cmmi/slapos/recipe/cmmi/shared/package/...
package: [ENV] FOO = bar 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. 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. 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 /bin/sh: 1: ./configure: not found
......
...@@ -213,17 +213,10 @@ class Recipe(object): ...@@ -213,17 +213,10 @@ class Recipe(object):
log = logging.getLogger(self.name) log = logging.getLogger(self.name)
args = ['find', self.buildout_prefix, '-cnewer', ref_file, '!', '-type', 'd'] args = ['find', self.buildout_prefix, '-cnewer', ref_file, '!', '-type', 'd']
try: try:
p = subprocess.Popen(args, stdout=subprocess.PIPE, universal_newlines=True) files = subprocess.check_output(args,
files, _ = p.communicate() universal_newlines=True, close_fds=True)
retcode = p.returncode except Exception as e:
if retcode < 0: log.error(e)
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))
raise zc.buildout.UserError('System error') raise zc.buildout.UserError('System error')
return files.splitlines() return files.splitlines()
...@@ -262,16 +255,10 @@ class Recipe(object): ...@@ -262,16 +255,10 @@ class Recipe(object):
"""Run the given ``cmd`` in a child process.""" """Run the given ``cmd`` in a child process."""
log = logging.getLogger(self.name) log = logging.getLogger(self.name)
try: try:
retcode = subprocess.call(cmd, shell=True, env=self.augmented_environment(), close_fds=True) subprocess.check_call(cmd, shell=True,
env=self.augmented_environment(), close_fds=True)
if retcode < 0: except Exception as e:
log.error('Command received signal %s: %s' % (-retcode, cmd)) log.error(e)
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))
raise zc.buildout.UserError('System error') raise zc.buildout.UserError('System error')
def install(self): 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