Skip to content

Commit

Permalink
Add uptime command
Browse files Browse the repository at this point in the history
  • Loading branch information
bill88t committed Jul 25, 2024
1 parent d5ab8b8 commit 3771597
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
1 change: 1 addition & 0 deletions base/Beryllium/bin/uptime.lja
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fpexec /bin/uptime.py
42 changes: 42 additions & 0 deletions base/Beryllium/bin/uptime.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
rename_process("uptime")
vr("tt", time.localtime())
vr(
"dat",
[
vr("tt").tm_hour,
vr("tt").tm_min,
vr("tt").tm_sec,
],
)

for pv[get_pid()]["i"] in range(3):
vr("dat")[vr("i")] = str(vr("dat")[vr("i")])
if len(str(vr("dat")[vr("i")])) < 2:
vr("dat")[vr("i")] = "0" + vr("dat")[vr("i")]

term.nwrite(" " + ":".join(vr("dat")) + " up ")

clear_process_storage()

vr("timef", pv[0]["uptimee"] + time.monotonic())
vr("time", int(vr("timef")))
vr("hr", vr("time") // 3600)
vrm("time", vr("hr") * 3600)
vr("min", vr("time") // 60)
vrm("time", vr("min") * 60)

vr("hr", str(vr("hr")))
if len(vr("hr")) < 2:
vr("hr", "0" + vr("hr"))
vrp("hr", ":")
vr("min", str(vr("min")))
if len(vr("min")) < 2:
vr("min", "0" + vr("min"))
vrp("min", ":")
vr("time", str(vr("time")))
if len(vr("time")) < 2:
vr("time", "0" + vr("time"))
term.nwrite(vr("hr") + vr("min") + vr("time"))
term.write(", 1 user, load average: 1.00, 1.00, 1.00")

be.api.setvar("return", "0")

0 comments on commit 3771597

Please sign in to comment.