Commit b49abc2c authored by Artur Safin's avatar Artur Safin

Fix script for os commands

parent 10da44e5
import subprocess
import os
def execute (command, directory = None, verbosity = 1):
def execute (command, directory = None, verbosity = 1, executable = None):
"""Execute an application command (including any arguments) in a command line shell."""
PIPE = subprocess.PIPE
if verbosity:
print (' : -> Executing: %s' % command)
process = subprocess.Popen ([command], cwd = directory, shell = True, stdout = PIPE, stderr = PIPE, env = os.environ.copy ())
process.communicate ()
process = subprocess.Popen ([command], cwd = directory, shell = True, stdout = PIPE, stderr = PIPE, env = os.environ.copy (), executable=executable)
output, error = process.communicate ()
if verbosity:
if process.returncode == 0:
......@@ -17,8 +17,8 @@ def execute (command, directory = None, verbosity = 1):
print (' : -> Shell command returned a non-zero exit code.')
print (' : -> The standard output and the standard error are printed below.')
print (' : -> STDOUT:')
print (process.stdout.decode ('ascii'))
print (output.decode ('ascii'))
print (' : -> STDERR:')
print (process.stderr.decode ('ascii'))
print (error.decode ('ascii'))
return process.returncode
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment