def write_descriptor_ascii(self, metric, output_path): """Writes the ascii format of the protobuf descriptor to file. Args: metric: The metric to write. output_path: The output directory path to write the file to. """ filename = self._get_output_file(output_path, metric.name, self.ASCII_DESCRIPTOR_EXTENSION) dump_string_to_file(metric.get_descriptor_ascii(), filename)
def write_binary(self, metric, output_path): """Writes the binary format of the protobuf to file. Args: metric: The metric to write. output_path: The output directory path to write the file to. """ filename = self._get_output_file(output_path, metric.name, self.BINARY_EXTENSION) dump_string_to_file(metric.get_binary(), filename, mode='wb')
def collect_bluetooth_manager_metrics_logs(self, ads): """ Collect Bluetooth metrics logs, save an ascii log to disk and return both binary and ascii logs to caller :param ads: list of active Android devices :return: List of binary metrics logs, List of ascii metrics logs """ bluetooth_logs = [] bluetooth_logs_ascii = [] for ad in ads: serial = ad.serial out_name = "{}_{}".format(serial, "bluetooth_metrics.txt") bluetooth_log = get_bluetooth_metrics(ad) bluetooth_log_ascii = parse_proto_to_ascii(bluetooth_log) dump_string_to_file(bluetooth_log_ascii, os.path.join(ad.metrics_path, out_name)) bluetooth_logs.append(bluetooth_log) bluetooth_logs_ascii.append(bluetooth_log_ascii) return bluetooth_logs, bluetooth_logs_ascii