Skip to content

Commit 02327ae

Browse files
committed
streaming work
1 parent 339802c commit 02327ae

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

Content/Scripts/upycmd.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,27 @@ def run(process, path=_PythonHomePath, verbose=True):
7878
ue.log(stdoutdata[1])
7979
return stdoutdata[1] #return the data for dependent functions
8080

81+
def runStreaming(process, callback=None, path=_PythonHomePath, verbose=True):
82+
#todo: change folder
83+
fullcommand = FolderCommand(path) + process
84+
85+
if verbose:
86+
print("Started cmd <" + fullcommand + ">")
87+
88+
#streaming version
89+
popenobj = subprocess.Popen(fullcommand, stdout=subprocess.PIPE)
90+
output = ''
91+
for line in iter(process.stdout.readline, ''):
92+
#sys.stdout.write(line)
93+
print(line)
94+
output += line
95+
96+
97+
if verbose:
98+
print("cmd Result: ")
99+
print(output)
100+
return output #return the data for dependent functions
101+
81102
#convenience override
82103
def runLogOutput(process, path=_PythonHomePath):
83104
fullcommand = FolderCommand(path) + process

0 commit comments

Comments
 (0)