Files
cef/tools/exec_util.py
Marshall Greenblatt e88e98f061 tools: Add VSCode setup (fixes #3906)
Add tooling to set up a Visual Studio Code development environment
for CEF. See script output for usage.

Run: python3 tools/setup_vscode.py
2025-03-20 13:53:33 -04:00

42 lines
1.1 KiB
Python

# Copyright (c) 2014 The Chromium Embedded Framework Authors. All rights
# reserved. Use of this source code is governed by a BSD-style license that
# can be found in the LICENSE file
from __future__ import absolute_import
from subprocess import Popen, PIPE
import sys
def exec_cmd(cmd, path, input_string=None, output_file=None):
""" Execute the specified command and return the result. """
out = ''
err = ''
ret = -1
parts = cmd.split()
if input_string is None:
process = Popen(
parts,
cwd=path,
stdout=PIPE if output_file is None else output_file,
stderr=PIPE,
shell=(sys.platform == 'win32'))
out, err = process.communicate()
ret = process.returncode
else:
process = Popen(
parts,
cwd=path,
stdin=PIPE,
stdout=PIPE if output_file is None else output_file,
stderr=PIPE,
shell=(sys.platform == 'win32'))
out, err = process.communicate(input=input_string)
ret = process.returncode
return {
'out': out.decode('utf-8') if output_file is None else None,
'err': err.decode('utf-8'),
'ret': ret
}