feat: Add function to cast to Trotec VNC viewer
This commit is contained in:
parent
b38843332f
commit
5e218ccba0
14
main.py
14
main.py
|
@ -1,4 +1,4 @@
|
||||||
import os, logging
|
import os, logging, subprocess
|
||||||
DEBUG = os.environ.get('DEBUG')
|
DEBUG = os.environ.get('DEBUG')
|
||||||
logging.basicConfig(
|
logging.basicConfig(
|
||||||
format='[%(asctime)s] %(levelname)s %(module)s/%(funcName)s - %(message)s',
|
format='[%(asctime)s] %(levelname)s %(module)s/%(funcName)s - %(message)s',
|
||||||
|
@ -13,6 +13,18 @@ def cast_spell():
|
||||||
logging.info(f"Received POST request on /cast. Request data: {request.data}")
|
logging.info(f"Received POST request on /cast. Request data: {request.data}")
|
||||||
return "Cast successful!", 200
|
return "Cast successful!", 200
|
||||||
|
|
||||||
|
def cast_trotec():
|
||||||
|
"""Executes the xtightvncviewer command."""
|
||||||
|
command = "DISPLAY=:1 xtightvncviewer -viewonly -fullscreen 172.17.17.214"
|
||||||
|
try:
|
||||||
|
logging.info(f"Executing command: {command}")
|
||||||
|
subprocess.run(command, shell=True, check=True)
|
||||||
|
logging.info("Command executed successfully.")
|
||||||
|
except subprocess.CalledProcessError as e:
|
||||||
|
logging.error(f"Command failed with error: {e}")
|
||||||
|
except FileNotFoundError:
|
||||||
|
logging.error(f"Command not found: xtightvncviewer. Please ensure it is installed and in PATH.")
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
app.run(debug=DEBUG, host='0.0.0.0', port=int(os.environ.get('PORT', 5000)))
|
app.run(debug=DEBUG, host='0.0.0.0', port=int(os.environ.get('PORT', 5000)))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user