aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/cgi-bin/get.py
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2021-03-03 23:16:36 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2021-03-03 23:16:36 +0300
commit923e2fce6df64b6fd2e203027f2cf216108cb24d (patch)
tree53ea20b4889b34fb5fe5d3ada79137a7e2f3918a /cgi-bin/get.py
parentadd server.py (diff)
downloadlinux-status-923e2fce6df64b6fd2e203027f2cf216108cb24d.tar.gz
linux-status-923e2fce6df64b6fd2e203027f2cf216108cb24d.zip
merge {reboot,poweroff}.sh into get.py
Diffstat (limited to '')
-rwxr-xr-xcgi-bin/get.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/cgi-bin/get.py b/cgi-bin/get.py
index 1453dc2..e852561 100755
--- a/cgi-bin/get.py
+++ b/cgi-bin/get.py
@@ -173,6 +173,28 @@ class TopTask(Task):
return self.task.result()
+class RebootTask(Task):
+ def __init__(self):
+ self.cmd = Command('systemctl', 'reboot')
+
+ def run(self):
+ self.task = self.cmd.run()
+
+ def result(self):
+ return self.task.result()
+
+
+class PoweroffTask(Task):
+ def __init__(self):
+ self.cmd = Command('systemctl', 'poweroff')
+
+ def run(self):
+ self.task = self.cmd.run()
+
+ def result(self):
+ return self.task.result()
+
+
class InstanceStatusTask(Task):
def __init__(self, systemctl):
self.overview_cmd = systemctl('status')
@@ -342,6 +364,8 @@ class Request(Enum):
STATUS = 'status'
TIMERS = 'timers'
TOP = 'top'
+ REBOOT = 'reboot'
+ POWEROFF = 'poweroff'
def __str__(self):
return self.value
@@ -359,6 +383,10 @@ class Request(Enum):
return TimersTask().complete()
if self is Request.TOP:
return TopTask().complete()
+ if self is Request.REBOOT:
+ return RebootTask().complete()
+ if self is Request.POWEROFF:
+ return PoweroffTask().complete()
raise NotImplementedError(f'unknown request: {self}')