diff options
author | Javier Jardón <jjardon@gnome.org> | 2017-07-19 16:09:13 +0000 |
---|---|---|
committer | Javier Jardón <jjardon@gnome.org> | 2017-07-19 16:09:13 +0000 |
commit | e48b216e362c43a32f5c688757550364f4ca338d (patch) | |
tree | a2beec7496c373d41791a8bdb85a52c775b53ec4 | |
parent | f85165679ba7c351f5182a2cff2cd857ee86518a (diff) | |
parent | 36311180c841f208689aa2eca9386953ed77bb0b (diff) | |
download | ybd-e48b216e362c43a32f5c688757550364f4ca338d.tar.gz |
Merge branch 'benbrown/tidyup' into 'master'
Small fixes/tidy ups
See merge request !374
-rw-r--r-- | ybd/rpm.py | 14 | ||||
-rw-r--r-- | ybd/sandbox.py | 8 | ||||
-rw-r--r-- | ybd/utils.py | 8 |
3 files changed, 13 insertions, 17 deletions
@@ -14,7 +14,7 @@ import yaml import repos import requests import tempfile -import errno +import utils # Because rpm is otherwise totally broken @@ -572,16 +572,8 @@ def package_rpms(system, whitelist=None): command = 'rpm ' + common_rpm_args + ' --initdb' # os.path.exists turned out to be unreliable, so ensuring the # directories exist is done via catching any EEXIST errors. - try: - os.makedirs(rpmdb_path) - except OSError as e: - if e.errno == errno.EEXIST: - pass - try: - os.makedirs(rpmdir) - except OSError as e: - if e.errno == errno.EEXIST: - pass + utils.makedirs(rpmdb_path, exist_ok=True) + utils.makedirs(rpmdir, exist_ok=True) sandbox.run_sandboxed(system, command, env_vars) diff --git a/ybd/sandbox.py b/ybd/sandbox.py index fe72b07..5314bd2 100644 --- a/ybd/sandbox.py +++ b/ybd/sandbox.py @@ -18,7 +18,6 @@ import sandboxlib import contextlib import os -import errno import pipes import shutil import stat @@ -79,11 +78,7 @@ def install(dn, component, subdir=None): destdir = dn['sandbox'] else: destdir = os.path.join(dn['sandbox'], subdir) - try: - os.mkdir(destdir) - except OSError as e: - if e.errno == errno.EEXIST: - pass + utils.makedirs(destdir, exist_ok=True) # populate destdir with the artifact files from component if os.path.exists(os.path.join(destdir, 'baserock', component['name'] + '.meta')): @@ -169,6 +164,7 @@ def run_sandboxed(dn, command, env=None, allow_parallel=False, # lazy load it in the chroot is made. unused = "Some Text".encode('string-escape') + out = err = "" argv = ['sh', '-c', '-e', command] cur_makeflags = env.get("MAKEFLAGS") diff --git a/ybd/utils.py b/ybd/utils.py index a3493e7..9ee321e 100644 --- a/ybd/utils.py +++ b/ybd/utils.py @@ -490,3 +490,11 @@ def tempdir(dir=None): yield tempdir finally: shutil.rmtree(tempdir, ignore_errors=True) + + +def makedirs(name, exist_ok=False, **kwargs): + try: + os.makedirs(name, **kwargs) + except OSError as e: + if exist_ok and e.errno == errno.EEXIST: + pass |