Skip to content

Commit

Permalink
using consolemsg step to have som feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
vokimon committed Aug 17, 2022
1 parent 9162dd2 commit a657125
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions scripts/tomatic_timetablelauncher.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import dbconfig
import time
import uuid
from consolemsg import step

template = """\
No he pogut completar la graella per la setmana.
Expand Down Expand Up @@ -62,6 +63,7 @@ def api(url):
)
return ns.loads(response.content)

step("Timetables: Lauching timetable for {monday}")
result = apiPost('/api/planner/api/run',
nlines=config.nTelefons,
monday=monday,
Expand All @@ -75,22 +77,28 @@ def api(url):
uploaduri = f"/api/planner/api/upload/{execution_id}"
killuri = f"/api/planner/api/kill/{execution_id}"

step("Timetables: Sleepning for {hours} hours until completition")
time.sleep(minutes*60)
step("Timetables: Sleepning for {hours} hours until completition")

status = api(statusuri)
print(status.dump())

if status.get('status') != 'Stopped':
step("Timetables: Still running, stopping")
stop = api(stopuri).get('ok')
if not stop:
step("Timetables: Still running, killing")
kill = api(killuri)

if status.unfilledCell == "Complete":
step("Timetables: Complete, uploading")
response = api(uploaduri)
if response.get('ok')!=True:
pass # TODO: ERROR
sys.exit()

step("Timetables: Inomplete, sending report email")
sendMail(
sender=dbconfig.tomatic.dailystats.sender,
to=['david.garcia@somenergia.coop'],
Expand Down

0 comments on commit a657125

Please sign in to comment.