subprocess.py 1002 B

123456789101112131415161718192021222324252627282930
  1. #
  2. # Copyright (c) 2021 Project CHIP Authors
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. #
  16. """Subprocess utilities."""
  17. import logging
  18. import subprocess
  19. from typing import List
  20. from memdf.util.config import Config
  21. def run_tool_pipe(config: Config, command: List[str]) -> subprocess.Popen:
  22. """Run a command."""
  23. if tool := config.getl(['tool', command[0]]):
  24. command[0] = tool
  25. logging.info('Execute: %s', ' '.join(command))
  26. return subprocess.Popen(command, stdout=subprocess.PIPE)