change sys.path

+ some other stuff
This commit is contained in:
2026-02-18 16:43:19 +01:00
parent a6ec455563
commit 0e8ad84570
4 changed files with 25 additions and 7 deletions

15
base.py
View File

@@ -41,6 +41,8 @@ class HandlerBase:
class Client(HandlerBase):
dictionary = {} # dict (kind, uri) of node
def __init__(self, server, streams, instrument_name, device_name):
super().__init__()
self.id = uuid.uuid4().hex[0:15]
@@ -50,7 +52,18 @@ class Client(HandlerBase):
for uri in streams:
urisplit = uri.rsplit('://')
kind = urisplit[0] if len(urisplit) == 2 else 'secop'
node = server.interactor_classes[kind](uri, self.node_map)
node = self.dictionary.get((kind, uri))
if node is None:
def change_callback(dictionary=self.dictionary, kind_uri=(kind, uri)):
dictionary.pop(kind_uri, None)
node = server.interactor_classes[kind](uri, self.node_map, change_callback)
self.dictionary[kind, uri] = node
self.nodes[uri] = node
self.server = server
self.instrument_name = instrument_name

View File

@@ -313,7 +313,7 @@ function reqJSON(s, url, successHandler, errorHandler) {
: new ActiveXObject('Microsoft.XMLHTTP');
if (debugCommunication) {
console.log("%cto server (reqJSON): %s",
"color:white;background:darkgreen", url);
"background:yellow", url);
}
xhr.open('get', url, true);
xhr.onreadystatechange = function() {

View File

@@ -1,9 +1,9 @@
#!/usr/bin/env python
import sys
from os.path import expanduser
# look for sehistory and frappy at usual locations in home directory
sys.path.extend([expanduser('~'), expanduser('~/frappy')])
# look for sehistory and frappy
sys.path.extend(['/sq_sw/linse', '/sq_sw/linse/frappy'])
import argparse
from webserver import server
from base import Client

View File

@@ -49,18 +49,23 @@ class SecopInteractor(SecopClient):
hide_par = ["baseclass", "class", "pollinterval"]
skip_par = ["status2"]
def __init__(self, uri, node_map):
def __init__(self, uri, node_map, change_callback=None):
super().__init__(uri)
self.module_updates = set()
self.param_updates = set()
self.updates = {}
self.change_callback = change_callback
try:
self.connect()
node_map.update({k: self for k in self.modules})
self.register_callback(None, updateItem=self.updateItem)
self.register_callback(None, updateItem=self.updateItem, descriptiveDataChange=self.descChanged)
except Exception as e:
print(repr(e))
def descChanged(self, module, desc):
if module is None and self.change_callback:
self.change_callback()
def add_main_components(self, components):
for name, desc in self.modules.items():
parameters = desc['parameters']