Index: dialin/utils/checks.py =================================================================== diff -u -ra2d44432a913537ca0627cd7dde7dcb1154f2156 -rf0487ded330dd831fede0982e53d40467fa33dde --- dialin/utils/checks.py (.../checks.py) (revision a2d44432a913537ca0627cd7dde7dcb1154f2156) +++ dialin/utils/checks.py (.../checks.py) (revision f0487ded330dd831fede0982e53d40467fa33dde) @@ -14,7 +14,7 @@ # ############################################################################ -def check_broadcast_interval_override_ms(ms:int): +def check_broadcast_interval_override_ms(ms: int): """ Checks whether a given broadcast interval override (in ms) is valid. Index: dialin/utils/conversions.py =================================================================== diff -u -ra1ee274cb5cab5f83deae1c39efef89ee81289df -rf0487ded330dd831fede0982e53d40467fa33dde --- dialin/utils/conversions.py (.../conversions.py) (revision a1ee274cb5cab5f83deae1c39efef89ee81289df) +++ dialin/utils/conversions.py (.../conversions.py) (revision f0487ded330dd831fede0982e53d40467fa33dde) @@ -87,4 +87,4 @@ """ if type(val) != int: raise ValueError("Expected integer but received {0} with type {1}".format(val, type(val))) - return [(val >> bit) & 1 for bit in range(num_bits - 1, -1, -1)] \ No newline at end of file + return [(val >> bit) & 1 for bit in range(num_bits - 1, -1, -1)] Index: dialin/utils/data_logger.py =================================================================== diff -u -r0d1e40ce50fa9b702ec281b6fc9c85e52a3e1490 -rf0487ded330dd831fede0982e53d40467fa33dde --- dialin/utils/data_logger.py (.../data_logger.py) (revision 0d1e40ce50fa9b702ec281b6fc9c85e52a3e1490) +++ dialin/utils/data_logger.py (.../data_logger.py) (revision f0487ded330dd831fede0982e53d40467fa33dde) @@ -37,7 +37,7 @@ logger: Logger = _FauxLogger()): """ Logs data to xlsx file - :param filepath: (str) the destination filepath + @param folder: (str) the destination filepath """ super().__init__() @@ -53,8 +53,8 @@ def logging_scheduler(self) -> None: """ Called on each timer event. Calls the data logger method - :param event: - :return: + + @return: None """ while True: self.do_data_logging() @@ -63,8 +63,8 @@ def add_data(self, data: Tuple): """ - :param data: (Tuple) the data to add to the queue - :return: None + @param data: (Tuple) the data to add to the queue + @return: None """ # ("module", "timestamp", "header", "value") if not os.path.exists(self.path_disable_logging): @@ -76,7 +76,7 @@ def do_data_logging(self) -> None: """ Called on teach timer event. Logs the data currently in deque - :return: None + @return: None """ i = 0 @@ -104,8 +104,8 @@ """ Called when the user wishes to export all captured logs to a xlsx file - :param output_path: (str) the destination output path - :return: None + @param output_path: (str) the destination output path + @return: None """ process = Process(target=self._do_export_to_xlsx, args=(output_path,)) process.start() @@ -114,8 +114,8 @@ """ Performs the actual export to xlsx - :param output_path: (str) the destination output path - :return: None + @param output_path: (str) the destination output path + @return: None """ Path(self.path_disable_logging).touch() @@ -149,7 +149,7 @@ def clear_logs(self): """ Called when the user clears the logs - :return: None + @return: None """ Path(self.path_disable_logging).touch() log_path = os.path.join(self.base_folder, "*Log") Index: dialin/utils/excel_ops.py =================================================================== diff -u -rbe687b87ec7dbbb312fc9dc67fd422119e43e64c -rf0487ded330dd831fede0982e53d40467fa33dde --- dialin/utils/excel_ops.py (.../excel_ops.py) (revision be687b87ec7dbbb312fc9dc67fd422119e43e64c) +++ dialin/utils/excel_ops.py (.../excel_ops.py) (revision f0487ded330dd831fede0982e53d40467fa33dde) @@ -87,7 +87,7 @@ active_sheet = workbook_obj[project] # Set the provided data into the specified row and column and set the bold, color and horizontal alignment active_sheet.cell(row=row, column=column).value = data - active_sheet.cell(row=row, column=column).font = Font(size=font, bold=bold, name=name) + active_sheet.cell(row=row, column=column).font = Font(size=font, bold=bold, name=name) # Wrapping text is not needed unless the length of the data is more than maximum column # length active_sheet[cell_name].alignment = Alignment(vertical='center', horizontal=horizontal, wrap_text=False) @@ -189,4 +189,4 @@ current_date = str(datetime.datetime.now().date()) # Create the save path by using the path, date and current code review excel count out of total number of them path = os.path.join(save_dir, current_date + '-' + str(record_name).upper() + '-Record.xlsx') - excel_workbook.save(filename=path) \ No newline at end of file + excel_workbook.save(filename=path) Index: dialin/utils/helpers.py =================================================================== diff -u -rebf0a72a1a1a52f3cfe20975de4857201275888c -rf0487ded330dd831fede0982e53d40467fa33dde --- dialin/utils/helpers.py (.../helpers.py) (revision ebf0a72a1a1a52f3cfe20975de4857201275888c) +++ dialin/utils/helpers.py (.../helpers.py) (revision f0487ded330dd831fede0982e53d40467fa33dde) @@ -187,6 +187,7 @@ @param log_path: (str) The full path to the output log file. @param level: (str) The logging level (e.g. INFO, WARN, DEBUG, ERROR, CRITICAL) @param enable_metadata: (bool) if True, include metadata, otherwise, log only the message + @param clear_before_write: (bool) if True, clear log file before write to it @return: (logging.Logger) The logger object """ Index: dialin/utils/nv_ops_utils.py =================================================================== diff -u -rc4776c1885f259b231532ef5ba7e904178cd0005 -rf0487ded330dd831fede0982e53d40467fa33dde --- dialin/utils/nv_ops_utils.py (.../nv_ops_utils.py) (revision c4776c1885f259b231532ef5ba7e904178cd0005) +++ dialin/utils/nv_ops_utils.py (.../nv_ops_utils.py) (revision f0487ded330dd831fede0982e53d40467fa33dde) @@ -150,8 +150,8 @@ col = 1 if isinstance(calibration_record[group], dict): - write_to_excel(self._excel_workbook, self._record_name, row, col, group, bold=True, - max_col_len=len(group)) + write_to_excel(self._excel_workbook, self._record_name, row, col, + group, bold=True, max_col_len=len(group)) for hardware in calibration_record[group].keys(): list_of_keys = list(calibration_record[group].keys()) @@ -174,8 +174,8 @@ write_to_excel(self._excel_workbook, self._record_name, row, col, spec_value) if list_of_keys.index(hardware) == len(list_of_keys) - 1: - merge_cells(self._excel_workbook, self._record_name, start_row, start_col, - row, start_col) + merge_cells(self._excel_workbook, self._record_name, + start_row, start_col, row, start_col) row += 1 row += 1 @@ -210,22 +210,23 @@ col = 4 for spec in calibration_record[group][hardware]: cell_value = get_cell_value(self._excel_workbook, self._record_name, row, col) - # Check if the cell value is not none. If it is none, it cannot be converted to a - # number like float or integer + # Check if the cell value is not none. If it is none, + # it cannot be converted to a number like float or integer is_cell_value_valid = True if cell_value is not None else False if 'crc' not in spec and 'time' not in spec and is_cell_value_valid: - temp_buffer.append(struct.pack(calibration_record[group][hardware][spec][0], cell_value)) + temp_buffer.append( + struct.pack(calibration_record[group][hardware][spec][0], cell_value)) if calibration_record[group][hardware][spec][1] != cell_value: is_value_different = True calibration_record[group][hardware][spec][1] = cell_value if is_value_different and 'time' in spec: epoch_time = self.get_current_time_in_epoch() calibration_record[group][hardware][spec][1] = epoch_time - temp_buffer.append(struct.pack(calibration_record[group][hardware][spec][0], epoch_time)) + temp_buffer.append( + struct.pack(calibration_record[group][hardware][spec][0], epoch_time)) date_time = self.get_current_date_time(epoch_time) - write_to_excel(self._excel_workbook, self._record_name, row, col, - date_time) + write_to_excel(self._excel_workbook, self._record_name, row, col, date_time) elif 'time' in spec and isinstance(cell_value, str) and is_cell_value_valid: epoch_time = self.get_date_time_in_epoch(cell_value) calibration_record[group][hardware][spec][1] = epoch_time @@ -237,16 +238,14 @@ # Clear the temp buffer for the next round of data is_value_different = False calibration_record[group][hardware][spec][1] = crc_value - write_to_excel(self._excel_workbook, self._record_name, row, col, - crc_value) + write_to_excel(self._excel_workbook, self._record_name, row, col, crc_value) col += 2 else: col = 3 - for spec in calibration_record[group][hardware]: - cell_value = get_cell_value(self._excel_workbook, self._record_name, row, - col) - # Check if the cell value is not none. If it is none, it cannot be converted to a number - # like float or integer + for _ in calibration_record[group][hardware]: + cell_value = get_cell_value(self._excel_workbook, self._record_name, row, col) + # Check if the cell value is not none. If it is none, + # it cannot be converted to a number like float or integer is_cell_value_valid = True if cell_value is not None else False if is_cell_value_valid: calibration_record[group][hardware][1] = cell_value @@ -466,8 +465,8 @@ @param group: (str) record group (i.e CRC, padding) @param key: (str) key of the calibration record dictionary @param read_start_index: (int) index to read the next set of byte(s) from fw raw records - @param inner_key: (str) the key to an inner dictionary that is the value of the provided key (i.e. pressure: {ppi : - [0,1]}) + @param inner_key: (str) the key to an inner dictionary that is the value of the provided key + (i.e. pressure: {ppi : [0,1]}) @return: calibration record dictionary that is updated and read start index as a tuple """ @@ -485,9 +484,10 @@ value_bytes = self.get_data_type_bytes(data_type) if data_type == ' self._MIN_PAYLOAD_BYTES_SPACE: @@ -618,9 +620,9 @@ # Add the number of total messages to each data packet. This was delayed # until now since it was not known how many message will it take to pack all the data. packet[1] = struct.pack(' 0: + while length > 0: # Make the sure variables are 16-bit integers left = (crc << 8) & 0x0000FFFF right = (crc >> 8) & 0x0000FFFF crc = left ^ cls.CRC_16_TABLE[data[i] ^ (right & 0x00FF)] - l -= 1 + length -= 1 i += 1 return crc