Browse Source

Code clean, and added software update method.

master
Carlos Reding 1 year ago
parent
commit
54800d1b48
1 changed files with 24 additions and 4 deletions
  1. 24
    4
      limoControl/puppeteer/__init__.py

+ 24
- 4
limoControl/puppeteer/__init__.py View File

@@ -9,7 +9,7 @@

from ._core import SetupDevice, SetProtocol
from ._dataparser import export_img_data, report_progress, house_keeper
import time, subprocess, pickle, os
import time, subprocess, os


# Location of hardware settings:
@@ -171,7 +171,27 @@ def CancelProtocol(with_device=None, Connection=None, ConnectionStatus=None):
if Box is not None:
Box.terminate_device(Connection, ConnectionStatus)
# Restart server (workaround, as python won't recognise BASH functions).
LiMO_Path = "/home/client/.srv/"
Routine=".cancel_protocol.sh"
subprocess.call(["bash", "-c", LiMO_Path + Routine])
Routine="/.cancel_protocol.sh"
subprocess.call(["bash", "-c", Path + Routine])


def UpdateSoftWare(Connection, BUFFER_SIZE=64):
"""
Update the software running the light modulator. `remote_buffer'
contains the software stored in a remote repository, and can only
be accessed through the GUI.
"""
Connection.sendall("Acknowledged".encode()) # Unlock
REMOTE_BUFFER_SIZE = Connection.recv(BUFFER_SIZE)
Connection.sendall("Acknowledged".encode()) # Unlock
# Retrieve software
sw_stream = Connection.recv(BUFFER_SIZE)
while len(sw_stream) < REMOTE_BUFFER_SIZE:
sw_stream += Connection.recv(BUFFER_SIZE)
Connection.sendall("Acknowledged".encode()) # Unlock _GUI_
# Save software
fName = sw_stream.url.split("/")[-1]
with open(Path + fName, "wb") as fOut:
fOut.write(sw_stream.read())
# Perform update
subprocess.call(["bash", "-c", "pip3 install --user " + Path + fName])

Loading…
Cancel
Save