diff --git a/tangostationcontrol/tangostationcontrol/statistics_writer/statistics_reader.py b/tangostationcontrol/tangostationcontrol/statistics_writer/statistics_reader.py index f0906e7d4122b2f1d0d8d864d8c6a47ad793c0f4..67ff6377cdf90326d7a9fa33a015c1ac5861064d 100644 --- a/tangostationcontrol/tangostationcontrol/statistics_writer/statistics_reader.py +++ b/tangostationcontrol/tangostationcontrol/statistics_writer/statistics_reader.py @@ -5,16 +5,9 @@ import argparse import os import psutil import pytz -import time process = psutil.Process(os.getpid()) -parser = argparse.ArgumentParser(description='Select a file to explore') -parser.add_argument('--files', type=str, nargs="+", help='the name and path of the files, takes one or more files') -parser.add_argument('--start_time', type=str, help='lowest timestamp to process (uses isoformat, ex: 2021-10-04T07:50:08.937+00:00)') -parser.add_argument('--end_time', type=str, help='highest timestamp to process (uses isoformat, ex: 2021-10-04T07:50:08.937+00:00)') - - import logging logging.basicConfig(level=logging.INFO) logger = logging.getLogger("hdf5_explorer") @@ -219,7 +212,20 @@ class statistics_data: self.values = numpy.array(file.get(f"{group_key}/values")) -if __name__ == "__main__": +def main(): + parser = argparse.ArgumentParser(description='Select a file to explore') + parser.add_argument( + '--files', type=str, nargs="+", required=True, + help='the name and path of the files, takes one or more files') + parser.add_argument( + '--start_time', type=str, required=True, + help='lowest timestamp to process (uses isoformat, ex: 2021-10-04T07:50' + ':08.937+00:00)') + parser.add_argument( + '--end_time', type=str, required=True, + help='highest timestamp to process (usesisoformat, ex: 2021-10-04T07:50' + ':08.937+00:00)') + args = parser.parse_args() files = args.files end_time = args.end_time diff --git a/tangostationcontrol/tangostationcontrol/statistics_writer/statistics_writer.py b/tangostationcontrol/tangostationcontrol/statistics_writer/statistics_writer.py index 594e261c6d1e00e0ea7882c595449813c305c8ce..2bc45604d07f7367d1f53312133b250f490634a5 100644 --- a/tangostationcontrol/tangostationcontrol/statistics_writer/statistics_writer.py +++ b/tangostationcontrol/tangostationcontrol/statistics_writer/statistics_writer.py @@ -1,27 +1,45 @@ import argparse -from receiver import tcp_receiver, file_receiver -from hdf5_writer import hdf5_writer - import sys -import signal + +from tangostationcontrol.statistics_writer.receiver import tcp_receiver, file_receiver +from tangostationcontrol.statistics_writer.hdf5_writer import hdf5_writer import logging logging.basicConfig(level=logging.INFO) logger = logging.getLogger("statistics_writer") -parser = argparse.ArgumentParser(description='Converts a stream of statistics packets into HDF5 files.') -parser.add_argument('-a', '--host', type=str, help='the host to connect to') -parser.add_argument('-p', '--port', type=int, default=0, help='the port to connect to, or 0 to use default port for the selected mode (default: %(default)s)') -parser.add_argument('-f', '--file', type=str, help='the file to read from') - -parser.add_argument('-m', '--mode', type=str, choices=['SST', 'XST', 'BST'], default='SST', help='sets the statistics type to be decoded options (default: %(default)s)') -parser.add_argument('-i', '--interval', type=float, default=3600, nargs="?", help='The time between creating new files in seconds (default: %(default)s)') -parser.add_argument('-o', '--output_dir', type=str, default=".", nargs="?", help='specifies the folder to write all the files (default: %(default)s)') -parser.add_argument('-v', '--debug', dest='debug', action='store_true', default=False, help='increase log output') -parser.add_argument('-d', '--decimation', type=int, default=1, help='Configure the writer to only store one every n samples. Saves storage space') +def main(): + parser = argparse.ArgumentParser( + description='Converts a stream of statistics packets into HDF5 files.') + parser.add_argument( + '-a', '--host', type=str, required=True, help='the host to connect to') + parser.add_argument( + '-p', '--port', type=int, default=0, + help='the port to connect to, or 0 to use default port for the ' + 'selected mode (default: %(default)s)') + parser.add_argument( + '-f', '--file', type=str, required=True, help='the file to read from') + parser.add_argument( + '-m', '--mode', type=str, choices=['SST', 'XST', 'BST'], default='SST', + help='sets the statistics type to be decoded options (default: ' + '%(default)s)') + parser.add_argument( + '-i', '--interval', type=float, default=3600, nargs="?", + help='The time between creating new files in seconds (default: ' + '%(default)s)') + parser.add_argument( + '-o', '--output_dir', type=str, default=".", nargs="?", + help='specifies the folder to write all the files (default: ' + '%(default)s)') + parser.add_argument( + '-v', '--debug', dest='debug', action='store_true', default=False, + help='increase log output') + parser.add_argument( + '-d', '--decimation', type=int, default=1, + help='Configure the writer to only store one every n samples. Saves ' + 'storage space') -if __name__ == "__main__": args = parser.parse_args() # argparse arguments