Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Holland Computing Center
HCCPiCluster
Commits
4da86566
Commit
4da86566
authored
Jun 07, 2019
by
Caughlin Bohn
Browse files
HTC Random Now
parent
f49711f1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Workers/workDir/HTCWeb.py
View file @
4da86566
import
time
import
socket
from
random
import
randint
from
random
import
randint
,
choice
import
subprocess
workers
=
{
"worker1"
:
{
"status"
:
0
,
"time"
:
0
},
...
...
@@ -30,26 +30,80 @@ def workersToData(workers):
data
.
append
(
workers
[
"worker%d"
%
i
][
"status"
])
writeWeb
(
data
)
workersToData
(
workers
)
for
i
in
range
(
1
,
9
):
currentWorker
=
"worker%d"
%
i
print
(
currentWorker
)
sendLights
(
"head %s 1"
%
currentWorker
)
time
.
sleep
(
0.02
)
workers
[
currentWorker
][
"status"
]
=
1
workersToData
(
workers
)
print
(
workers
[
currentWorker
][
"status"
])
time
.
sleep
(
0.3
)
time
.
sleep
(
15
)
active
=
[]
dead
=
[]
start
=
time
.
time
()
for
i
in
range
(
1
,
9
):
currentWorker
=
"worker%d"
%
i
print
(
currentWorker
)
sendLights
(
"%s head 1"
%
currentWorker
)
time
.
sleep
(
0.2
)
workers
[
currentWorker
][
"status"
]
=
0
workersToData
(
workers
)
print
(
workers
[
currentWorker
][
"status"
])
time
.
sleep
(
0.3
)
dead
.
append
(
"worker%d"
%
i
)
workersToData
(
workers
)
while
(
time
.
time
()
-
start
)
<
45
:
if
randint
(
0
,
1
)
==
1
and
len
(
dead
)
>
0
:
currentWorker
=
choice
(
dead
)
workers
[
currentWorker
][
"status"
]
=
1
sendLights
(
"head %s 1"
%
currentWorker
)
dead
.
remove
(
currentWorker
)
active
.
append
(
currentWorker
)
workersToData
(
workers
)
if
randint
(
0
,
1
)
==
1
and
len
(
active
)
>
0
:
currentWorker
=
choice
(
active
)
if
(
time
.
time
()
-
workers
[
currentWorker
][
"time"
])
>
5
:
workers
[
currentWorker
][
"status"
]
=
0
sendLights
(
"%s head 1"
%
currentWorker
)
workersToData
(
workers
)
active
.
remove
(
currentWorker
)
dead
.
append
(
currentWorker
)
# for i in range(1,9):
# currentWorker = "worker%d" % i
# print(currentWorker)
# sendLights("head %s 1" % currentWorker)
# time.sleep(0.02)
# workers[currentWorker]["status"] = 1
# workersToData(workers)
# print(workers[currentWorker]["status"])
# time.sleep(0.3)
# time.sleep(8)
# for i in range(1,9):
# currentWorker = "worker%d" % i
# print(currentWorker)
# if currentWorker == "worker8":
# sendLights("%s head 1" % "worker1")
# time.sleep(0.2)
# workers["worker1"]["status"] = 1
# workersToData(workers)
# sendLights("%s head 1" % currentWorker)
# time.sleep(0.2)
# workers[currentWorker]["status"] = 0
# workersToData(workers)
# print(workers[currentWorker]["status"])
# time.sleep(0.3)
# for i in range(2,9):
# currentWorker = "worker%d" % i
# print(currentWorker)
# sendLights("head %s 1" % currentWorker)
# time.sleep(0.02)
# workers[currentWorker]["status"] = 1
# workersToData(workers)
# print(workers[currentWorker]["status"])
# time.sleep(0.3)
# time.sleep(8)
# for i in range(1,9):
# currentWorker = "worker%d" % i
# print(currentWorker)
# sendLights("%s head 1" % currentWorker)
# time.sleep(0.2)
# workers[currentWorker]["status"] = 0
# workersToData(workers)
# print(workers[currentWorker]["status"])
# time.sleep(0.3)
workers
=
{
"worker1"
:
{
"status"
:
0
,
"time"
:
0
},
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment