source: ogClient-Git/src/linux/ogOperations.py

Last change on this file was 79d3062, checked in by Jose M. Guisado <jguisado@…>, 3 years ago

Revert "#1065 linux: add systray icon"

This reverts commit 69d214f63b2aa8ef60489d56468393b70795124a.

  • Property mode set to 100644
File size: 1.8 KB
Line 
1#
2# Copyright (C) 2021 Soleta Networks <info@soleta.eu>
3#
4# This program is free software: you can redistribute it and/or modify it under
5# the terms of the GNU Affero General Public License as published by the
6# Free Software Foundation; either version 3 of the License, or
7# (at your option) any later version.
8
9import os
10import subprocess
11from subprocess import CalledProcessError
12
13from src.ogRest import ThreadState
14
15class OgLinuxOperations:
16
17    def _restartBrowser(self, url):
18        raise NotImplementedError
19
20    def poweroff(self):
21        os.system('systemctl poweroff')
22
23    def reboot(self):
24        os.system('systemctl reboot')
25
26    def shellrun(self, request, ogRest):
27        cmd = request.getrun()
28        try:
29            result = subprocess.run(cmd,
30                                    shell=True,
31                                    stdin=subprocess.DEVNULL,
32                                    capture_output=True,
33                                    text=True,
34                                    check=True)
35        except CalledProcessError as error:
36            if error.stderr:
37                return error.stderr
38            if error.stdout:
39                return error.stdout
40            return "{Non zero exit code and empty output}"
41        return result.stdout
42
43    def session(self, request, ogRest):
44        raise NotImplementedError
45
46    def hardware(self, path, ogRest):
47        raise NotImplementedError
48
49    def setup(self, request, ogRest):
50        raise NotImplementedError
51
52    def image_restore(self, request, ogRest):
53        raise NotImplementedError
54
55    def image_create(self, path, request, ogRest):
56        raise NotImplementedError
57
58    def refresh(self, ogRest):
59        return {"status": "LINUX"}
60
61    def probe(self, ogRest):
62        return {'status': 'LINUX' if ogRest.state != ThreadState.BUSY else 'BSY'}
Note: See TracBrowser for help on using the repository browser.