forked from joey-kilgore/PyFarm
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPyFarmChild.py
More file actions
78 lines (65 loc) · 1.84 KB
/
PyFarmChild.py
File metadata and controls
78 lines (65 loc) · 1.84 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import PyFarm
import time
import platform
argIndex = 0
numArgs = 1
def getIdNum():
id = 1
cell = PyFarm.sheet2.cell(id+1,1)
while cell.value != '':
id += 1
cell =PyFarm.sheet2.cell(id+1,1)
PyFarm.sheet2.update_cell(id+1,1,'Machine Connected')
PyFarm.sheet2.update_cell(id+1,2, id)
PyFarm.sheet2.update_cell(id+1,3, platform.processor())
return id
def runScript():
script = getScript()
global argIndex
global numArgs
while getArgs():
print(str(PyFarm.arg))
finalScript = script[:script.find("import PyFarm")] + "\nPyFarm.setInput("+str(PyFarm.arg)+")\n"+script[script.find("import PyFarm"):]+"\nPyFarm.sendOutput("+str(argIndex)+","+str(numArgs)+")\nPyFarm.clearOutput()"
#Start Elapsed Time
exec(finalScript)
#Get Elapsed Time
PyFarm.sheet1.update_cell(argIndex,1,'1')
argIndex = 0
numArgs = 1
PyFarm.sheet2.update_cell(1,1,'')
argIndex = 0
numArgs = 1
runScript()
def getScript():
script = ''
while script == '':
time.sleep(5)
script = PyFarm.sheet2.cell(1,1).value
return script
def getArgs():
# query for args
global argIndex
status = '-1'
while status != '0' and status != '':
argIndex += 1
status = PyFarm.sheet1.cell(argIndex,1).value
argList = []
global id
# if there are args
if status == '0':
PyFarm.sheet1.update_cell(argIndex,1,id)
# set args
global numArgs
arg = '0'
while arg != '':
numArgs += 1
arg = PyFarm.sheet1.cell(argIndex,numArgs).value
if arg != '':
argList.append(arg)
PyFarm.setInput(argList)
return True
else:
return False
PyFarm.makeConnection()
id = getIdNum()
runScript()