blob: 0f3a629a419d35a1b6d6bb516c75883db68d00a8 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
# Copyright (C) 2009, 2010, 2011 Roman Zimbelmann <romanz@lavabit.com>
# This software is distributed under the terms of the GNU GPL version 3.
from subprocess import Popen, PIPE
ENCODING = 'utf-8'
def spawn(*args):
"""Runs a program, waits for its termination and returns its stdout"""
if len(args) == 1:
popen_arguments = args[0]
shell = isinstance(popen_arguments, str)
else:
popen_arguments = args
shell = False
process = Popen(popen_arguments, stdout=PIPE, shell=shell)
stdout, stderr = process.communicate()
return stdout.decode(ENCODING)
|