synchronously log

Signed-off-by: Xe Iaso <me@christine.website>
This commit is contained in:
Cadey Ratio 2022-05-09 18:34:50 +00:00
parent 2c2f545a9a
commit 43058cbd15
2 changed files with 13 additions and 12 deletions

View File

@ -2,10 +2,12 @@ import json
import os
import pathlib
import subprocess
import sys
class Plugin:
async def log(self, message=""):
print("frontend: " + message)
sys.stdout.flush()
async def whoami(self, *args):
return os.getuid()
@ -30,8 +32,9 @@ class Plugin:
return "impossible state"
async def install_state(self, *args):
result = await self.install_state()
print("status: " + result)
await self.log("fetching state")
result = self.install_state()
await self.log("status: " + result)
return result
# Asyncio-compatible long-running code, executed in a task when the plugin is loaded

View File

@ -5,29 +5,27 @@
<link rel="stylesheet" href="/steam_resource/css/library.css">
<script src="/static/library.js"></script>
<script>
function log(message) {
return call_plugin_method("log", {"message": message});
async function log(message) {
return call_plugin_method("log", {"message": `${message}`);
}
function getUID() {
async function getUID() {
return call_plugin_method("whoami", {});
}
function getInstallState() {
async function getInstallState() {
return call_plugin_method("install_state", {});
}
function getStatus() {
async function getStatus() {
let status = document.getElementById("status");
let installStatus = getInstallState();
log(installStatus);
let installStatus = await getInstallState();
status.innerText = `${installStatus}`;
}
function onReady() {
async function onReady() {
let heading = document.getElementById("heading");
let id = getUID();
let id = await getUID();
heading.innerText = `Hello ${id}`;
}
</script>