-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathframeScraper.py
More file actions
40 lines (33 loc) · 1.01 KB
/
frameScraper.py
File metadata and controls
40 lines (33 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import subprocess
import sys
import threading
# def processFrame(frame)
def processStream(text):
lines = text.splitlines()
endPoint = -1
startPoint = -1
for i in range(len(lines) - 1, 0, -1):
l = lines[i]
if l == "MoCap Frame End":
print("found frame")
endPoint = i
break
for j in range(endPoint, 0, -1):
l = lines[j]
if l == "MoCap Frame Begin":
startPoint = j
break
print(f"Last Frame Start: {startPoint}, End: {endPoint}")
return "\n".join(lines[startPoint:endPoint+1])
def on_timeout(proc, status_dict):
status_dict['timeout'] = True
proc.kill()
def scrape():
status_dict = {'timeout':False}
p = subprocess.Popen(["python", "C:.\PythonClient\PythonSample.py"], stdout=subprocess.PIPE)
recentText = p.stdout.read1().decode("utf-8")
timer = threading.Timer(1, on_timeout, (p, status_dict))
timer.start()
p.wait()
timer.cancel()
return processStream(recentText)