Add basic windows control system. Needs VM functional to continue
This commit is contained in:
parent
9ac8f95982
commit
0bbfa2d49c
1
.gitignore
vendored
1
.gitignore
vendored
@ -2,3 +2,4 @@ venv
|
|||||||
__pycache__
|
__pycache__
|
||||||
cables
|
cables
|
||||||
.vscode
|
.vscode
|
||||||
|
output.log
|
@ -2,7 +2,7 @@ core:
|
|||||||
mode: winclient
|
mode: winclient
|
||||||
serverip: 192.168.1.20
|
serverip: 192.168.1.20
|
||||||
clientip: 192.168.1.21
|
clientip: 192.168.1.21
|
||||||
server: Hyper-Vs
|
server: Hyper-V
|
||||||
|
|
||||||
arm:
|
arm:
|
||||||
ip: 192.168.1.145
|
ip: 192.168.1.145
|
||||||
|
@ -8,6 +8,7 @@ git+https://github.com/Byeongdulee/python-urx.git
|
|||||||
psycopg2
|
psycopg2
|
||||||
pyyaml
|
pyyaml
|
||||||
Flask
|
Flask
|
||||||
|
selenium
|
||||||
|
|
||||||
# Development
|
# Development
|
||||||
matplotlib
|
matplotlib
|
||||||
|
34
run.py
34
run.py
@ -17,6 +17,7 @@ import signal
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
config = None
|
config = None
|
||||||
keeprunning = True
|
keeprunning = True
|
||||||
arm_ready = False
|
arm_ready = False
|
||||||
@ -90,24 +91,27 @@ def mainloop_server(pool):
|
|||||||
killall()
|
killall()
|
||||||
counter = counter + 1
|
counter = counter + 1
|
||||||
|
|
||||||
|
def run_loading_app():
|
||||||
|
|
||||||
def setup_client(pool, config):
|
|
||||||
# Windows client setup
|
|
||||||
|
|
||||||
# Open loading wepage
|
|
||||||
def run_app():
|
|
||||||
from flask import Flask, render_template
|
from flask import Flask, render_template
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
|
|
||||||
@app.route('/')
|
@app.route('/')
|
||||||
def index():
|
def index():
|
||||||
return render_template('index.html')
|
return render_template('index.html')
|
||||||
|
|
||||||
app.run(debug=True, use_reloader=False)
|
app.run(debug=True, use_reloader=False)
|
||||||
|
|
||||||
p = Process(target=run_app)
|
def setup_client(pool):
|
||||||
|
# Windows client setup
|
||||||
|
global config
|
||||||
|
|
||||||
|
# Open loading wepage
|
||||||
|
p = Process(target=run_loading_app)
|
||||||
p.start()
|
p.start()
|
||||||
|
|
||||||
|
firefox = webdriver.Firefox()
|
||||||
|
firefox.fullscreen_window()
|
||||||
|
firefox.get('http://localhost:5000')
|
||||||
|
|
||||||
# start Linux server VM
|
# start Linux server VM
|
||||||
if config["core"]["server"] == "Hyper-V":
|
if config["core"]["server"] == "Hyper-V":
|
||||||
run_cmd("Start-VM -Name Jukebox*") # any and all VMs starting with "Jukebox"
|
run_cmd("Start-VM -Name Jukebox*") # any and all VMs starting with "Jukebox"
|
||||||
@ -117,12 +121,16 @@ def setup_client(pool, config):
|
|||||||
|
|
||||||
wait_for(vm_ready, "VM Startup")
|
wait_for(vm_ready, "VM Startup")
|
||||||
p.terminate()
|
p.terminate()
|
||||||
|
firefox.get(config["core"]["serverip"])
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
def mainloop_client(pool):
|
def mainloop_client(pool):
|
||||||
sleep(0.1)
|
sleep(0.1)
|
||||||
|
|
||||||
|
# listen for & act on commands from VM, if needed
|
||||||
|
# mainly just shut down, possibly connect to wifi or something
|
||||||
|
|
||||||
"""class Logger(object):
|
"""class Logger(object):
|
||||||
def __init__(self, filename="output.log"):
|
def __init__(self, filename="output.log"):
|
||||||
self.log = open(filename, "a")
|
self.log = open(filename, "a")
|
||||||
@ -149,6 +157,9 @@ def killall():
|
|||||||
|
|
||||||
|
|
||||||
def killall_signal(a, b):
|
def killall_signal(a, b):
|
||||||
|
global config
|
||||||
|
if config["core"]["server"] == "Hyper-V":
|
||||||
|
run_cmd("Stop-VM -Name Jukebox*") # any and all VMs starting with "Jukebox"
|
||||||
killall()
|
killall()
|
||||||
|
|
||||||
def error(msg, *args):
|
def error(msg, *args):
|
||||||
@ -181,7 +192,7 @@ class LoggingPool(Pool):
|
|||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
#sys.stdout = Logger(filename="output.log")
|
#sys.stdout = Logger(filename="output.log")
|
||||||
#sys.stderr = Logger(filename="output.log")
|
#sys.stderr = Logger(filename="output.log")
|
||||||
log_to_stderr(logging.DEBUG)
|
#log_to_stderr(logging.DEBUG)
|
||||||
|
|
||||||
with open('config.yml', 'r') as fileread:
|
with open('config.yml', 'r') as fileread:
|
||||||
#global config
|
#global config
|
||||||
@ -193,7 +204,8 @@ if __name__ == "__main__":
|
|||||||
killme = manager.Value('d', 0)
|
killme = manager.Value('d', 0)
|
||||||
signal.signal(signal.SIGINT, killall_signal)
|
signal.signal(signal.SIGINT, killall_signal)
|
||||||
if config["core"]["mode"] == "winclient":
|
if config["core"]["mode"] == "winclient":
|
||||||
if setup_client(pool, config):
|
from selenium import webdriver
|
||||||
|
if setup_client(pool):
|
||||||
while(keeprunning):
|
while(keeprunning):
|
||||||
mainloop_client(pool)
|
mainloop_client(pool)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user