diff options
author | Nirbheek Chauhan <nirbheek@centricular.com> | 2019-03-16 12:01:47 +0530 |
---|---|---|
committer | Nirbheek Chauhan <nirbheek@centricular.com> | 2019-03-18 03:27:28 +0530 |
commit | 6656d8ad023ba4db72a1394978f2909ebe351f0c (patch) | |
tree | 83c4df379bf8d371d59e8c6fadca82f870d27db6 | |
parent | a26947aefbdeaf0e2373ae8a8f7554641a2208dd (diff) |
cerbero/windows: Don't include stderr in .def files
Implement a new check_output that only returns the stdout. We can't
have stderr in the .def file because it can cause lib.exe to error out
because of invalid syntax.
We also need to start moving away from check_call which has very
crufty mechanics.
-rw-r--r-- | cerbero/ide/vs/genlib.py | 3 | ||||
-rw-r--r-- | cerbero/utils/shell.py | 16 |
2 files changed, 18 insertions, 1 deletions
diff --git a/cerbero/ide/vs/genlib.py b/cerbero/ide/vs/genlib.py index 9c086eb6..2b33695d 100644 --- a/cerbero/ide/vs/genlib.py +++ b/cerbero/ide/vs/genlib.py @@ -42,7 +42,8 @@ class GenLib(object): def gendef(self, dllpath, outputdir, libname): defname = libname + '.def' - def_contents = shell.check_call('gendef - %s' % dllpath, outputdir) + def_contents = shell.check_output('gendef - %s' % dllpath, outputdir, + logfile=self.logfile) # If the output doesn't contain a 'LIBRARY' directive, gendef errored # out. However, gendef always returns 0 so we need to inspect the # output and guess. diff --git a/cerbero/utils/shell.py b/cerbero/utils/shell.py index 3e3e1beb..2dc7b35d 100644 --- a/cerbero/utils/shell.py +++ b/cerbero/utils/shell.py @@ -153,6 +153,9 @@ def call(cmd, cmd_dir='.', fail=True, verbose=False, logfile=None, env=None): def check_call(cmd, cmd_dir=None, shell=False, split=True, fail=False, env=None): + ''' + DEPRECATED: Use check_output and a cmd array wherever possible + ''' if env is None and CALL_ENV is not None: env = CALL_ENV.copy() if split and isinstance(cmd, str): @@ -172,6 +175,19 @@ def check_call(cmd, cmd_dir=None, shell=False, split=True, fail=False, env=None) return output + +def check_output(cmd, cmd_dir=None, logfile=None, env=None): + cmd = _cmd_string_to_array(cmd) + try: + o = subprocess.check_output(cmd, cwd=cmd_dir, env=env, stderr=logfile) + except (OSError, subprocess.CalledProcessError) as e: + raise FatalError('Running command: {!r}\n{}'.format(cmd, str(e))) + + if sys.stdout.encoding: + o = o.decode(sys.stdout.encoding, errors='replace') + return o + + async def async_call(cmd, cmd_dir='.', logfile=None, env=None): ''' Run a shell command |