Collector API provide a consistent way of collecting arbitrary data from
a target. Data is collected via an instance of a class derived from
The following example shows how to use a collector to read the logcat output from an Android target.
# import and instantiate the Target and the collector # (note: this assumes exactly one android target connected # to the host machine). In : from devlib import AndroidTarget, LogcatCollector In : t = AndroidTarget() # Set up the collector on the Target. In : collector = LogcatCollector(t) # Configure the output file path for the collector to use. In : collector.set_output('adb_log.txt') # Reset the Collector to preform any required configuration or preparation. In : collector.reset() # Start Collecting In : collector.start() # Wait for some output to be generated In : sleep(10) # Stop Collecting In : collector.stop() # Retrieved the collected data In : output = collector.get_data() # Display the returned ``CollectorOutput`` Object. In : output Out: [<adb_log.txt (file)>] In  log_file = output # Get the path kind of the the returned CollectorOutputEntry. In : log_file.path_kind Out: 'file' # Get the path of the returned CollectorOutputEntry. In : log_file.path Out: 'adb_log.txt' # Find the full path to the log file. In : os.path.join(os.getcwd(), logfile) Out: '/tmp/adb_log.txt'
CollectorBaseis the the base class and API that should be implemented to allowing collecting various data from a traget e.g. traces, logs etc.
This will set up the collector on the target. Parameters this method takes are particular to subclasses (see documentation for specific collectors below). What actions are performed by this method are also collector-specific. Usually these will be things like installing executables, starting services, deploying assets, etc. Typically, this method needs to be invoked at most once per reboot of the target (unless
teardown()has been called), but see documentation for the collector you’re interested in.
This can be used to configure a collector for collection. This must be invoked before
start()is called to begin collection.
Starts collecting from the target.
Configure the output path for the particular collector. This will be either a directory or file path which will be used when storing the data. Please see the individual Collector documentation for more information.
The collected data will be return via the previously specified output_path. This method will return a
CollectorOutputobject which is a subclassed list object containing individual
CollectorOutputEntryobjects with details about the individual output entry.
This object is designed to allow for the output of a collector to be processed
generically. The object will behave as a regular string containing the path to
underlying output path and can be used directly in
The file path for the corresponding output item.
The type of output the is specified in the
pathattribute. Current valid kinds are:
CollectorOutputEntryobject with the desired file path and kind of file path specified.
This section lists collectors that are currently part of devlib.