Skip to content

Commit

Permalink
Fix loading
Browse files Browse the repository at this point in the history
  • Loading branch information
zdimension committed Aug 1, 2024
1 parent 9ed6a11 commit 756a16f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
8 changes: 7 additions & 1 deletion desktop.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,13 @@ def log_display():
task = asyncio.create_task(fetch_edf.fetch_loop())
import ui
_ = ui
nui.timer(0.1, lambda: task.done() and nui.open("/app"))
done = False
def timer_callback():
nonlocal done
if not done and task.done():
nui.open("/app")
done = True
nui.timer(0.1, timer_callback)

@nui.page("/")
async def index():
Expand Down
3 changes: 3 additions & 0 deletions fetch_edf.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,9 @@ def add_prices_pdf():
cur.execute("INSERT OR REPLACE INTO edf_plan_slice VALUES (?, ?, ?, ?, ?, ?, ?, ?)",
(plan, dt, power, sub, day_kind, hp, hc, dt_end))

log_callback("committing to db")
db.commit()
log_callback("done")

async def fetch_apis():
await fetch_enedis()
Expand All @@ -364,5 +366,6 @@ async def fetch_apis():


async def fetch_loop():
log_callback("fetch loop")
await fetch_apis()
add_prices_pdf()

0 comments on commit 756a16f

Please sign in to comment.