def __init__( # pylint: disable=too-many-arguments self, adb, battery_file=None, memory_file=None, cpu_file=None, append_file=False, num_samples=0, collection_time_secs=0, sample_interval_ms=0): """Initialize AdbControl object.""" self.adb = adb output_files = [battery_file, memory_file, cpu_file] if not any(output_files): raise ValueError("There are no collection sample files selected.") self.battery_file = battery_file self.memory_file = memory_file self.cpu_file = cpu_file # The AdbResourceMonitor will always append results to the specified file. # If append_file is specified in this init, then if there's an existing file # we do not overwrite it. for output_file in output_files: if not append_file: fileops.create_empty(output_file) self.append_file = append_file # collection_time_secs overrides num_samples self.num_samples = num_samples if collection_time_secs == 0 else 0 self.collection_time_secs = collection_time_secs self.sample_interval_ms = sample_interval_ms self.should_stop = threading.Event() self.should_stop.clear() self.sample_based_threads = [] self.all_threads = []
def __init__( # pylint: disable=too-many-arguments self, adb, logger=LOGGER, battery_file=None, memory_file=None, cpu_file=None, append_file=False, num_samples=DEFAULT_NUM_SAMPLES, collection_time_secs=None, sample_interval_ms=DEFAULT_SAMPLE_INTERVAL_MS): """Initialize AdbControl object.""" self.adb = adb self.logger = logger output_files = [ fn for fn in [battery_file, memory_file, cpu_file] if fn ] if not output_files: raise ValueError("There are no collection sample files selected.") self.battery_file = battery_file self.memory_file = memory_file self.cpu_file = cpu_file # The AdbResourceMonitor will always append results to the specified file. # If append_file is specified in this init, then if there's an existing file # we do not overwrite it. for output_file in output_files: if not append_file: fileops.create_empty(output_file) # collection_time_secs overrides num_samples self.num_samples = num_samples if not collection_time_secs else 0 self.collection_time_secs = collection_time_secs self.sample_interval_ms = sample_interval_ms self._should_stop = threading.Event() self._should_stop.clear() self._sample_based_threads = [] self._all_threads = []