Package linspector :: Package lib :: Package core :: Module command
[hide private]
[frames] | no frames]

Source Code for Module linspector.lib.core.command

 1  import subprocess as sp 
 2  from subprocess import CalledProcessError 
 3  from datetime import datetime as dt 
 4   
5 -class Command:
6 - def __init__(self, command):
7 self.command = command 8 self.output = "" 9 self.error = "" 10 self.retcode = 0 11 self.commandStart=0
12
13 - def __str__(self):
14 return self.command
15
16 - def call(self):
17 ''' 18 self.commandStart = dt.now() 19 "called at: " 20 process = sp.Popen(stdout=PIPE, *popenargs, **kwargs) 21 self.output, self.error = process.communicate() 22 self.retcode = process.poll() 23 ''' 24 try: 25 print self.command 26 self.output=sp.check_output(self.command.split(),stderr=sp.STDOUT) 27 28 except CalledProcessError: 29 self.error=CalledProcessError.output 30 self.retcode = CalledProcessError.returncode
31
32 - def getOutput(self):
33 return self.output
34
35 - def getError(self):
36 return self.error
37
38 - def getReturnCode(self):
39 return self.retcode
40