diff --git a/LCU/StationTest/rspctlprobe.py b/LCU/StationTest/rspctlprobe.py old mode 100755 new mode 100644 index 1d254e6ad388452474771e25d72e34e82f82573f..96dab5d98679c2736d0312ea9e344db579fdf07f --- a/LCU/StationTest/rspctlprobe.py +++ b/LCU/StationTest/rspctlprobe.py @@ -19,6 +19,31 @@ from functools import reduce name = __name__ if __name__ != '__main__' else 'rspctlprobe' logger = logging.getLogger(name) +_NUM_HBA_ELEMENTS = 16 + +# Optimum element calculation done by M.Brentjes (Dec 2015) +_OptimumElements_Int = [0, 5, 3, 1, 8, 3, 12, 15, 10, 13, 11, 5, 12, 12, 5, 2, 10, 8, 0, 3, 5, 1, 4, 0, 11, 6, 2, 4, 9, + 14, 15, 3, 7, 5, 13, 15, 5, 6, 5, 12, 15, 7, 1, 1, 14, 9, 4, 9, 3, 9, 3, 13, 7, 14, 7, 14, 2, 8, + 8, 0, 1, 4, 2, 2, 12, 15, 5, 7, 6, 10, 12, 3, 3, 12, 7, 4, 6, 0, 5, 9, 1, 10, 10, 11, 5, 11, 7, + 9, 7, 6, 4, 4, 15, 4, 1, 15] +_OptimumElements_Core = [0, 10, 4, 3, 14, 0, 5, 5, 3, 13, 10, 3, 12, 2, 7, 15, 6, 14, 7, 5, 7, 9, 0, 15, 0, 10, 4, 3, + 14, 0, 5, 5, 3, 13, 10, 3, 12, 2, 7, 15, 6, 14, 7, 5, 7, 9, 0, 15] +_OptimumElements_Remote = [0, 13, 12, 4, 11, 11, 7, 8, 2, 7, 11, 2, 10, 2, 6, 3, 8, 3, 1, 7, 1, 15, 13, 1, 11, 1, 12, 7, + 10, 15, 8, 2, 12, 13, 9, 13, 4, 5, 5, 12, 5, 5, 9, 11, 15, 12, 2, 15] + +_NUM_TILES = {'core': 48, + 'remote': 48, + 'international': 96} +_OptimumElements = {'core': _OptimumElements_Core, + 'remote': _OptimumElements_Remote, + 'international': _OptimumElements_Int} +_SLEEP_TIME_SINGLE_ELEMENT_SELECTION = 2. # in units of s +STATION_TYPE = 'Unknown' +_HBA_MODES = (5, 6, 7) +_ELEMENT_OFF_CODE = '2' +_ELEMENT_ON_ZERO_DELAY = '128' + + # --------------------------------NICE PRINTOUT def table_maxlength_per_column(column): """ @@ -28,7 +53,8 @@ def table_maxlength_per_column(column): """ return reduce(max, list(map(len, column))) -def compute_table_width(data, margin = 1): + +def compute_table_width(data, margin=1): """ Compute the column width in characters :param data: table made of a list of columns @@ -39,6 +65,7 @@ def compute_table_width(data, margin = 1): """ return [x + 2 * margin for x in list(map(table_maxlength_per_column, data))] + def table_fix_string_length(string, length): """ Reformat each string to have the same character width @@ -48,7 +75,8 @@ def table_fix_string_length(string, length): :type length: str :return: a formatted string with the request character size """ - return '{:^{width}}'.format(string, width = length) + return '{:^{width}}'.format(string, width=length) + def table_format_column(column, length): """ @@ -60,6 +88,7 @@ def table_format_column(column, length): """ return [table_fix_string_length(x, length) for x in column] + def table_transpose(table): """ Transpose a list of rows in a list of columns and viceversa @@ -69,7 +98,8 @@ def table_transpose(table): """ return list(zip(*table)) -def table_format(table, separator = "|", margin_size = 1): + +def table_format(table, separator="|", margin_size=1): """ Format a table of values :param table: table of values @@ -84,6 +114,7 @@ def table_format(table, separator = "|", margin_size = 1): # transpose the list of columns in list of rows and concatenate the values to obtain rows using the separator return [separator.join(row) for row in table_transpose(formatted_columns)] + def table_print_out_table(write_function, table): """ Calls the write function for each row in the new formatted table @@ -97,6 +128,7 @@ def table_print_out_table(write_function, table): except Exception as e: logger.error("Error formatting table: %s", e) + # ---------------------------------UTILITIES def issue_rspctl_command(cmd): """ @@ -109,7 +141,8 @@ def issue_rspctl_command(cmd): cmd = ["rspctl"] + cmd try: - proc = subprocess.Popen(cmd, stdout = subprocess.PIPE, stderr = subprocess.PIPE) + logging.debug('executing command: %s', cmd) + proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) out, err = proc.communicate() if proc.returncode == 0: @@ -122,13 +155,15 @@ def issue_rspctl_command(cmd): except OSError as e: raise Exception("Error executing " + " ".join(cmd) + ":" + e.strerror) + def list_mode(l): """ Return the most frequent element in the list :param l: input list :return: the most frequent element """ - return max(set(l), key = l.count) + return max(set(l), key=l.count) + # ----------------------------------COMMANDS # -------Clock @@ -152,6 +187,7 @@ def parse_clock_output(out, err): "STDOUT: %s\n" % out + "STDERR: %s\n" % err) + def query_clock(): """ Execute the command rspctl --clock and and parses the result @@ -161,19 +197,20 @@ def query_clock(): out, err = issue_rspctl_command(['--clock']) return parse_clock_output(out, err) + class RCUBoard: """ This class describes the properties of a RCUBoard """ - def __init__(self, - identifier = -1, - status = None, - mode = None, - delay = None, - attenuation = None, - sub_bands = None, - xcsub_bands = None): + def __init__(self, + identifier=-1, + status=None, + mode=None, + delay=None, + attenuation=None, + sub_bands=None, + xcsub_bands=None): self.id = identifier self.status = status self.mode = mode @@ -195,6 +232,7 @@ class RCUBoard: def __getitem__(self, item): return getattr(self, item) + # -------RCU mode def parse_rcu_output(out, err): """ @@ -211,21 +249,21 @@ def parse_rcu_output(out, err): :rtype: dict """ rcu_values = out[1:] - rcu_by_id = {} # list of RCUs listed by ID + rcu_by_id = {} # list of RCUs listed by ID for rcu_value in rcu_values: - match = re.search("RCU\[\s*(?P<RCU_id>\d+)\].control=" + # parsing id - "\d+x\w+\s=>\s*(?P<status>\w+)," + # parsing status - "\smode:(?P<mode>\-?\d)," + # parsing mode - "\sdelay=(?P<delay>\d+)," + # parsing delay - "\satt=(?P<attenuation>\d+)", rcu_value) # parsing attenuation + match = re.search("RCU\[\s*(?P<RCU_id>\d+)\].control=" + # parsing id + "\d+x\w+\s=>\s*(?P<status>\w+)," + # parsing status + "\smode:(?P<mode>-?\d)," + # parsing mode + "\sdelay=(?P<delay>\d+)," + # parsing delay + "\satt=(?P<attenuation>\d+)", rcu_value) # parsing attenuation if match: rcu_id = int(match.group('RCU_id')) - rcu_board = RCUBoard(identifier = rcu_id, - status = match.group('status'), - mode = match.group('mode'), - delay = match.group('delay'), - attenuation = match.group('attenuation') + rcu_board = RCUBoard(identifier=rcu_id, + status=match.group('status'), + mode=match.group('mode'), + delay=match.group('delay'), + attenuation=match.group('attenuation') ) rcu_by_id[rcu_id] = rcu_board @@ -235,6 +273,7 @@ def parse_rcu_output(out, err): "STDERR: %s\n" % err) return rcu_by_id + def query_rcu_mode(): """ Execute the command rspctl --rcu and parses the result @@ -244,6 +283,7 @@ def query_rcu_mode(): out, err = issue_rspctl_command(['--rcu']) return parse_rcu_output(out, err) + # -------Subbands def parse_subbands_output(out, err): """ @@ -270,9 +310,9 @@ def parse_subbands_output(out, err): i_row = 0 while i_row < len(rcu_values): value = rcu_values[i_row] - match = re.search("RCU\[\s*(?P<RCU_id>\d+)\]" + # parsing RCU id - ".subbands=\(\d+,(?P<n_rows>\d)\)\s+x\s+\(0," + # parsing the number of rows - "(?P<n_elements>\d+)\)\s*", # parsing the number of elements + match = re.search("RCU\[\s*(?P<RCU_id>\d+)\]" + # parsing RCU id + ".subbands=\(\d+,(?P<n_rows>\d)\)\s+x\s+\(0," + # parsing the number of rows + "(?P<n_elements>\d+)\)\s*", # parsing the number of elements value) if match: rcu_id = int(match.group('RCU_id')) @@ -287,15 +327,17 @@ def parse_subbands_output(out, err): sub_band_list = [] for i in range(n_rows): # Parsing the string [ 143 145 ... or ... 122 123] into a list of integers - row = list(map(int, [_f for _f in rcu_values[i_row + i + 1].strip().lstrip('[').rstrip(']').split(' ') if _f])) + row = list( + map(int, [_f for _f in rcu_values[i_row + i + 1].strip().lstrip('[').rstrip(']').split(' ') if _f])) sub_band_list.append(row) - i_row = i_row + n_rows + 1 # ADVANCE + i_row = i_row + n_rows + 1 # ADVANCE rcu_by_id[rcu_id] = sub_band_list return rcu_by_id + def query_sub_bands_mode(): """ Execute the command rspctl --subbands and parses the result @@ -305,6 +347,7 @@ def query_sub_bands_mode(): out, err = issue_rspctl_command(['--subbands']) return parse_subbands_output(out, err) + # -------XCSub bands def parse_xcsub_bands_output(out, err): """ @@ -342,7 +385,7 @@ def parse_xcsub_bands_output(out, err): :return: a dict indexed by the rcu board id containing the list of xcsub bands used :rtype: dict """ - rcu_values= out[1:] + rcu_values = out[1:] rcu_by_id = {} i_row = 0 @@ -362,10 +405,11 @@ def parse_xcsub_bands_output(out, err): xcsub_bands_list = [] for i in range(n_rows): # Parsing the string [ 143 145 ... or ... 122 123] into a list of integers - row = list(map(int, [_f for _f in rcu_values[i_row + i + 1].strip().lstrip('[').rstrip(']').split(' ') if _f])) + row = list( + map(int, [_f for _f in rcu_values[i_row + i + 1].strip().lstrip('[').rstrip(']').split(' ') if _f])) xcsub_bands_list.append(row) - i_row = i_row + n_rows + 1 # ADVANCE + i_row = i_row + n_rows + 1 # ADVANCE # concatenates the two rows -> computes the max xcsub_band and returns the value # [NOTE max accepts only a couple of values] val = reduce(lambda x, a: max(x, a), reduce(lambda x, a: x + a, xcsub_bands_list)) @@ -377,6 +421,7 @@ def parse_xcsub_bands_output(out, err): rcu_by_id[rcu_id] = val return rcu_by_id + def query_xcsub_bands_mode(): """ Execute the command rspctl --subbands and parses the result @@ -386,6 +431,7 @@ def query_xcsub_bands_mode(): out, err = issue_rspctl_command(['--xcsubband']) return parse_xcsub_bands_output(out, err) + # -------Spectral inversion def parse_spinv_output(out, err): """ @@ -450,6 +496,7 @@ def parse_spinv_output(out, err): return rcu_by_id + def query_spinv_mode(): """ Execute the command rspctl --spinv and parses the result @@ -459,6 +506,7 @@ def query_spinv_mode(): out, err = issue_rspctl_command(['--specinv']) return parse_spinv_output(out, err) + def execute_xcstatistics_mode(parameters): """ Execute the command rspclt --xcstatistics from a dict of parameters @@ -481,11 +529,12 @@ def execute_xcstatistics_mode(parameters): cmd_list.append('--integration=%d' % parameters['integration']) if 'directory' in parameters: cmd_list.append('--directory=%s' % parameters['directory']) - if 'select'in parameters: + if 'select' in parameters: cmd_list.append('--select=%s' % parameters['select']) issue_rspctl_command(cmd_list) + # ----------------------------------Merging information def query_status(): @@ -542,6 +591,7 @@ def query_status(): return res + def dump_info_file(path, res): """ Dump the information collected in json format into the directory specified in path @@ -553,7 +603,8 @@ def dump_info_file(path, res): file_path = os.path.join(path, "infos") with open(file_path, 'w') as fout: - fout.write(json.dumps(res, indent = 4, separators = (',', ': '))) + fout.write(json.dumps(res, indent=4, separators=(',', ': '))) + def query_xcstatistics(options): """ @@ -576,7 +627,7 @@ def query_xcstatistics(options): filename = "_mode_%s_xst_sb%0.3d.dat" % (mode, subband) - temporary_output_directory = tempfile.mkdtemp(prefix = "rspctlprobe_tmp") + temporary_output_directory = tempfile.mkdtemp(prefix="rspctlprobe_tmp") options['directory'] = temporary_output_directory integration = options['integration'] @@ -600,7 +651,7 @@ def query_xcstatistics(options): rcus = res["rcus"] header = ["RCUID", "delay", "attenuation", "mode", "status", "xcsub_bands"] - ids = [[header[0]] + list(map(str, list(rcus.keys())))] # Create the id column of the file + ids = [[header[0]] + list(map(str, list(rcus.keys())))] # Create the id column of the file table = [[key] + [str(rcus[i][key]) for i in rcus] for key in header[1:]] table = ids + table @@ -618,6 +669,7 @@ def query_xcstatistics(options): return res + def query_most_common_mode(): """ Return the most frequent mode that the RCUs have @@ -627,9 +679,10 @@ def query_most_common_mode(): rcus_mode = [rcus_mode[rcu] for rcu in rcus_mode] return int(list_mode([x['mode'] for x in rcus_mode])) + def set_mode(mode): """ - Set the mode on all the rsp boards + Set the mode on all the rcu boards :param mode: the mode to be set :type mode: int @@ -645,11 +698,128 @@ def set_mode(mode): for i in range(10): time.sleep(3) outmode = query_most_common_mode() - logger.info('current rsp mode is {}'.format(outmode)) + logger.info('current rcu mode is {}'.format(outmode)) if mode == outmode: logger.info('mode changed correctly to {}'.format(outmode)) return True - raise Exception('Cannot change rsp mode') + raise Exception('Cannot change rcu mode') + + +def _single_element_hba_delay_string(element_id): + """ + Generate the HBA delay string to select a single element id + :param element_id: the element id to be selected + :return: the element id string + >>> _single_element_hba_delay_string(0) + '128,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2' + >>> _single_element_hba_delay_string(15) + '2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,128' + >>> _single_element_hba_delay_string(8) + '2,2,2,2,2,2,2,2,128,2,2,2,2,2,2,2' + >>> _single_element_hba_delay_string(-1) + Traceback (most recent call last): + ... + ValueError: the element id -1 out of range [0, 15] + >>> _single_element_hba_delay_string(18) + Traceback (most recent call last): + ... + ValueError: the element id 18 out of range [0, 15] + """ + if element_id < 0 or element_id > _NUM_HBA_ELEMENTS: + raise ValueError('the element id %d out of range [0, 15]' % element_id) + + return ",".join([_ELEMENT_OFF_CODE for _ in range(element_id)] + + [_ELEMENT_ON_ZERO_DELAY] + + [_ELEMENT_OFF_CODE for _ in range(element_id + 1, _NUM_HBA_ELEMENTS)]) + + +def _tile_to_rcu_ids(tile_id): + """ + RCU ids for a given tile id (both polarizations) + :param tile_id: the id of the tile + :return: the list of the rcu ids corresponding to the tile_id + + >>> _tile_to_rcu_ids(1) + [2,3] + >>> _tile_to_rcu_ids(4) + [8,9] + """ + return [2 * tile_id, 2 * tile_id + 1] + + +def _rcu_selection_string(element_id, station_type): + """ + Generate the rcu selection string to select a series of rcu to be set for the HBA single element mode + :param element_id: the element id to be selected + :return: the element id string + >>> _rcu_selection_string(0, 'remote') + '0,1' + >>> _rcu_selection_string(8, 'remote') + '14,15,32,33,60,61' + >>> _rcu_selection_string(15, 'remote') + '42,43,58,59,88,89,94,95' + >>> _rcu_selection_string(8, 'international') + '8,9,34,35,114,115,116,117' + >>> _rcu_selection_string(9, 'core') + '42,43,90,91' + >>> _rcu_selection_string(8, 'core') + '' + >>> _rcu_selection_string(-1, 'core') + Traceback (most recent call last): + ... + ValueError: the element id -1 out of range [0, 15] + >>> _rcu_selection_string(18, 'core') + Traceback (most recent call last): + ... + ValueError: the element id 18 out of range [0, 15] + """ + if element_id < 0 or element_id > _NUM_HBA_ELEMENTS: + raise ValueError('the element id %d out of range [0, 15]' % element_id) + + num_tiles = _NUM_TILES[station_type] + elements_list = _OptimumElements[station_type] + rcu_to_be_selected = [] + for tile in range(num_tiles): + if elements_list[tile] == element_id: + # convert tile number to RCU number + rcu_to_be_selected += _tile_to_rcu_ids(tile) + + rcu_ctrl_string = ','.join(map(str, rcu_to_be_selected)) + return rcu_ctrl_string + + +def detect_station_type(): + hostname = socket.gethostname() + if hostname.startswith('RS'): + station_type = 'remote' + elif hostname.startswith('CS'): + station_type = 'core' + else: + station_type = 'international' + logger.info('Station type detected is %s', station_type) + return station_type + + +def set_single_hba_element(station_type): + """ + Activate a single element in the HBA tile + + :return: None + """ + if station_type not in _NUM_TILES: + raise ValueError('the station type "%s" not existent' % station_type) + + logger.info('selecting a single element only') + for element_id in range(_NUM_HBA_ELEMENTS): + rcu_to_select = _rcu_selection_string(element_id, station_type) + if rcu_to_select == '': + continue + delay_to_set = _single_element_hba_delay_string(element_id) + + issue_rspctl_command(['--hbadelay={}'.format(delay_to_set), + '--select={}'.format(rcu_to_select)]) + time.sleep(_SLEEP_TIME_SINGLE_ELEMENT_SELECTION) + def set_xcsubband(subband): """ @@ -659,7 +829,7 @@ def set_xcsubband(subband): :type subband: string """ logger.info('switching rcu xcsubband to %d', subband) - issue_rspctl_command(["--xcsubband={}".format(subband)]) + issue_rspctl_command(['--xcsubband={}'.format(subband)]) logger.debug('xcsubband change command issued') for i in range(10): time.sleep(1) @@ -670,7 +840,8 @@ def set_xcsubband(subband): return True raise Exception('Cannot change rsp xcsubband to {}'.format(subband)) -def produce_xcstatistics(integration_time = 1, duration = 1, add_options = None, output_directory = "./"): + +def produce_xcstatistics(integration_time=1, duration=1, add_options=None, output_directory="./"): """ Execute the command to compute the xcstatistics with a given integration and duration. It is also possible to specify an output directory and additional options. @@ -690,13 +861,15 @@ def produce_xcstatistics(integration_time = 1, duration = 1, add_options = None, res = query_xcstatistics(add_options) return res + def batch_produce_xcstatistics(integration_time, duration, - wait_time = None, - xcsub_bands = None, - mode = None, - add_options = None, - output_directory = "./"): + wait_time=None, + xcsub_bands=None, + mode=None, + add_options=None, + output_directory="./", + select_single_element=False): """ Produces the xcstatistics for a list of integration_times durations and wait_times on the given set of xcsubband storing everything in the output directory. @@ -719,6 +892,9 @@ def batch_produce_xcstatistics(integration_time, if mode != -2: set_mode(mode) + if select_single_element: + set_single_hba_element(station_type=STATION_TYPE) + for ind, (i, d, w) in enumerate(zip(integration_time, duration, wait_time)): if not xcsub_bands: produce_xcstatistics(i, d, add_options, output_directory) @@ -729,51 +905,79 @@ def batch_produce_xcstatistics(integration_time, time.sleep(w) + # ----------------------------------MAIN CODE LOGIC -def setup_logging(): +def setup_logging(log_level): """ Setup the logging system """ logging.basicConfig( - format = '%(asctime)s - %(name)s: %(message)s', - datefmt = "%m/%d/%Y %I:%M:%S %p", - level = logging.DEBUG) - - + format='%(asctime)s - %(name)s: %(message)s', + datefmt="%m/%d/%Y %I:%M:%S %p", + level=log_level) + + __MODE_NOT_SET_DEFAULT = -2 -def init(): +def init(log_level=logging.DEBUG): """ Init phase of the program """ - setup_logging() + global STATION_TYPE + setup_logging(log_level=log_level) + STATION_TYPE = detect_station_type() + def setup_command_argument_parser(): parser = argparse.ArgumentParser( - formatter_class=argparse.RawDescriptionHelpFormatter, - description = "es: rspctlprobe.py --mode 3 --xcstatistics --xcsubband 100:400:50 --integration 5 --duration 5 --wait 3600 --loops 24 --directory /localhome/data/") - - parser.add_argument('--xcstatistics', action = 'store_true') - parser.add_argument('--integration', type = int, default = [1], nargs = '+') - parser.add_argument('--duration', type = int, default = [1], nargs = '+') - parser.add_argument('--xcangle', default = 'False') - parser.add_argument('--directory', default = os.getcwd()) - parser.add_argument('--wait', type = int, default = [0], nargs = '+') - parser.add_argument('--xcsubband', type = str, default = "") - parser.add_argument('--loops', type = int, default = 1) - parser.add_argument('--mode', type = int, default = __MODE_NOT_SET_DEFAULT) + formatter_class=argparse.RawDescriptionHelpFormatter, + description="Example complete tile: rspctlprobe.py --mode 5 --xcstatistics --xcsubband 100:400:25 --integration 5 --duration 5 --wait 3600 --loops 24 --directory /localhome/data/ \n\n" + "Example single element: rspctlprobe.py --mode 5 --single --xcstatistics --xcsubband 100:400:25 --integration 5 --duration 5 --wait 3600 --loops 24 --directory /localhome/data/") + + parser.add_argument('--xcstatistics', action='store_true') + parser.add_argument('--integration', type=int, default=[1], nargs='+') + parser.add_argument('--duration', type=int, default=[1], nargs='+') + parser.add_argument('--xcangle', default='False') + parser.add_argument('--directory', default=os.getcwd()) + parser.add_argument('--wait', type=int, default=[0], nargs='+') + parser.add_argument('--xcsubband', type=str, default="") + parser.add_argument('--loops', type=int, default=1) + parser.add_argument('--mode', type=int, default=__MODE_NOT_SET_DEFAULT) + parser.add_argument('--single', action='store_true', help='select a single HBA element') return parser + +def check_input_validity(arguments): + if arguments.single: + current_mode = query_most_common_mode() + if current_mode not in _HBA_MODES and arguments.mode == __MODE_NOT_SET_DEFAULT: + logger.error('single selection cannot be done for not HBA modes with code (5, 6, 7): current mode is %d', + current_mode) + raise SystemExit('single selection cannot be done for not HBA modes with code (5, 6, 7)') + + +def xcsubband_specification_to_list(xcsubbands_string): + if ":" in xcsubbands_string: + start, end, step = map(int, xcsubbands_string.split(":")) + xcsub_bands = [int(i) for i in range(start, end + step, step)] + elif "," in xcsubbands_string: + xcsub_bands = [int(i) for i in xcsubbands_string.split(",")] + else: + xcsub_bands = [int(xcsubbands_string)] + return xcsub_bands + + def parse_and_execute_command_arguments(): """ Parses the command line arguments and execute the procedure linked :return: :rtype: """ + global STATION_TYPE parser = setup_command_argument_parser() program_arguments = parser.parse_args() - + check_input_validity(program_arguments) if program_arguments.xcstatistics: options = {} if program_arguments.xcangle: @@ -781,34 +985,31 @@ def parse_and_execute_command_arguments(): try: if program_arguments.xcsubband: - if ":" in program_arguments.xcsubband: - start, end, step = map(int, program_arguments.xcsubband.split(":")) - xcsub_bands = [int(i) for i in range(start, end+step, step)] - elif "," in program_arguments.xcsubband: - xcsub_bands = [int(i) for i in program_arguments.xcsubband.split(",")] - else: - xcsub_bands = [int(program_arguments.xcsubband)] + xcsub_bands = xcsubband_specification_to_list(program_arguments.xcsubband) for i in range(program_arguments.loops): batch_produce_xcstatistics(program_arguments.integration, program_arguments.duration, - wait_time = program_arguments.wait, - xcsub_bands = xcsub_bands, - mode = program_arguments.mode, - add_options = options, - output_directory = program_arguments.directory) + wait_time=program_arguments.wait, + xcsub_bands=xcsub_bands, + mode=program_arguments.mode, + add_options=options, + output_directory=program_arguments.directory, + select_single_element=program_arguments.single) else: for i in range(program_arguments.loops): batch_produce_xcstatistics(program_arguments.integration, program_arguments.duration, - wait_time = program_arguments.wait, - mode = program_arguments.mode, - add_options = options, - output_directory = program_arguments.directory) + wait_time=program_arguments.wait, + mode=program_arguments.mode, + add_options=options, + output_directory=program_arguments.directory, + select_single_element=program_arguments.single) + if program_arguments.mode != __MODE_NOT_SET_DEFAULT: # SWITCH BACK TO MODE 0 AT THE END IF MODE SWITCH WAS SET - set_mode(0) + set_mode(0) except Exception as e: logger.error('error executing rspctl : %s', e) logger.error('traceback \n%s', traceback.format_exc()) @@ -816,11 +1017,13 @@ def parse_and_execute_command_arguments(): else: parser.error('please specify a task') + def main(): - init() - logging.basicConfig(format = '%(asctime)s ' + socket.gethostname() + ' %(levelname)s %(message)s', - level = logging.INFO) + init(log_level=logging.INFO) + logging.basicConfig(format='%(asctime)s ' + socket.gethostname() + ' %(levelname)s %(message)s', + level=logging.INFO) parse_and_execute_command_arguments() + if __name__ == '__main__': main()