attempt at making it autonomous

This commit is contained in:
simon987
2019-02-28 20:54:47 -05:00
parent 3986a3109b
commit 3400ee44ea
6 changed files with 103 additions and 56 deletions

View File

@@ -1,13 +1,11 @@
import datetime
import json
import os
import random
import shutil
import subprocess
import time
from subprocess import Popen
from tt_drone.api import Project, Worker, TaskTrackerApi, Task
from tt_drone.api import (Project, Worker, Task)
class WorkerContext:
@@ -62,7 +60,6 @@ class WorkerContext:
json_result["result"],
json_result["verification"] if "verification" in json_result else 0).text)
except Exception as e:
print(e)
return
def _do_post_task_hooks(self, res):
@@ -87,20 +84,3 @@ class WorkerContext:
task.get("max_retries"))
print("SUBMIT: %s <%d>" % (task, r.status_code))
api = TaskTrackerApi("https://tt.simon987.net/api")
w1 = Worker.from_file(api)
ctx = WorkerContext(w1, "main")
while True:
try:
t = w1.fetch_task()
ctx.execute_task(t)
time.sleep(random.randint(5, 45))
except KeyboardInterrupt:
print("Cancel current task...")
try:
w1.release_task(t.id, 2, 0)
except NameError:
pass