mirror of
https://github.com/simon987/task_tracker_drone.git
synced 2025-12-17 09:19:05 +00:00
attempt at making it autonomous
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user