summaryrefslogtreecommitdiffstats
path: root/gitautodeploy/wrappers/process.py
diff options
context:
space:
mode:
authorOliver Poignant <oliver@poignant.se>2016-03-06 21:05:20 +0100
committerOliver Poignant <oliver@poignant.se>2016-03-06 21:05:20 +0100
commit3f7a830cdadc82f10bad26b060f2701ed08b34a9 (patch)
treee62af59711f37b88e64b6155aaa57904c3f3e7c7 /gitautodeploy/wrappers/process.py
parentec1f2a28c902855aa470f8523eea33f8aed6a2b5 (diff)
downloadGit-Auto-Deploy-3f7a830cdadc82f10bad26b060f2701ed08b34a9.zip
Git-Auto-Deploy-3f7a830cdadc82f10bad26b060f2701ed08b34a9.tar.gz
Git-Auto-Deploy-3f7a830cdadc82f10bad26b060f2701ed08b34a9.tar.bz2
Moved files around into new project structure
Diffstat (limited to 'gitautodeploy/wrappers/process.py')
-rw-r--r--gitautodeploy/wrappers/process.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/gitautodeploy/wrappers/process.py b/gitautodeploy/wrappers/process.py
new file mode 100644
index 0000000..30adc36
--- /dev/null
+++ b/gitautodeploy/wrappers/process.py
@@ -0,0 +1,31 @@
+class ProcessWrapper():
+ """Wraps the subprocess popen method and provides logging."""
+
+ def __init__(self):
+ pass
+
+ @staticmethod
+ def call(*popenargs, **kwargs):
+ """Run command with arguments. Wait for command to complete. Sends
+ output to logging module. The arguments are the same as for the Popen
+ constructor."""
+
+ from subprocess import Popen, PIPE
+ import logging
+ logger = logging.getLogger()
+
+ kwargs['stdout'] = PIPE
+ kwargs['stderr'] = PIPE
+
+ p = Popen(*popenargs, **kwargs)
+ stdout, stderr = p.communicate()
+
+ if stdout:
+ for line in stdout.strip().split("\n"):
+ logger.info(line)
+
+ if stderr:
+ for line in stderr.strip().split("\n"):
+ logger.error(line)
+
+ return p.returncode \ No newline at end of file