Files
sf_databuffer/Config Tests.ipynb
2021-03-16 08:28:01 +01:00

970 lines
45 KiB
Plaintext

{
"cells": [
{
"cell_type": "code",
"execution_count": 12,
"metadata": {
"hide_input": false
},
"outputs": [],
"source": [
"from pathlib import Path\n",
"import json\n",
"import re\n",
"import requests"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"# Stolen from https://www.saltycrane.com/blog/2007/11/remove-c-comments-python/\n",
"def remove_comments(text):\n",
" \"\"\" remove c-style comments.\n",
" text: blob of text with comments (can include newlines)\n",
" returns: text with comments removed\n",
" \"\"\"\n",
" pattern = r\"\"\"\n",
" ## --------- COMMENT ---------\n",
" /\\* ## Start of /* ... */ comment\n",
" [^*]*\\*+ ## Non-* followed by 1-or-more *'s\n",
" ( ##\n",
" [^/*][^*]*\\*+ ##\n",
" )* ## 0-or-more things which don't start with /\n",
" ## but do end with '*'\n",
" / ## End of /* ... */ comment\n",
" | ## -OR- various things which aren't comments:\n",
" ( ## \n",
" ## ------ \" ... \" STRING ------\n",
" \" ## Start of \" ... \" string\n",
" ( ##\n",
" \\\\. ## Escaped char\n",
" | ## -OR-\n",
" [^\"\\\\] ## Non \"\\ characters\n",
" )* ##\n",
" \" ## End of \" ... \" string\n",
" | ## -OR-\n",
" ##\n",
" ## ------ ' ... ' STRING ------\n",
" ' ## Start of ' ... ' string\n",
" ( ##\n",
" \\\\. ## Escaped char\n",
" | ## -OR-\n",
" [^'\\\\] ## Non '\\ characters\n",
" )* ##\n",
" ' ## End of ' ... ' string\n",
" | ## -OR-\n",
" ##\n",
" ## ------ ANYTHING ELSE -------\n",
" . ## Anything other char\n",
" [^/\"'\\\\]* ## Chars which doesn't start a comment, string\n",
" ) ## or escape\n",
" \"\"\"\n",
" regex = re.compile(pattern, re.VERBOSE|re.MULTILINE|re.DOTALL)\n",
" noncomments = [m.group(2) for m in regex.finditer(text) if m.group(2)]\n",
"\n",
" return \"\".join(noncomments)"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"def load_file(file_path):\n",
" with open(file_path) as file_h:\n",
" text = file_h.read()\n",
" text = remove_comments(text)\n",
" config = json.loads(text)\n",
" return config"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
"def read_files(files_dir, file_type):\n",
" sources = []\n",
" for file in files_dir.iterdir():\n",
"# print(file)\n",
" config = load_file(file)\n",
" sources.extend(config[file_type])\n",
"# print(config)\n",
" return {file_type: sources}"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
"sources = read_files(Path(\"sources/\"), \"sources\")"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'sources': [{'stream': 'tcp://SIN-CVME-LAS0041:9999'},\n",
" {'stream': 'tcp://SIN-CVME-LAS0042:9999'},\n",
" {'stream': 'tcp://SIN-CVME-LAS0051:9999'},\n",
" {'stream': 'tcp://SIN-CVME-LAS0051:9989'},\n",
" {'stream': 'tcp://SIN-CVME-LAS0071:9999'},\n",
" {'stream': 'tcp://SIN-CVME-LAS0201:9999'},\n",
" {'stream': 'tcp://SARES21-CPCL-GES1:9999'},\n",
" {'stream': 'tcp://SARES21-CPCL-GES1:9990'},\n",
" {'stream': 'tcp://SARES21-CPCL-GES1:9980'},\n",
" {'stream': 'tcp://SARES21-CPCL-GES1:9970'},\n",
" {'stream': 'tcp://SLAAR21-CPPM-MOT6991:9999'},\n",
" {'stream': 'tcp://SLAAR21-CVME-LAS6991:9999'},\n",
" {'stream': 'tcp://SARES20-CVME-01:9999'},\n",
" {'stream': 'tcp://sf-daqsync-06:9003'},\n",
" {'stream': 'tcp://sf-daqsync-06:9001'},\n",
" {'stream': 'tcp://sf-daqsync-06:9011'},\n",
" {'stream': 'tcp://sf-daqsync-06.psi.ch:9015'},\n",
" {'stream': 'tcp://sf-daqsync-06.psi.ch:9016'},\n",
" {'stream': 'tcp://sf-daqsync-06.psi.ch:9017'},\n",
" {'stream': 'tcp://sf-daqsync-06.psi.ch:9018'},\n",
" {'stream': 'tcp://SINLH01-CVME-DBAM12:9999'},\n",
" {'stream': 'tcp://S10BC01-CVME-DBAM32:9999'},\n",
" {'stream': 'tcp://SARCL01-CVME-DBAM42:9999'},\n",
" {'stream': 'tcp://SARUN20-CVME-DBAM52:9999'},\n",
" {'stream': 'tcp://sf-daqsync-02:8889'},\n",
" {'stream': 'tcp://SIN-CVME-MPS0151:9999'},\n",
" {'stream': 'tcp://SLAAR-CVME-LAS6861:9999'},\n",
" {'stream': 'tcp://SLAAR-CVME-LAS6891:9999'},\n",
" {'stream': 'tcp://SIN-CVME-TIFGUN:9999'},\n",
" {'stream': 'tcp://SFTEST-CVME-CON1331:9999'},\n",
" {'stream': 'tcp://SAR-CVME-TIFALL4:9999'},\n",
" {'stream': 'tcp://SAR-CVME-TIFALL5:9999'},\n",
" {'stream': 'tcp://SAT-CVME-TIFALL5:9999'},\n",
" {'stream': 'tcp://SAT-CVME-TIFALL6:9999'},\n",
" {'stream': 'tcp://SINEG01-CVME-DICT009:9999'},\n",
" {'stream': 'tcp://S10DI01-CVME-DICT113:9999'},\n",
" {'stream': 'tcp://SATDI01-CVME-DICT344:9999'},\n",
" {'stream': 'tcp://SATBD02-CVME-DICT499:9999'},\n",
" {'stream': 'tcp://SARMA01-CVME-DICT482:9999'},\n",
" {'stream': 'tcp://SARBD01-CVME-DICT599:9999'},\n",
" {'stream': 'tcp://sates20-cvme-maloja1:9999'},\n",
" {'stream': 'tcp://sates21-cpcl-ges1:9999'},\n",
" {'stream': 'tcp://sates21-cpcl-ges1:9989'},\n",
" {'stream': 'tcp://sf-daqsync-04.psi.ch:9001'},\n",
" {'stream': 'tcp://sf-daqsync-04.psi.ch:9011'},\n",
" {'stream': 'tcp://SINEG01-CVME-DBLM009:9999'},\n",
" {'stream': 'tcp://SINLH02-CVME-DBLM018:9999'},\n",
" {'stream': 'tcp://SINDI02-CVME-DBLM084:9999'},\n",
" {'stream': 'tcp://S10DI01-CVME-DBLM113:9999'},\n",
" {'stream': 'tcp://S10CB04-CVME-DBLM130:9999'},\n",
" {'stream': 'tcp://S10CB06-CVME-DBLM153:9999'},\n",
" {'stream': 'tcp://S10CB08-CVME-DBLM170:9999'},\n",
" {'stream': 'tcp://S10BC01-CVME-DBLM184:9999'},\n",
" {'stream': 'tcp://S20CB02-CVME-DBLM234:9999'},\n",
" {'stream': 'tcp://S20CB04-CVME-DBLM255:9999'},\n",
" {'stream': 'tcp://S20SY03-CVME-DBLM269:9999'},\n",
" {'stream': 'tcp://S20SY03-CVME-DBLM292:9999'},\n",
" {'stream': 'tcp://S30CB02-CVME-DBLM310:9999'},\n",
" {'stream': 'tcp://SATCL01-CVME-DBLM328:9999'},\n",
" {'stream': 'tcp://SATDI01-CVME-DBLM344:9999'},\n",
" {'stream': 'tcp://SATCB01-CVME-DBLM355:9999'},\n",
" {'stream': 'tcp://S30CB10-CVME-DBLM381:9999'},\n",
" {'stream': 'tcp://S30CB14-CVME-DBLM417:9999'},\n",
" {'stream': 'tcp://SARCL02-CVME-DBLM457:9999'},\n",
" {'stream': 'tcp://SARCL02-CVME-DBLM469:9999'},\n",
" {'stream': 'tcp://SARMA01-CVME-DBLM482:9999'},\n",
" {'stream': 'tcp://SARUN01-CVME-DBLM499:9999'},\n",
" {'stream': 'tcp://SARUN04-CVME-DBLM516:9999'},\n",
" {'stream': 'tcp://SARUN08-CVME-DBLM537:9999'},\n",
" {'stream': 'tcp://SARUN11-CVME-DBLM546:9999'},\n",
" {'stream': 'tcp://SARUN13-CVME-DBLM555:9999'},\n",
" {'stream': 'tcp://SARUN15-CVME-DBLM567:9999'},\n",
" {'stream': 'tcp://SARUN20-CVME-DBLM599:9999'},\n",
" {'stream': 'tcp://S20CB04-CVME-ILK:9000'},\n",
" {'stream': 'tcp://S30CB01-CVME-ILK:9000'},\n",
" {'stream': 'tcp://S30CB02-CVME-ILK:9000'},\n",
" {'stream': 'tcp://S30CB03-CVME-ILK:9000'},\n",
" {'stream': 'tcp://S30CB04-CVME-ILK:9000'},\n",
" {'stream': 'tcp://S30CB05-CVME-ILK:9000'},\n",
" {'stream': 'tcp://S30CB06-CVME-ILK:9000'},\n",
" {'stream': 'tcp://S30CB07-CVME-ILK:9000'},\n",
" {'stream': 'tcp://S30CB08-CVME-ILK:9000'},\n",
" {'stream': 'tcp://S30CB09-CVME-ILK:9000'},\n",
" {'stream': 'tcp://S30CB10-CVME-ILK:9000'},\n",
" {'stream': 'tcp://S30CB11-CVME-ILK:9000'},\n",
" {'stream': 'tcp://S30CB12-CVME-ILK:9000'},\n",
" {'stream': 'tcp://S30CB13-CVME-ILK:9000'},\n",
" {'stream': 'tcp://sf-ecmc-04.psi.ch:9999'},\n",
" {'stream': 'tcp://SINEG01-CVME-ILK:9999'},\n",
" {'stream': 'tcp://SINSB01-CVME-ILK:9999'},\n",
" {'stream': 'tcp://SINSB02-CVME-ILK:9999'},\n",
" {'stream': 'tcp://SINSB03-CVME-ILK:9999'},\n",
" {'stream': 'tcp://SINSB04-CVME-ILK:9999'},\n",
" {'stream': 'tcp://SINXB01-CVME-ILK:9999'},\n",
" {'stream': 'tcp://SINDI01-CVME-ILK:9999'},\n",
" {'stream': 'tcp://S10CB01-CVME-ILK:9999'},\n",
" {'stream': 'tcp://S10CB02-CVME-ILK:9999'},\n",
" {'stream': 'tcp://S10CB03-CVME-ILK:9999'},\n",
" {'stream': 'tcp://S10CB04-CVME-ILK:9999'},\n",
" {'stream': 'tcp://S10CB05-CVME-ILK:9999'},\n",
" {'stream': 'tcp://S10CB06-CVME-ILK:9999'},\n",
" {'stream': 'tcp://S10CB07-CVME-ILK:9999'},\n",
" {'stream': 'tcp://S10CB08-CVME-ILK:9999'},\n",
" {'stream': 'tcp://S10CB09-CVME-ILK:9999'},\n",
" {'stream': 'tcp://S20CB01-CVME-ILK:9999'},\n",
" {'stream': 'tcp://S20CB02-CVME-ILK:9999'},\n",
" {'stream': 'tcp://S20CB03-CVME-ILK:9999'},\n",
" {'stream': 'tcp://S20CB04-CVME-ILK:9999'},\n",
" {'stream': 'tcp://S30CB01-CVME-ILK:9999'},\n",
" {'stream': 'tcp://S30CB02-CVME-ILK:9999'},\n",
" {'stream': 'tcp://S30CB03-CVME-ILK:9999'},\n",
" {'stream': 'tcp://S30CB04-CVME-ILK:9999'},\n",
" {'stream': 'tcp://S30CB05-CVME-ILK:9999'},\n",
" {'stream': 'tcp://S30CB06-CVME-ILK:9999'},\n",
" {'stream': 'tcp://S30CB07-CVME-ILK:9999'},\n",
" {'stream': 'tcp://S30CB08-CVME-ILK:9999'},\n",
" {'stream': 'tcp://S30CB09-CVME-ILK:9999'},\n",
" {'stream': 'tcp://S30CB10-CVME-ILK:9999'},\n",
" {'stream': 'tcp://S30CB11-CVME-ILK:9999'},\n",
" {'stream': 'tcp://S30CB12-CVME-ILK:9999'},\n",
" {'stream': 'tcp://S30CB13-CVME-ILK:9999'},\n",
" {'stream': 'tcp://S30CB14-CVME-ILK:9999'},\n",
" {'stream': 'tcp://SATCB01-CVME-ILK:9999'},\n",
" {'stream': 'tcp://SINEGTS-CVME-ILK:9999'},\n",
" {'stream': 'tcp://SAROP11-CPCL-PALM118:9990'},\n",
" {'stream': 'tcp://SAROP11-CPCL-PALM118:9999'},\n",
" {'stream': 'tcp://SAROP21-CPCL-PALM134:9999'},\n",
" {'stream': 'tcp://SINBC02-CVME-DBCM077:9999'},\n",
" {'stream': 'tcp://SINDI02-CVME-DCDR083:9999'},\n",
" {'stream': 'tcp://S10MA01-CVME-DCDR216:9999'},\n",
" {'stream': 'tcp://daqsf-sioc-cs-01.psi.ch:8160',\n",
" 'split': 4,\n",
" 'backend': 'sf-imagebuffer'},\n",
" {'stream': 'tcp://daqsf-sioc-cs-11.psi.ch:8020',\n",
" 'split': 4,\n",
" 'backend': 'sf-imagebuffer'},\n",
" {'stream': 'tcp://daqsf-sioc-cs-11.psi.ch:8030',\n",
" 'split': 4,\n",
" 'backend': 'sf-imagebuffer'},\n",
" {'stream': 'tcp://daqsf-sioc-cs-11.psi.ch:8040',\n",
" 'split': 4,\n",
" 'backend': 'sf-imagebuffer'},\n",
" {'stream': 'tcp://daqsf-sioc-cs-11.psi.ch:9000',\n",
" 'split': 4,\n",
" 'backend': 'sf-imagebuffer'},\n",
" {'stream': 'tcp://daqsf-sioc-cs-11.psi.ch:9010',\n",
" 'split': 4,\n",
" 'backend': 'sf-imagebuffer'},\n",
" {'stream': 'tcp://daqsf-sioc-cs-11.psi.ch:9020',\n",
" 'split': 4,\n",
" 'backend': 'sf-imagebuffer'},\n",
" {'stream': 'tcp://daqsf-sioc-cs-11.psi.ch:9030',\n",
" 'split': 4,\n",
" 'backend': 'sf-imagebuffer'},\n",
" {'stream': 'tcp://daqsf-sioc-cs-11.psi.ch:9040',\n",
" 'split': 4,\n",
" 'backend': 'sf-imagebuffer'},\n",
" {'stream': 'tcp://daqsf-sioc-cs-11.psi.ch:9050',\n",
" 'split': 4,\n",
" 'backend': 'sf-imagebuffer'},\n",
" {'stream': 'tcp://daqsf-sioc-cs-11.psi.ch:9060',\n",
" 'split': 4,\n",
" 'backend': 'sf-imagebuffer'},\n",
" {'stream': 'tcp://daqsf-sioc-cs-11.psi.ch:9070',\n",
" 'split': 4,\n",
" 'backend': 'sf-imagebuffer'},\n",
" {'stream': 'tcp://daqsf-sioc-cs-11.psi.ch:9080',\n",
" 'split': 4,\n",
" 'backend': 'sf-imagebuffer'},\n",
" {'stream': 'tcp://daqsf-sioc-cs-11.psi.ch:9100',\n",
" 'split': 4,\n",
" 'backend': 'sf-imagebuffer'},\n",
" {'stream': 'tcp://daqsf-sioc-cs-11.psi.ch:9110',\n",
" 'split': 4,\n",
" 'backend': 'sf-imagebuffer'},\n",
" {'stream': 'tcp://daqsf-sioc-cs-11.psi.ch:9120',\n",
" 'split': 4,\n",
" 'backend': 'sf-imagebuffer'},\n",
" {'stream': 'tcp://daqsf-sioc-cs-11.psi.ch:9130',\n",
" 'split': 4,\n",
" 'backend': 'sf-imagebuffer'},\n",
" {'stream': 'tcp://daqsf-sioc-cs-11.psi.ch:9140',\n",
" 'split': 4,\n",
" 'backend': 'sf-imagebuffer'},\n",
" {'stream': 'tcp://daqsf-sioc-cs-11.psi.ch:9150',\n",
" 'split': 4,\n",
" 'backend': 'sf-imagebuffer'},\n",
" {'stream': 'tcp://daqsf-sioc-cs-11.psi.ch:9160',\n",
" 'split': 4,\n",
" 'backend': 'sf-imagebuffer'},\n",
" {'stream': 'tcp://daqsf-sioc-cs-11.psi.ch:9170',\n",
" 'split': 4,\n",
" 'backend': 'sf-imagebuffer'},\n",
" {'stream': 'tcp://daqsf-sioc-cs-11.psi.ch:9180',\n",
" 'split': 4,\n",
" 'backend': 'sf-imagebuffer'},\n",
" {'stream': 'tcp://daqsf-sioc-cs-11.psi.ch:9190',\n",
" 'split': 4,\n",
" 'backend': 'sf-imagebuffer'},\n",
" {'stream': 'tcp://daqsf-sioc-cs-12.psi.ch:9000',\n",
" 'split': 4,\n",
" 'backend': 'sf-imagebuffer'},\n",
" {'stream': 'tcp://daqsf-sioc-cs-12.psi.ch:9010',\n",
" 'split': 4,\n",
" 'backend': 'sf-imagebuffer'},\n",
" {'stream': 'tcp://daqsf-sioc-cs-13.psi.ch:9000',\n",
" 'split': 4,\n",
" 'backend': 'sf-imagebuffer'},\n",
" {'stream': 'tcp://daqsf-sioc-cs-13.psi.ch:9010',\n",
" 'split': 4,\n",
" 'backend': 'sf-imagebuffer'},\n",
" {'stream': 'tcp://daqsf-sioc-cs-14.psi.ch:9000',\n",
" 'split': 4,\n",
" 'backend': 'sf-imagebuffer'},\n",
" {'stream': 'tcp://daqsf-sioc-cs-14.psi.ch:9010',\n",
" 'split': 4,\n",
" 'backend': 'sf-imagebuffer'},\n",
" {'stream': 'tcp://daqsf-sioc-cs-14.psi.ch:9020',\n",
" 'split': 4,\n",
" 'backend': 'sf-imagebuffer'},\n",
" {'stream': 'tcp://daqsf-sioc-cs-21.psi.ch:9000',\n",
" 'split': 4,\n",
" 'backend': 'sf-imagebuffer'},\n",
" {'stream': 'tcp://daqsf-sioc-cs-21.psi.ch:9010',\n",
" 'split': 4,\n",
" 'backend': 'sf-imagebuffer'},\n",
" {'stream': 'tcp://daqsf-sioc-cs-31.psi.ch:9000',\n",
" 'split': 4,\n",
" 'backend': 'sf-imagebuffer'},\n",
" {'stream': 'tcp://daqsf-sioc-cs-31.psi.ch:9020',\n",
" 'split': 4,\n",
" 'backend': 'sf-imagebuffer'},\n",
" {'stream': 'tcp://daqsf-sioc-cs-31.psi.ch:9010',\n",
" 'split': 4,\n",
" 'backend': 'sf-imagebuffer'},\n",
" {'stream': 'tcp://daqsf-sioc-cs-41.psi.ch:9000',\n",
" 'split': 4,\n",
" 'backend': 'sf-imagebuffer'},\n",
" {'stream': 'tcp://daqsf-sioc-cs-41.psi.ch:9010',\n",
" 'split': 4,\n",
" 'backend': 'sf-imagebuffer'},\n",
" {'stream': 'tcp://daqsf-sioc-cs-51.psi.ch:9000',\n",
" 'split': 4,\n",
" 'backend': 'sf-imagebuffer'},\n",
" {'stream': 'tcp://daqsf-sioc-cs-61.psi.ch:9000',\n",
" 'split': 4,\n",
" 'backend': 'sf-imagebuffer'},\n",
" {'stream': 'tcp://daqsf-sioc-cs-61.psi.ch:9010',\n",
" 'split': 4,\n",
" 'backend': 'sf-imagebuffer'},\n",
" {'stream': 'tcp://daqsf-sioc-cs-62.psi.ch:9000',\n",
" 'split': 4,\n",
" 'backend': 'sf-imagebuffer'},\n",
" {'stream': 'tcp://daqsf-sioc-cs-62.psi.ch:9010',\n",
" 'split': 4,\n",
" 'backend': 'sf-imagebuffer'},\n",
" {'stream': 'tcp://daqsf-sioc-cs-63.psi.ch:9000',\n",
" 'split': 4,\n",
" 'backend': 'sf-imagebuffer'},\n",
" {'stream': 'tcp://daqsf-sioc-cs-63.psi.ch:9010',\n",
" 'split': 4,\n",
" 'backend': 'sf-imagebuffer'},\n",
" {'stream': 'tcp://daqsf-sioc-cs-64.psi.ch:9000',\n",
" 'split': 4,\n",
" 'backend': 'sf-imagebuffer'},\n",
" {'stream': 'tcp://daqsf-sioc-cs-64.psi.ch:9010',\n",
" 'split': 4,\n",
" 'backend': 'sf-imagebuffer'},\n",
" {'stream': 'tcp://daqsf-sioc-cs-65.psi.ch:9000',\n",
" 'split': 4,\n",
" 'backend': 'sf-imagebuffer'},\n",
" {'stream': 'tcp://daqsf-sioc-cs-65.psi.ch:9010',\n",
" 'split': 4,\n",
" 'backend': 'sf-imagebuffer'},\n",
" {'stream': 'tcp://daqsf-sioc-cs-65.psi.ch:9020',\n",
" 'split': 4,\n",
" 'backend': 'sf-imagebuffer'},\n",
" {'stream': 'tcp://daqsf-sioc-cs-74.psi.ch:9000',\n",
" 'split': 4,\n",
" 'backend': 'sf-imagebuffer'},\n",
" {'stream': 'tcp://daqsf-sioc-cs-74.psi.ch:9010',\n",
" 'split': 4,\n",
" 'backend': 'sf-imagebuffer'},\n",
" {'stream': 'tcp://daqsf-sioc-cs-74.psi.ch:9020',\n",
" 'split': 4,\n",
" 'backend': 'sf-imagebuffer'},\n",
" {'stream': 'tcp://daqsf-sioc-cs-74.psi.ch:9030',\n",
" 'split': 4,\n",
" 'backend': 'sf-imagebuffer'},\n",
" {'stream': 'tcp://daqsf-sioc-cs-74.psi.ch:9040',\n",
" 'split': 4,\n",
" 'backend': 'sf-imagebuffer'},\n",
" {'stream': 'tcp://daqsf-sioc-cs-74.psi.ch:9050',\n",
" 'split': 4,\n",
" 'backend': 'sf-imagebuffer'},\n",
" {'stream': 'tcp://daqsf-sioc-cs-74.psi.ch:9060',\n",
" 'split': 4,\n",
" 'backend': 'sf-imagebuffer'},\n",
" {'stream': 'tcp://daqsf-sioc-cs-74.psi.ch:9070',\n",
" 'split': 4,\n",
" 'backend': 'sf-imagebuffer'},\n",
" {'stream': 'tcp://daqsf-sioc-cs-74.psi.ch:9090',\n",
" 'split': 4,\n",
" 'backend': 'sf-imagebuffer'},\n",
" {'stream': 'tcp://daqsf-sioc-cs-74.psi.ch:9100',\n",
" 'split': 4,\n",
" 'backend': 'sf-imagebuffer'},\n",
" {'stream': 'tcp://daqsf-sioc-cs-74.psi.ch:9120',\n",
" 'split': 4,\n",
" 'backend': 'sf-imagebuffer'},\n",
" {'stream': 'tcp://daqsf-sioc-cs-74.psi.ch:9130',\n",
" 'split': 4,\n",
" 'backend': 'sf-imagebuffer'},\n",
" {'stream': 'tcp://daqsf-sioc-cs-74.psi.ch:9140',\n",
" 'split': 4,\n",
" 'backend': 'sf-imagebuffer'},\n",
" {'stream': 'tcp://daqsf-sioc-cs-74.psi.ch:9150',\n",
" 'split': 4,\n",
" 'backend': 'sf-imagebuffer'},\n",
" {'stream': 'tcp://daqsf-sioc-cs-74.psi.ch:9160',\n",
" 'split': 4,\n",
" 'backend': 'sf-imagebuffer'},\n",
" {'stream': 'tcp://daqsf-sioc-cs-81.psi.ch:9000',\n",
" 'split': 4,\n",
" 'backend': 'sf-imagebuffer'},\n",
" {'stream': 'tcp://daqsf-sioc-cs-81.psi.ch:9010',\n",
" 'split': 4,\n",
" 'backend': 'sf-imagebuffer'},\n",
" {'stream': 'tcp://daqsf-sioc-cs-81.psi.ch:9030',\n",
" 'split': 4,\n",
" 'backend': 'sf-imagebuffer'},\n",
" {'stream': 'tcp://daqsf-sioc-cs-81.psi.ch:8080',\n",
" 'split': 4,\n",
" 'backend': 'sf-imagebuffer'},\n",
" {'stream': 'tcp://daqsf-sioc-cs-83.psi.ch:8060',\n",
" 'split': 4,\n",
" 'backend': 'sf-imagebuffer'},\n",
" {'stream': 'tcp://daqsf-sioc-cs-83.psi.ch:9000',\n",
" 'split': 4,\n",
" 'backend': 'sf-imagebuffer'},\n",
" {'stream': 'tcp://daqsf-sioc-cs-83.psi.ch:9010',\n",
" 'split': 4,\n",
" 'backend': 'sf-imagebuffer'},\n",
" {'stream': 'tcp://daqsf-sioc-cs-83.psi.ch:9020',\n",
" 'split': 4,\n",
" 'backend': 'sf-imagebuffer'},\n",
" {'stream': 'tcp://daqsf-sioc-cs-84.psi.ch:9000',\n",
" 'split': 4,\n",
" 'backend': 'sf-imagebuffer'},\n",
" {'stream': 'tcp://daqsf-sioc-cs-c2.psi.ch:9000',\n",
" 'split': 4,\n",
" 'backend': 'sf-imagebuffer'},\n",
" {'stream': 'tcp://daqsf-sioc-cs-c2.psi.ch:9010',\n",
" 'split': 4,\n",
" 'backend': 'sf-imagebuffer'},\n",
" {'stream': 'tcp://daqsf-sioc-cs-c2.psi.ch:9020',\n",
" 'split': 4,\n",
" 'backend': 'sf-imagebuffer'},\n",
" {'stream': 'tcp://daqsf-sioc-cs-c2.psi.ch:9030',\n",
" 'split': 4,\n",
" 'backend': 'sf-imagebuffer'},\n",
" {'stream': 'tcp://daqsf-sioc-cs-c2.psi.ch:9040',\n",
" 'split': 4,\n",
" 'backend': 'sf-imagebuffer'},\n",
" {'stream': 'tcp://daqsf-sioc-cs-c2.psi.ch:9050',\n",
" 'split': 4,\n",
" 'backend': 'sf-imagebuffer'},\n",
" {'stream': 'tcp://daqsf-sioc-cs-c2.psi.ch:9060',\n",
" 'split': 4,\n",
" 'backend': 'sf-imagebuffer'},\n",
" {'stream': 'tcp://daqsf-sioc-cs-c2.psi.ch:9070',\n",
" 'split': 4,\n",
" 'backend': 'sf-imagebuffer'},\n",
" {'stream': 'tcp://daqsf-daqsync-05.psi.ch:9000',\n",
" 'split': 4,\n",
" 'backend': 'sf-imagebuffer'},\n",
" {'stream': 'tcp://daqsf-daqsync-05.psi.ch:9010',\n",
" 'split': 4,\n",
" 'backend': 'sf-imagebuffer'},\n",
" {'stream': 'tcp://daqsf-daqsync-05.psi.ch:9002',\n",
" 'split': 4,\n",
" 'backend': 'sf-imagebuffer'},\n",
" {'stream': 'tcp://daqsf-daqsync-06.psi.ch:9002',\n",
" 'split': 4,\n",
" 'backend': 'sf-imagebuffer'},\n",
" {'stream': 'tcp://daqsf-daqsync-06.psi.ch:9000',\n",
" 'split': 4,\n",
" 'backend': 'sf-imagebuffer'},\n",
" {'stream': 'tcp://daqsf-daqsync-06.psi.ch:9010',\n",
" 'split': 4,\n",
" 'backend': 'sf-imagebuffer'},\n",
" {'stream': 'tcp://daqsf-daqsync-04.psi.ch:9000',\n",
" 'split': 4,\n",
" 'backend': 'sf-imagebuffer'},\n",
" {'stream': 'tcp://daqsf-daqsync-04.psi.ch:9010',\n",
" 'split': 4,\n",
" 'backend': 'sf-imagebuffer'},\n",
" {'stream': 'tcp://daqsf-daqsync-02.psi.ch:8890',\n",
" 'split': 4,\n",
" 'backend': 'sf-imagebuffer'},\n",
" {'stream': 'tcp://daqsf-daqsync-06.psi.ch:9005',\n",
" 'split': 4,\n",
" 'backend': 'sf-imagebuffer'},\n",
" {'stream': 'tcp://SARES11-CPCL-GES1:9999'},\n",
" {'stream': 'tcp://SARES11-CPCL-GES1:9990'},\n",
" {'stream': 'tcp://SARES11-CPCL-GES1:9980'},\n",
" {'stream': 'tcp://SARES11-CPCL-GES1:9970'},\n",
" {'stream': 'tcp://SLAAR11-CPPM-MOT6891:9999'},\n",
" {'stream': 'tcp://SLAAR11-CVME-LAS6891:9999'},\n",
" {'stream': 'tcp://SARES11-CVME-PRIME1:9999'},\n",
" {'stream': 'tcp://SARES12-CPCL-GES1:9999'},\n",
" {'stream': 'tcp://SARES12-CVME-FLEX1:9999'},\n",
" {'stream': 'tcp://SARES11-CPPM-MOT6912:9999'},\n",
" {'stream': 'tcp://SARES12-CPPM-MOT6952:9999'},\n",
" {'stream': 'tcp://sf-daqsync-05:9001'},\n",
" {'stream': 'tcp://sf-daqsync-05:9011'},\n",
" {'stream': 'tcp://sf-daqsync-05:9003'},\n",
" {'stream': 'tcp://sf-sioc-cs-61:9030'},\n",
" {'stream': 'tcp://SIN-CPPM-MOT0841:9999'},\n",
" {'stream': 'tcp://S10-CPPM-MOT0991:9999'},\n",
" {'stream': 'tcp://S10-CPPM-MOT1531:9999'},\n",
" {'stream': 'tcp://S10-CPPM-MOT2161:9999'},\n",
" {'stream': 'tcp://S20-CPPM-MOT2551:9999'},\n",
" {'stream': 'tcp://S30-CPPM-MOT3101:9999'},\n",
" {'stream': 'tcp://SAT-CPPM-MOT3391:9999'},\n",
" {'stream': 'tcp://SAT-CPPM-MOT4001:9999'},\n",
" {'stream': 'tcp://SAR-CPPM-MOT4693:9999'},\n",
" {'stream': 'tcp://SAT-CPPM-MOT4891:9999'},\n",
" {'stream': 'tcp://SAR-CPPM-MOT5631:9999'},\n",
" {'stream': 'tcp://SINEG01-CVME-LLRF1:20000'},\n",
" {'stream': 'tcp://SINEG01-CVME-LLRF2:20000'},\n",
" {'stream': 'tcp://SINSB01-CVME-LLRF1:20000'},\n",
" {'stream': 'tcp://SINSB01-CVME-LLRF2:20000'},\n",
" {'stream': 'tcp://SINSB02-CVME-LLRF1:20000'},\n",
" {'stream': 'tcp://SINSB02-CVME-LLRF2:20000'},\n",
" {'stream': 'tcp://SINSB03-CVME-LLRF1:20000'},\n",
" {'stream': 'tcp://SINSB03-CVME-LLRF2:20000'},\n",
" {'stream': 'tcp://SINSB04-CVME-LLRF1:20000'},\n",
" {'stream': 'tcp://SINSB04-CVME-LLRF2:20000'},\n",
" {'stream': 'tcp://SINXB01-CVME-LLRF1:20000'},\n",
" {'stream': 'tcp://SINXB01-CVME-LLRF2:20000'},\n",
" {'stream': 'tcp://SINDI01-CVME-LLRF1:20000'},\n",
" {'stream': 'tcp://SINDI01-CVME-LLRF2:20000'},\n",
" {'stream': 'tcp://S10CB01-CVME-LLRF1:20000'},\n",
" {'stream': 'tcp://S10CB01-CVME-LLRF2:20000'},\n",
" {'stream': 'tcp://S10CB02-CVME-LLRF1:20000'},\n",
" {'stream': 'tcp://S10CB02-CVME-LLRF2:20000'},\n",
" {'stream': 'tcp://S10CB03-CVME-LLRF1:20000'},\n",
" {'stream': 'tcp://S10CB03-CVME-LLRF2:20000'},\n",
" {'stream': 'tcp://S10CB04-CVME-LLRF1:20000'},\n",
" {'stream': 'tcp://S10CB04-CVME-LLRF2:20000'},\n",
" {'stream': 'tcp://S10CB05-CVME-LLRF1:20000'},\n",
" {'stream': 'tcp://S10CB05-CVME-LLRF2:20000'},\n",
" {'stream': 'tcp://S10CB06-CVME-LLRF1:20000'},\n",
" {'stream': 'tcp://S10CB06-CVME-LLRF2:20000'},\n",
" {'stream': 'tcp://S10CB07-CVME-LLRF1:20000'},\n",
" {'stream': 'tcp://S10CB07-CVME-LLRF2:20000'},\n",
" {'stream': 'tcp://S10CB08-CVME-LLRF1:20000'},\n",
" {'stream': 'tcp://S10CB08-CVME-LLRF2:20000'},\n",
" {'stream': 'tcp://S10CB09-CVME-LLRF1:20000'},\n",
" {'stream': 'tcp://S10CB09-CVME-LLRF2:20000'},\n",
" {'stream': 'tcp://S20CB01-CVME-LLRF1:20000'},\n",
" {'stream': 'tcp://S20CB01-CVME-LLRF2:20000'},\n",
" {'stream': 'tcp://S20CB02-CVME-LLRF1:20000'},\n",
" {'stream': 'tcp://S20CB02-CVME-LLRF2:20000'},\n",
" {'stream': 'tcp://S20CB03-CVME-LLRF1:20000'},\n",
" {'stream': 'tcp://S20CB03-CVME-LLRF2:20000'},\n",
" {'stream': 'tcp://S20CB04-CVME-LLRF1:20000'},\n",
" {'stream': 'tcp://S20CB04-CVME-LLRF2:20000'},\n",
" {'stream': 'tcp://S30CB01-CVME-LLRF1:20000'},\n",
" {'stream': 'tcp://S30CB01-CVME-LLRF2:20000'},\n",
" {'stream': 'tcp://S30CB02-CVME-LLRF1:20000'},\n",
" {'stream': 'tcp://S30CB02-CVME-LLRF2:20000'},\n",
" {'stream': 'tcp://S30CB03-CVME-LLRF1:20000'},\n",
" {'stream': 'tcp://S30CB03-CVME-LLRF2:20000'},\n",
" {'stream': 'tcp://S30CB04-CVME-LLRF1:20000'},\n",
" {'stream': 'tcp://S30CB04-CVME-LLRF2:20000'},\n",
" {'stream': 'tcp://S30CB05-CVME-LLRF1:20000'},\n",
" {'stream': 'tcp://S30CB05-CVME-LLRF2:20000'},\n",
" {'stream': 'tcp://S30CB06-CVME-LLRF1:20000'},\n",
" {'stream': 'tcp://S30CB06-CVME-LLRF2:20000'},\n",
" {'stream': 'tcp://S30CB07-CVME-LLRF1:20000'},\n",
" {'stream': 'tcp://S30CB07-CVME-LLRF2:20000'},\n",
" {'stream': 'tcp://S30CB08-CVME-LLRF1:20000'},\n",
" {'stream': 'tcp://S30CB08-CVME-LLRF2:20000'},\n",
" {'stream': 'tcp://S30CB09-CVME-LLRF1:20000'},\n",
" {'stream': 'tcp://S30CB09-CVME-LLRF2:20000'},\n",
" {'stream': 'tcp://S30CB10-CVME-LLRF1:20000'},\n",
" {'stream': 'tcp://S30CB10-CVME-LLRF2:20000'},\n",
" {'stream': 'tcp://S30CB11-CVME-LLRF1:20000'},\n",
" {'stream': 'tcp://S30CB11-CVME-LLRF2:20000'},\n",
" {'stream': 'tcp://S30CB12-CVME-LLRF1:20000'},\n",
" {'stream': 'tcp://S30CB12-CVME-LLRF2:20000'},\n",
" {'stream': 'tcp://S30CB13-CVME-LLRF1:20000'},\n",
" {'stream': 'tcp://S30CB13-CVME-LLRF2:20000'},\n",
" {'stream': 'tcp://S30CB14-CVME-LLRF1:20000'},\n",
" {'stream': 'tcp://S30CB14-CVME-LLRF2:20000'},\n",
" {'stream': 'tcp://SATCB01-CVME-LLRF1:20000'},\n",
" {'stream': 'tcp://SATCB01-CVME-LLRF2:20000'},\n",
" {'stream': 'tcp://SINEGTS-CVME-LLRF1:20000'},\n",
" {'stream': 'tcp://SINEGTS-CVME-LLRF2:20000'},\n",
" {'stream': 'tcp://SARFE10-CVME-PHO6211:9999'},\n",
" {'stream': 'tcp://SARFE10-CVME-PHO6212:9999'},\n",
" {'stream': 'tcp://SARFE10-CVME-PBIG050:9999'},\n",
" {'stream': 'tcp://SAROP11-CVME-PBPS1:9999'},\n",
" {'stream': 'tcp://SAROP11-CVME-PBPS2:9999'},\n",
" {'stream': 'tcp://SAROP21-CVME-PBPS1:9999'},\n",
" {'stream': 'tcp://SAROP21-CVME-PBPS2:9999'},\n",
" {'stream': 'tcp://SAROP21-CVME-PBPS3:9999'},\n",
" {'stream': 'SATFE10-CVME-PEPG046:9999'},\n",
" {'stream': 'tcp://SIN-CVME-DBPM0421:9000'},\n",
" {'stream': 'tcp://SIN-CVME-DBPM0422:9000'},\n",
" {'stream': 'tcp://S10-CVME-DBPM1431:9000'},\n",
" {'stream': 'tcp://S20-CVME-DBPM2371:9000'},\n",
" {'stream': 'tcp://S30-CVME-DBPM3391:9000'},\n",
" {'stream': 'tcp://S30-CVME-DBPM3392:9000'},\n",
" {'stream': 'tcp://S30-CVME-DBPM4101:9000'},\n",
" {'stream': 'tcp://S30-CVME-DBPM4102:9000'},\n",
" {'stream': 'tcp://S30-CVME-DBPM4103:9000'},\n",
" {'stream': 'tcp://SARUN-CVME-DBPM4941:9000'},\n",
" {'stream': 'tcp://SARUN-CVME-DBPM4942:9000'},\n",
" {'stream': 'tcp://SARUN-CVME-DBPM5411:9000'},\n",
" {'stream': 'tcp://SARUN-CVME-DBPM5412:9000'},\n",
" {'stream': 'tcp://SATUN06-DBPM-DIA4261:9000'},\n",
" {'stream': 'tcp://SATUN06-DBPM-DIA4261:9002'},\n",
" {'stream': 'tcp://SATUN06-DBPM-DIA4261:9004'},\n",
" {'stream': 'tcp://SATUN06-DBPM-DIA4261:9006'},\n",
" {'stream': 'tcp://SATUN06-DBPM-DIA4262:9000'},\n",
" {'stream': 'tcp://SATUN06-DBPM-DIA4262:9002'},\n",
" {'stream': 'tcp://SATUN06-DBPM-DIA4262:9004'},\n",
" {'stream': 'tcp://SATUN06-DBPM-DIA4262:9006'},\n",
" {'stream': 'tcp://SATMA01-DBPM-DIA3901:9000'},\n",
" {'stream': 'tcp://SATMA01-DBPM-DIA3901:9002'},\n",
" {'stream': 'tcp://SATMA01-DBPM-DIA3902:9000'},\n",
" {'stream': 'tcp://SATMA01-DBPM-DIA3902:9004'},\n",
" {'stream': 'tcp://SATMA01-DBPM-DIA4191:9000'},\n",
" {'stream': 'tcp://SATMA01-DBPM-DIA4191:9002'},\n",
" {'stream': 'tcp://SATMA01-DBPM-DIA4191:9004'},\n",
" {'stream': 'tcp://SATMA01-DBPM-DIA4191:9006'},\n",
" {'stream': 'tcp://SATUN21-DBPM-DIA4711:9004'},\n",
" {'stream': 'tcp://SATUN21-DBPM-DIA4711:9006'},\n",
" {'stream': 'tcp://SFTEST-CVME-DBPM1:9000'}]}"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"sources"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [],
"source": [
"policies = read_files(Path(\"policies/\"), \"policies\")"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'policies': [{'pattern': '^ignore',\n",
" 'data_reduction': {'default': [{'ttl': -1, 'modulo': 1}]}},\n",
" {'pattern': ':FPICTURE$',\n",
" 'data_reduction': {'default': [{'ttl': 'P1D', 'modulo': 1}]}},\n",
" {'pattern': '-RLLE-STA:',\n",
" 'data_reduction': {'default': [{'ttl': 'P2W', 'modulo': 1},\n",
" {'ttl': 'P2M', 'modulo': 100},\n",
" {'ttl': 'P50Y', 'modulo': 60000}]}},\n",
" {'pattern': '-RLLE-STA:.*TIMER$',\n",
" 'data_reduction': {'default': [{'ttl': 'P2W', 'modulo': 1}]}},\n",
" {'pattern': '-RLLE-STA:.*EVRPULSEID$',\n",
" 'data_reduction': {'default': [{'ttl': 'P2W', 'modulo': 1}]}},\n",
" {'pattern': '-RLLE-STA:.*MSICNT$',\n",
" 'data_reduction': {'default': [{'ttl': 'P2W', 'modulo': 1}]}},\n",
" {'pattern': '-RLLE-DSP:',\n",
" 'data_reduction': {'default': [{'ttl': 'P2W', 'modulo': 1},\n",
" {'ttl': 'P2M', 'modulo': 100},\n",
" {'ttl': 'P50Y', 'modulo': 60000}]}},\n",
" {'pattern': '-RIQM-STA:DAC',\n",
" 'data_reduction': {'waveform': [{'ttl': 'P2D', 'modulo': 1},\n",
" {'ttl': 'P2M', 'modulo': 100},\n",
" {'ttl': 'P50Y', 'modulo': 60000}]}},\n",
" {'pattern': '-AMPLT$',\n",
" 'data_reduction': {'waveform': [{'ttl': 'P2D', 'modulo': 1},\n",
" {'ttl': 'P2M', 'modulo': 100},\n",
" {'ttl': 'P50Y', 'modulo': 60000}]}},\n",
" {'pattern': '-PHASE$',\n",
" 'data_reduction': {'waveform': [{'ttl': 'P2D', 'modulo': 1},\n",
" {'ttl': 'P2M', 'modulo': 100},\n",
" {'ttl': 'P50Y', 'modulo': 60000}]}},\n",
" {'pattern': '-ADCRAW$',\n",
" 'data_reduction': {'waveform': [{'ttl': 'PT2H', 'modulo': 1}]}},\n",
" {'pattern': '-AMPLT-AVG$',\n",
" 'data_reduction': {'scalar': [{'ttl': 'P2W', 'modulo': 1},\n",
" {'ttl': 'P2M', 'modulo': 100},\n",
" {'ttl': 'P50Y', 'modulo': 60000}]}},\n",
" {'pattern': '-PHASE-AVG$',\n",
" 'data_reduction': {'scalar': [{'ttl': 'P2W', 'modulo': 1},\n",
" {'ttl': 'P2M', 'modulo': 100},\n",
" {'ttl': 'P50Y', 'modulo': 60000}]}},\n",
" {'pattern': '^SINEG01.*-RIQM-STA:DAC',\n",
" 'data_reduction': {'waveform': [{'ttl': 'P2W', 'modulo': 1},\n",
" {'ttl': 'P2M', 'modulo': 100},\n",
" {'ttl': 'P50Y', 'modulo': 60000}]}},\n",
" {'pattern': '^SINEGTS-.*',\n",
" 'data_reduction': {'scalar': [{'ttl': 'P4D', 'modulo': 1}],\n",
" 'waveform': [{'ttl': 'PT6H', 'modulo': 1}]}},\n",
" {'pattern': '^S.*-DBLM.*:BASELINE_VAL$',\n",
" 'data_reduction': {'default': [{'ttl': 'P10D', 'modulo': 1}]}},\n",
" {'pattern': '^S.*-DBLM.*:LOSS_SIGNAL_RAW$',\n",
" 'data_reduction': {'default': [{'ttl': 'P2D', 'modulo': 1}]}},\n",
" {'pattern': '^S.*-DBLM.*:B[12]_LOSS.*',\n",
" 'data_reduction': {'default': [{'ttl': 'P10D', 'modulo': 1}]}},\n",
" {'pattern': '.',\n",
" 'data_reduction': {'scalar': [{'ttl': 'P3D', 'modulo': 1}],\n",
" 'waveform': [{'ttl': 'P2D', 'modulo': 1}]}},\n",
" {'pattern': '^SATCB01-',\n",
" 'data_reduction': {'default': [{'ttl': 'P1D', 'modulo': 1}]}},\n",
" {'pattern': '^SIN-CVME-TIFGUN-EVR0:BEAMOK$',\n",
" 'data_reduction': {'default': [{'ttl': 'P20W', 'modulo': 1}]}},\n",
" {'pattern': '^.*:EvtSet$',\n",
" 'data_reduction': {'default': [{'ttl': 'P20W', 'modulo': 1}]}},\n",
" {'pattern': '^SAROP21-PALMK134',\n",
" 'data_reduction': {'default': [{'ttl': 'P3D', 'modulo': 1}]}},\n",
" {'pattern': '^SAROP21-CVME-PBPS2:Lnk9',\n",
" 'data_reduction': {'default': [{'ttl': 'P3D', 'modulo': 1}]}},\n",
" {'pattern': '^SAROP21-CVME-PBPS1:Lnk9',\n",
" 'data_reduction': {'default': [{'ttl': 'P3D', 'modulo': 1}]}},\n",
" {'pattern': '^SAROP21-PBPS',\n",
" 'data_reduction': {'default': [{'ttl': 'P3D', 'modulo': 1}]}},\n",
" {'pattern': '^SARFE10-CVME-PHO6211:Lnk9',\n",
" 'data_reduction': {'default': [{'ttl': 'P3D', 'modulo': 1}]}},\n",
" {'pattern': '^SARFE10-PBPG050',\n",
" 'data_reduction': {'default': [{'ttl': 'P3D', 'modulo': 1}]}},\n",
" {'pattern': '^SARCL02-DBPM.*X1',\n",
" 'data_reduction': {'default': [{'ttl': 'P3D', 'modulo': 1}]}},\n",
" {'pattern': '^SARBD02-DBPM.*Y1',\n",
" 'data_reduction': {'default': [{'ttl': 'P3D', 'modulo': 1}]}},\n",
" {'pattern': 'DBPM.*T1$',\n",
" 'data_reduction': {'default': [{'ttl': 'P3D', 'modulo': 1}]}},\n",
" {'pattern': '^S10BC01-DBAM070',\n",
" 'data_reduction': {'default': [{'ttl': 'P3D', 'modulo': 1}]}},\n",
" {'pattern': '^SINLH01-DBAM010',\n",
" 'data_reduction': {'default': [{'ttl': 'P3D', 'modulo': 1}]}},\n",
" {'pattern': '^SINEG01-DWCM170:CHARGE$',\n",
" 'data_reduction': {'default': [{'ttl': 'P2W', 'modulo': 1},\n",
" {'ttl': 'P6M', 'modulo': 100},\n",
" {'ttl': 'P5Y', 'modulo': 60000}]}},\n",
" {'pattern': '^SINEG01-DFCP185:CHARGE$',\n",
" 'data_reduction': {'default': [{'ttl': 'P2W', 'modulo': 1},\n",
" {'ttl': 'P6M', 'modulo': 100},\n",
" {'ttl': 'P5Y', 'modulo': 60000}]}},\n",
" {'pattern': '^S.*-DICT.*_CHARGE$',\n",
" 'data_reduction': {'default': [{'ttl': 'P2W', 'modulo': 1},\n",
" {'ttl': 'P6M', 'modulo': 100},\n",
" {'ttl': 'P5Y', 'modulo': 60000}]}},\n",
" {'pattern': '^S.*-DICT.*:TOTAL_CHARGE_HOUR$',\n",
" 'data_reduction': {'default': [{'ttl': 'P6M', 'modulo': 100},\n",
" {'ttl': 'P5Y', 'modulo': 60000},\n",
" {'ttl': -1, 'modulo': 1}]}},\n",
" {'pattern': '^S.*-DBPM.*:[XYQT][12]$',\n",
" 'data_reduction': {'default': [{'ttl': 'P2W', 'modulo': 1},\n",
" {'ttl': 'P6M', 'modulo': 100},\n",
" {'ttl': 'P5Y', 'modulo': 60000}]}},\n",
" {'pattern': '^S.*-DBPM.*:[XYQT][12]-VALID$',\n",
" 'data_reduction': {'default': [{'ttl': 'P2W', 'modulo': 1},\n",
" {'ttl': 'P6M', 'modulo': 100},\n",
" {'ttl': 'P5Y', 'modulo': 60000}]}},\n",
" {'pattern': '^S.*-DBPM.*:[XYQ][12]_MPS$',\n",
" 'data_reduction': {'default': [{'ttl': 'P2W', 'modulo': 1},\n",
" {'ttl': 'P6M', 'modulo': 100},\n",
" {'ttl': 'P5Y', 'modulo': 60000}]}},\n",
" {'pattern': '^SLG-LCAM-C103:FIT-[XY]POS_EGU$',\n",
" 'data_reduction': {'default': [{'ttl': 'P2W', 'modulo': 1},\n",
" {'ttl': 'P6M', 'modulo': 100},\n",
" {'ttl': 'P5Y', 'modulo': 60000}]}},\n",
" {'pattern': '^SLG-LCAM-C103:FIT-[XY]WID_EGU$',\n",
" 'data_reduction': {'default': [{'ttl': 'P2W', 'modulo': 1},\n",
" {'ttl': 'P6M', 'modulo': 100},\n",
" {'ttl': 'P5Y', 'modulo': 60000}]}},\n",
" {'pattern': '^S.*DBAM.*:EOM[12]_T[12]$',\n",
" 'data_reduction': {'default': [{'ttl': 'P2W', 'modulo': 1},\n",
" {'ttl': 'P6M', 'modulo': 100},\n",
" {'ttl': 'P5Y', 'modulo': 60000}]}},\n",
" {'pattern': '^S.*DBCM.*:B[12]_CH[12]_SIG$',\n",
" 'data_reduction': {'default': [{'ttl': 'P2W', 'modulo': 1},\n",
" {'ttl': 'P6M', 'modulo': 100},\n",
" {'ttl': 'P5Y', 'modulo': 60000}]}},\n",
" {'pattern': '^S.*DBCM.*:B[12]_CH[12]_SIG_VALID$',\n",
" 'data_reduction': {'default': [{'ttl': 'P2W', 'modulo': 1},\n",
" {'ttl': 'P6M', 'modulo': 100},\n",
" {'ttl': 'P5Y', 'modulo': 60000}]}},\n",
" {'pattern': '^S.*DCDR.*:B[12]_CH[12]_SIG$',\n",
" 'data_reduction': {'default': [{'ttl': 'P2W', 'modulo': 1},\n",
" {'ttl': 'P6M', 'modulo': 100},\n",
" {'ttl': 'P5Y', 'modulo': 60000}]}},\n",
" {'pattern': '^S.*DCDR.*:B[12]_CH[12]_SIG_VALID$',\n",
" 'data_reduction': {'default': [{'ttl': 'P2W', 'modulo': 1},\n",
" {'ttl': 'P6M', 'modulo': 100},\n",
" {'ttl': 'P5Y', 'modulo': 60000}]}},\n",
" {'pattern': '^S.*DBLM.*:B[12]_LOSS$',\n",
" 'data_reduction': {'default': [{'ttl': 'P2W', 'modulo': 1},\n",
" {'ttl': 'P6M', 'modulo': 100},\n",
" {'ttl': 'P5Y', 'modulo': 60000}]}},\n",
" {'pattern': '^S.*DBLM.*:B[12]_LOSS_MPS$',\n",
" 'data_reduction': {'default': [{'ttl': 'P2W', 'modulo': 1},\n",
" {'ttl': 'P6M', 'modulo': 100},\n",
" {'ttl': 'P5Y', 'modulo': 60000}]}},\n",
" {'pattern': '^S.*DLLM.*:CH.*_LOSS$',\n",
" 'data_reduction': {'default': [{'ttl': 'P2W', 'modulo': 1},\n",
" {'ttl': 'P6M', 'modulo': 100},\n",
" {'ttl': 'P5Y', 'modulo': 60000}]}},\n",
" {'pattern': '^S.*DLLM.*:CH.*_LOSS_MPS$',\n",
" 'data_reduction': {'default': [{'ttl': 'P2W', 'modulo': 1},\n",
" {'ttl': 'P6M', 'modulo': 100},\n",
" {'ttl': 'P5Y', 'modulo': 60000}]}},\n",
" {'pattern': '^S.*DWSC.*:ENC_1_BS$',\n",
" 'data_reduction': {'default': [{'ttl': 'P2W', 'modulo': 1},\n",
" {'ttl': 'P6M', 'modulo': 100},\n",
" {'ttl': 'P5Y', 'modulo': 60000}]}},\n",
" {'pattern': '^S.*-RSYS:GET-BEAM-PHASE$',\n",
" 'data_reduction': {'default': [{'ttl': 'P2W', 'modulo': 1},\n",
" {'ttl': 'P6M', 'modulo': 100},\n",
" {'ttl': 'P5Y', 'modulo': 60000}]}},\n",
" {'pattern': '^S.*-RSYS:GET-ACC-VOLT$',\n",
" 'data_reduction': {'default': [{'ttl': 'P2W', 'modulo': 1},\n",
" {'ttl': 'P6M', 'modulo': 100},\n",
" {'ttl': 'P5Y', 'modulo': 60000}]}},\n",
" {'pattern': '^S.*-DLLM.*:BASELINE_VAL$',\n",
" 'data_reduction': {'default': [{'ttl': 'P10D', 'modulo': 1}]}},\n",
" {'pattern': '^S.*-DLLM.*:LOSS_SIGNAL_RAW$',\n",
" 'data_reduction': {'default': [{'ttl': 'P2D', 'modulo': 1}]}},\n",
" {'pattern': '^S.*-DLLM.*:CH.*_LOSS.*',\n",
" 'data_reduction': {'default': [{'ttl': 'P10D', 'modulo': 1}]}},\n",
" {'pattern': '^SINBC02-DBCM410:AL[12]-B1(()|(-VALID))$',\n",
" 'data_reduction': {'default': [{'ttl': 'P10D', 'modulo': 1}]}},\n",
" {'pattern': '^SINDI02-DCDR065:AL[12]-B1(()|(-VALID))$',\n",
" 'data_reduction': {'default': [{'ttl': 'P10D', 'modulo': 1}]}},\n",
" {'pattern': '^S10MA01-DCDR080:AL[12]-B1(()|(-VALID))$',\n",
" 'data_reduction': {'default': [{'ttl': 'P10D', 'modulo': 1}]}},\n",
" {'pattern': '^SINBC02-DBCM410:LM-((AG-.*-B[1-2]$)|(VALID-.*-B[1-2]$))',\n",
" 'data_reduction': {'default': [{'ttl': 'P3M', 'modulo': 1}]}},\n",
" {'pattern': '^SINDI02-DCDR065:LM-((AG-.*-B[1-2]$)|(VALID-.*-B[1-2]$))',\n",
" 'data_reduction': {'default': [{'ttl': 'P3M', 'modulo': 1}]}},\n",
" {'pattern': '^S10MA01-DCDR080:LM-((AG-.*-B[1-2]$)|(VALID-.*-B[1-2]$))',\n",
" 'data_reduction': {'default': [{'ttl': 'P3M', 'modulo': 1}]}}]}"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"policies"
]
},
{
"cell_type": "code",
"execution_count": 23,
"metadata": {},
"outputs": [],
"source": [
"# https://stackoverflow.com/questions/18179345/uploading-multiple-files-in-a-single-request-using-python-requests-module\n",
"\n",
"from io import StringIO\n",
"\n",
"\n",
"def upload(sources, policies):\n",
" upload_url = \"https://dispatcher-api.psi.ch/sf/configuration/upload\"\n",
"# upload_url = \"http://localhost:1234\"\n",
" \n",
"# upload_files = [(\"all.sources\", open(\"my_file.txt\", \"rb\")),\n",
"# (\"all.policies\", open(\"my_file_2.txt\", \"rb\"))]\n",
" upload_files = [(\"files\", (\"all.sources\", StringIO(json.dumps(sources)))),\n",
" (\"files\", (\"all.policies\", StringIO(json.dumps(policies))))]\n",
"\n",
" test_response = requests.post(upload_url, files = upload_files)\n",
"\n",
" if test_response.ok:\n",
" print(\"Upload completed successfully!\")\n",
" print(test_response.text)\n",
" else:\n",
" print(\"Something went wrong!\")"
]
},
{
"cell_type": "code",
"execution_count": 24,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Upload completed successfully!\n",
"\n"
]
}
],
"source": [
"upload(sources, policies)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"hide_input": false,
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.5"
}
},
"nbformat": 4,
"nbformat_minor": 4
}