mirror of
https://gitlab.com/signalytic/client-external/streamline/streamline-emr.git
synced 2026-09-12 19:21:33 +00:00
updated streamline-setup v2
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
import json
|
||||
import socket
|
||||
|
||||
import requests
|
||||
|
||||
HOST = "192.168.1.215" # Standard loopback interface address (localhost)
|
||||
PORT = 5100 # Port to listen on (non-privileged ports are > 1023)
|
||||
|
||||
bytes_to_decode = b''
|
||||
|
||||
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
|
||||
s.bind((HOST, PORT))
|
||||
s.listen()
|
||||
conn, addr = s.accept()
|
||||
|
||||
with conn:
|
||||
# print(f"Connected by {addr}")
|
||||
|
||||
while True:
|
||||
data = conn.recv(1024)
|
||||
|
||||
if data:
|
||||
bytes_to_decode += data
|
||||
|
||||
if 'END_RESULT' in data.decode():
|
||||
results_dict = {}
|
||||
decoded_data = bytes_to_decode.decode()
|
||||
|
||||
data_lists = [line.split(";") for line in decoded_data.split("\r\n")]
|
||||
data_list = []
|
||||
|
||||
for row in data_lists:
|
||||
if row[0] in ['SID', 'PID', 'ID']:
|
||||
results_dict[row[0]] = row[1]
|
||||
elif row[0] in ['WBC', 'LYMP', 'MONP', 'NEUP', 'EOSP', 'BASP', 'IMMP', 'ALYP', 'LYM', 'RDW-SD',
|
||||
'MON', 'NEU', 'EOS', 'BAS', 'IMM', 'ALY', 'RBC', 'HGB', 'HCT', 'MCV', 'MCH',
|
||||
'MCHC', 'RDW-CV', 'PLCR', 'PDW', 'PCT', 'MPV', 'PLT']:
|
||||
try:
|
||||
flag = row[3]
|
||||
except:
|
||||
flag = ''
|
||||
|
||||
try:
|
||||
result = row[1]
|
||||
except:
|
||||
result = ''
|
||||
|
||||
data_list.append([row[0], result, flag])
|
||||
|
||||
results_dict["results"] = json.dumps(data_list)
|
||||
|
||||
requests.post('http://192.168.1.215/lab_machines/receive_results_mispa', data=results_dict)
|
||||
|
||||
bytes_to_decode = b''
|
||||
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
from subprocess import check_output, Popen, PIPE, STDOUT
|
||||
import os
|
||||
|
||||
file_path = "/var/www/streamline/public/uploads/lab_machine_scripts/kisiizi/main.py"
|
||||
|
||||
try:
|
||||
# get the pid of the last process running with python3
|
||||
pid_list = check_output(["pidof", "python3"]).split()
|
||||
|
||||
# iterate over the list of related pids
|
||||
for pid in pid_list:
|
||||
decoded_pid = pid.decode("utf-8")
|
||||
file_path_from_pid = check_output(["ps", "-o", "cmd", decoded_pid]).split()[2].decode("utf-8")
|
||||
|
||||
if file_path_from_pid == file_path:
|
||||
# kill the process with this path
|
||||
delete_pid = check_output(["kill", "-9", decoded_pid])
|
||||
break
|
||||
|
||||
# start a new process
|
||||
os.system("nohup python3 " + file_path + " >/dev/null 2>&1 & ")
|
||||
print(1)
|
||||
|
||||
except Exception as e:
|
||||
print(e)
|
||||
Reference in New Issue
Block a user