Maintenance will be performed on git.ligo.org, chat.ligo.org, containers.ligo.org, and docs.ligo.org on Tuesday 26 May 2020 starting at approximately 10am CDT. It is expected to take around 30 minutes and will involve a short period of downtime, around 5 minutes, towards the end of the maintenance period. Please address any questions, comments, or concerns to uwm-help@cgca.uwm.edu.

Commit 0e4bcd37 authored by Jonathan Hanks's avatar Jonathan Hanks

Merge branch 'update-script' into 'master'

add script to update/maintain channel lists

See merge request !5
parents 4e6f9596 1e3b4d06
Pipeline #46413 passed with stage
in 10 minutes and 46 seconds
#!/usr/bin/env python3
import os
import sys
import nds2
HOSTPORT = os.getenv('NDSSERVER', 'nds.ligo.caltech.edu:31200').split(',')[0].split(':')
HOST = HOSTPORT[0]
if len(HOSTPORT) == 1:
PORT = 31200
else:
PORT = int(HOSTPORT[1])
CACHE_DIR = os.path.expanduser('~/.cache/ligo-channel-list')
NDS_CHAN_LIST = os.getenv('NDS_CHAN_LIST', os.path.join(CACHE_DIR, 'nds-chan-list.txt'))
EPICS_CHAN_LIST = os.getenv('EPICS_CHAN_LIST', os.path.join(CACHE_DIR, 'epics-chan-list.txt'))
def main():
if len(sys.argv) > 1 and sys.argv[1] in ['-h', '--help']:
print("""Update channel file lists for use with ligo_channel_completion.
Downloads the channel list from NDS and updates the NDS and EPICS
channel list files. Uses the server specified in the NDSSERVER
environment variable, or 'nds.ligo.caltech.edu:31200' if not
specified. If the NDS_CHAN_LIST and EPICS_CHAN_LIST variables exist
they are assumed to be the paths to files to be updated. Otherwise
the files are updated in the default cache locations:
NDS_CHAN_LIST={}
EPICS_CHAN_LIST={}
Export these variables to your environment for bash channel
completion.""".format(NDS_CHAN_LIST, EPICS_CHAN_LIST))
sys.exit()
params = nds2.parameters(HOST, PORT)
chans = nds2.find_channels(
channel_type_mask=nds2.channel.CHANNEL_TYPE_RAW,
params=params,
)
os.makedirs(os.path.dirname(NDS_CHAN_LIST), exist_ok=True)
os.makedirs(os.path.dirname(EPICS_CHAN_LIST), exist_ok=True)
f_nds = open(NDS_CHAN_LIST+'.tmp', 'w')
f_epics = open(EPICS_CHAN_LIST+'.tmp', 'w')
for chan in sorted(chans, key=lambda c: c.name):
f_nds.write(chan.name+'\n')
if chan.sample_rate == 16:
f_epics.write(chan.name+'\n')
os.rename(NDS_CHAN_LIST+'.tmp', NDS_CHAN_LIST)
os.rename(EPICS_CHAN_LIST+'.tmp', EPICS_CHAN_LIST)
if __name__ == '__main__':
main()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment