framework/cg/utils/cmd_proc.py

27 lines
934 B
Python
Raw Normal View History

2023-09-12 09:07:30 +00:00
# coding: utf-8
# Copyright (C) 2023 Ilia Kurochkin <brothermechanic@gmail.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
import subprocess
def cmd_proc(*args, **kwargs):
command = list(args)
for akey, aval in kwargs.items():
command.append(f'--{akey}')
command.append(str(aval))
return subprocess.run(command,
check=True,
stdout=subprocess.PIPE,
encoding='utf-8').stdout