synchronously log
Signed-off-by: Xe Iaso <me@christine.website>
This commit is contained in:
parent
2c2f545a9a
commit
43058cbd15
7
main.py
7
main.py
|
@ -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
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in New Issue