Ejemplo n.º 1
0
def restart_energenie_service():
    cmd = "sudo systemctl restart energenie.service"
    if OSPlatform.is_mac():
        print(cmd)
        return
    if OSPlatform.is_linux():
        os.system(cmd)
        return
    raise NotImplementedError("Restart service for this OS is not implemented")
def validate_write(config_dir):
    if validate(request.get_json()):
        config_class = convert_dict_to_class(request.get_json())
        if OSPlatform.is_mac():
            print(json.dumps(config_class.__dict__, indent=2))
        if OSPlatform.is_linux():
            write(json.dumps(config_class.__dict__, indent=2),
                  config_dir + "/backlight/backlight_config.json")
        return jsonify(config_class.__dict__)
    return jsonify(None)
Ejemplo n.º 3
0
def backlight_control(sleep, cmd):
    # cmd = f"python3 $HOME/rpi_styra/services/main_backlight_on_off.py --{cmd}"
    cmd = f"python3 $HOME/rpi_styra/services/backlight/py/{cmd}.py"
    if OSPlatform.is_linux():
        os.system(cmd)
    print(f"cmd: {cmd}")
Ejemplo n.º 4
0
def energenie_control(sleep, cmd, socket):
    cmd = f"python3 $HOME/rpi_styra/services/energenie/py/{cmd}-{socket}.py"
    if OSPlatform.is_linux():
        os.system(cmd)
    print(f"cmd: {cmd}")
Ejemplo n.º 5
0
def _shutdown(sleep):
    cmd = f"nohup sudo -b bash -c 'sleep {sleep}; shutdown -h now' &> /dev/null; "
    if OSPlatform.is_linux():
        os.system(cmd)
    print(f"cmd: {cmd}")
Ejemplo n.º 6
0
def _reboot(sleep):
    cmd = f"nohup sudo -b bash -c 'sleep {sleep}; reboot' &> /dev/null; "
    if OSPlatform.is_linux():
        os.system(cmd)
    print(f"cmd: {cmd}")