Skip to content
Snippets Groups Projects
Verified Commit 803f2841 authored by Tamas Gal's avatar Tamas Gal :speech_balloon:
Browse files

Show tag and map process name more reliably

parent 4251f374
No related branches found
No related tags found
No related merge requests found
Pipeline #32395 passed
......@@ -4,7 +4,7 @@
# Author: Tamas Gal <tgal@km3net.de>
# vim: ts=4 sw=4 et
"""
Dumps MSG data from Ligier to a file.
Dumps MSG and other data from Ligier to a file.
Usage:
msg_dumper.py [options]
......@@ -14,17 +14,26 @@ Options:
-l LIGIER_IP The IP of the ligier [default: 127.0.0.1].
-p LIGIER_PORT The port of the ligier [default: 5553].
-o LOG_DIR Directory to dump the messages [default: logs].
-x PREFIX Prefix for the log files [default: MSG].
-x PREFIX Prefix for the log files [default: MSG,Born,Died].
-h --help Show this screen.
"""
import datetime
import os
import re
from shutil import copyfile
from km3pipe import Pipeline, Module
from km3pipe.io import CHPump
PROCESS_NAME_REGEX = re.compile(r'.*([A-Z])\d{3}/[A-Z]\d{3}.*')
PROCESS_NAME_MAPPING = {
"A": "AcousticDataFilter",
"F": "DataFilter",
"Q": "DataQueue",
"W": "DataWriter",
}
def current_date_str(fmt="%Y-%m-%d"):
"""Return the current datetime string"""
......@@ -53,17 +62,15 @@ class MSGDumper(Module):
def process(self, blob):
data = blob['CHData'].decode()
tag = str(blob["CHPrefix"].tag)
source = "Other"
if " A0" in data:
source = "AcousticDataFilter"
if " F0" in data:
source = "DataFilter"
if " Q0" in data:
source = "DataQueue"
if " W0" in data:
source = "DataWriter"
entry = "{} [{}]: {}\n".format(self.filename, source, data)
match = PROCESS_NAME_REGEX.match(data)
if match is not None:
source = PROCESS_NAME_MAPPING.get(match[1], "Unknown process")
entry = "{} {} [{}]: {}\n".format(self.filename, tag, source, data)
self.update_file_descriptor()
self.fobj.write(entry)
self.fobj.flush()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment