Commit 4da86566 authored by Caughlin Bohn's avatar Caughlin Bohn
Browse files

HTC Random Now

parent f49711f1
import time import time
import socket import socket
from random import randint from random import randint,choice
import subprocess import subprocess
workers = { workers = {
"worker1": {"status":0,"time":0}, "worker1": {"status":0,"time":0},
...@@ -30,26 +30,80 @@ def workersToData(workers): ...@@ -30,26 +30,80 @@ def workersToData(workers):
data.append(workers["worker%d" % i]["status"]) data.append(workers["worker%d" % i]["status"])
writeWeb(data) writeWeb(data)
workersToData(workers)
for i in range(1,9): active = []
currentWorker = "worker%d" % i dead = []
print(currentWorker) start = time.time()
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)
for i in range(1,9): for i in range(1,9):
currentWorker = "worker%d" % i dead.append("worker%d" % i)
print(currentWorker) workersToData(workers)
sendLights("%s head 1" % currentWorker)
time.sleep(0.2) while (time.time() - start) < 45:
workers[currentWorker]["status"] = 0 if randint(0,1) == 1 and len(dead) > 0:
workersToData(workers) currentWorker = choice(dead)
print(workers[currentWorker]["status"]) workers[currentWorker]["status"] = 1
time.sleep(0.3) 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 = { workers = {
"worker1": {"status":0,"time":0}, "worker1": {"status":0,"time":0},
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment