some code...
This commit is contained in:
parent
f9c99d4070
commit
cac342582b
19 changed files with 788 additions and 0 deletions
28
lib/core/command.py
Normal file
28
lib/core/command.py
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
import subprocess
|
||||
|
||||
|
||||
class Command:
|
||||
def __init__(self, command):
|
||||
self.command = command
|
||||
self.output = ""
|
||||
self.error = ""
|
||||
|
||||
def __str__(self):
|
||||
return command
|
||||
|
||||
def hasProcessed(self):
|
||||
return self.output != "" and self.error != ""
|
||||
|
||||
def doProcess(self):
|
||||
process = subprocess.Popen([self.command], stdout=subprocess.PIPE)
|
||||
self.output, self.error = process.communicate()
|
||||
|
||||
def getOutput(self):
|
||||
if not self.hasProcessed():
|
||||
self.doProcess()
|
||||
return self.output
|
||||
|
||||
def getError(self):
|
||||
if not self.hasProcessed():
|
||||
self.doProcess()
|
||||
return self.error
|
||||
Loading…
Add table
Add a link
Reference in a new issue