From a7b28e8f1f07a5638931f4bac52acd603d13a0bb Mon Sep 17 00:00:00 2001 From: ErikHogenbirk Date: Wed, 6 Feb 2019 08:31:47 +0100 Subject: [PATCH] Working on autoprocessing --- .gitignore | 4 ++++ autoprocessing/process_run.py | 25 ++++++++++++++++++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index fd6a4a7c..d4d059a0 100644 --- a/.gitignore +++ b/.gitignore @@ -58,3 +58,7 @@ docs/_build # coverage .coverage + +# scripts +*.e[0-9][0-9][0-9][0-9][0-9]* +*.o[0-9][0-9][0-9][0-9][0-9]* diff --git a/autoprocessing/process_run.py b/autoprocessing/process_run.py index 62b4f507..1eabed95 100644 --- a/autoprocessing/process_run.py +++ b/autoprocessing/process_run.py @@ -1,12 +1,17 @@ version = '0.0.0' print(f'This is process_run version {version} initializing...') + import sys import json import strax import amstrax -import shutil +# import shutil +import os +from sshtunnel import SSHTunnelForwarder +import pymongo import os + nargs = 1 if len(sys.argv) != 1 + nargs: @@ -26,6 +31,22 @@ print(f'ERROR: could not load configuration from data/xenon/xams/processing_folder/config/{run_name}.json.') sys.exit(2) +MONGO_HOST = "145.102.133.174" +MONGO_DB = "xamsdata0" +MONGO_USER = "xams" +if "MONGO_PASS" not in dict(os.environ).keys(): + raise RuntimeError("DAQ password not set. Please define in .bashrc file. (i.e. 'export MONGO_PASS = ')") +MONGO_PASS = os.environ['MONGO_PASS'] + +print('Initializing server...') +server = SSHTunnelForwarder( + MONGO_HOST, + ssh_username=MONGO_USER, + ssh_password=MONGO_PASS, + remote_bind_address=('127.0.0.1', 27017) +) +server.start() +print('Server started.') print(f'Writing to folder location {run_doc['data_folder']}') st = strax.Context(storage=strax.DataDirectory(run_doc['data_folder']), @@ -37,6 +58,8 @@ st.make(run_name, 'records') print('Record building done.') + + if run_doc['delete_raw_records']: print('Deleting raw records...') print('WARNING not implemented yet...')