Skip to content
Snippets Groups Projects
Commit d71256c7 authored by Anael Beutot's avatar Anael Beutot
Browse files

Add utils function for handling subprocess.

parent 616abe5a
No related branches found
No related tags found
No related merge requests found
import subprocess
def and_(iter):
"""Do an and logic condition over the iterable element.
......@@ -8,3 +11,17 @@ def and_(iter):
return False
return True
def subproc_call(args, stdin=None):
"""
:param args: arguments for subprocess call
:param stdin: stdin data as string
"""
proc = subprocess.Popen(args, bufsize=4096, stdin=subprocess.PIPE,
stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
result, _ = proc.communicate(stdin)
if proc.returncode != 0:
raise subprocess.CalledProcessError(proc.returncode,
'Error while executing command')
return result
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment