1 # SPDX-License-Identifier: GPL-2.0-only
3 # This file is part of Nominatim. (https://nominatim.org)
5 # Copyright (C) 2022 by the Nominatim developer community.
6 # For a full list of authors see the git log.
8 Various smaller helps for step execution.
13 LOG = logging.getLogger(__name__)
15 def run_script(cmd, **kwargs):
16 """ Run the given command, check that it is successful and output
19 proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
21 (outp, outerr) = proc.communicate()
22 outp = outp.decode('utf-8')
23 outerr = outerr.decode('utf-8').replace('\\n', '\n')
24 LOG.debug("Run command: %s\n%s\n%s", cmd, outp, outerr)
26 assert proc.returncode == 0, "Script '{}' failed:\n{}\n{}\n".format(cmd[0], outp, outerr)