diff --git a/PythonServer/environment-to-freeze.yml b/PythonServer/environment-to-freeze.yml index 300d8000bd8cd4228d400446836eff1782123382..3f7136ad27dd0be9e84e1a88e5cf64545fe0df75 100644 --- a/PythonServer/environment-to-freeze.yml +++ b/PythonServer/environment-to-freeze.yml @@ -18,3 +18,4 @@ dependencies: - pip: - --index-url https://artifactory.esss.lu.se/artifactory/api/pypi/pypi-virtual/simple - py-epicsarchiver==0.3.0 + - channelfinder==3.0.0 diff --git a/PythonServer/environment.yml b/PythonServer/environment.yml index 7316cbbfd9e168fd7e7dc10addbef789dc92589f..2335233c9cff9179c055849fa2f9de55cc8094e4 100644 --- a/PythonServer/environment.yml +++ b/PythonServer/environment.yml @@ -62,3 +62,4 @@ dependencies: - pip: - --index-url https://artifactory.esss.lu.se/artifactory/api/pypi/pypi-virtual/simple - py-epicsarchiver==0.3.0 + - channelfinder==3.0.0 diff --git a/PythonServer/pos-python-server.py b/PythonServer/pos-python-server.py index 94f0b233bbc19e20a7b9083201c7ea20a1ccb2b1..95328ba6e0b318afef84a605b8967dac24f5a3a6 100755 --- a/PythonServer/pos-python-server.py +++ b/PythonServer/pos-python-server.py @@ -10,7 +10,9 @@ from glob import glob from numpy import linspace, array, zeros, flip, rot90, tile from http.server import BaseHTTPRequestHandler,HTTPServer from epicsarchiver import ArchiverAppliance +from channelfinder import ChannelFinderClient from threading import Thread, Event + from screens.pos import posScreen from screens.interlocks import interlocksScreen from screens.instruments import instrumentsScreen @@ -18,19 +20,13 @@ from screens.ts2_cav import ts2_cavScreen from screens.ts2_screens import ts2_screensScreen PORT_NUMBER = 8080 -ARCHIVER_SERVER = os.environ.get('ARCHIVER_SERVER', 'archiver-01.tn.esss.lu.se') +ARCHIVER_SERVER = os.environ.get('ARCHIVER_SERVER') archiver = ArchiverAppliance(ARCHIVER_SERVER) -pv_repo = os.environ.get('PV_REPO', 'https://bitbucket.org/europeanspallationsource/isrc-lebt-pv-list.git') +CHANNEL_FINDER = os.environ.get('CHANNEL_FINDER') +cf = ChannelFinderClient(BaseURL=CHANNEL_FINDER) stop_signal = Event() stop_signal.clear() -try: - Repo.clone_from(pv_repo, './repo') - pvfiles=glob('./repo/*.txt') -except: - print('PV Repository not available') - quit() - def save_json(json_data, outfile): tmp_json = json.dumps(json_data) tmp_json = tmp_json.replace('NaN','0') @@ -39,30 +35,7 @@ def save_json(json_data, outfile): datafile.write(tmp_json) return -pvlist=[] -for filename in pvfiles: - sheet = filename.split('/')[2].split('.')[0] - data=open(filename,'r') - pvlist+=data.read().splitlines() - data.close() -rmtree('./repo') -pvlist.sort() - -global_dict={} -for PV in pvlist: - try: - sheet=PV.split(':')[0] - column=PV.split(':')[1] - if sheet not in global_dict.keys(): - global_dict[sheet]={} - if column not in global_dict[sheet].keys(): - global_dict[sheet][column]={} - global_dict[sheet][column][PV]=False - except: - None - -save_json(global_dict, '/var/www/data/getData.json') - +all_casings=lambda s:s and {r[0]+t for r in{s,s.swapcase()} for t in all_casings(s[1:])} or{s} class myHandler(BaseHTTPRequestHandler): def do_GET(self): @@ -79,14 +52,20 @@ class myHandler(BaseHTTPRequestHandler): if len(wordlist)<=1 and len(wordlist[0])<2: returnlist='' return - result=pvlist + search_string='' for word in wordlist: - result=[row for row in result if word.lower() in row.lower()] + for case in all_casings(word): + search_string+='*'+case+'*|' + search_string=search_string[:-1] + search_string+=',' + search_string=search_string[:-1] + result = cf.find(name=search_string) + if len(result)==0: returnlist='No PV found.' else: for pv in result: - returnlist+='<a href="#" onclick="searchPV(\''+pv+'\')">'+pv+'</a>' + returnlist+='<a href="#" onclick="searchPV(\''+pv['name']+'\')">'+pv['name']+'</a>' returnlist+='<br>' self.wfile.write(bytes(json.dumps({'pvs':returnlist}), "utf-8")) return diff --git a/WebSites/pvs/dashboard.json b/WebSites/pvs/dashboard.json index 89dfa34fc1d868f2f1aa86b7bb61abc6c0fdc39b..fa765e8cd68d55a79f193537218c58b1c0a162f3 100644 --- a/WebSites/pvs/dashboard.json +++ b/WebSites/pvs/dashboard.json @@ -1,7 +1,7 @@ { "version": 1, "header_image": "", - "allow_edit": true, + "allow_edit": false, "plugins": [], "panes": [ { diff --git a/docker-compose.yml b/docker-compose.yml index 07e61f2755b63332177a96382ebfdae9f05cf2d6..4314bf6376f3dbbd520ff9caaab7028e4c619bb1 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -9,7 +9,7 @@ services: EPICS_CA_AUTO_ADDR_LIST: "NO" EPICS_CA_ADDR_LIST: "10.0.16.88" ARCHIVER_SERVER: "archiver-01.tn.esss.lu.se" - PV_REPO: "https://bitbucket.org/europeanspallationsource/isrc-lebt-pv-list.git" + CHANNEL_FINDER: "https://channelfinder.tn.esss.lu.se" expose: - "8080" volumes: