API Reference

Piotr API

This module allows to interact with/instrument Piotr virtual devices in a pythonic way. It exposes a main class, Piotr, that is able to interact with running instances and to automate things.

class piotr.api.Device(deviceName)[source]

API Device object.

get_sysroot()[source]

Return this device root fs path

run(alias=None, background=False)[source]

Run emulated device.

exception piotr.api.DeviceNotFound[source]
class piotr.api.Instance(guest, device)[source]

This class represents a Piotr running device instance and allows to interact with it, execute commands into the emulated host and target (if Qemu agent is supported by the device), enumerate and manipulate process.

Parameters
  • guest (piotr.qemu.QemuPlatform) – Qemu guest

  • device (str) – Name of parent device, as referenced in Piotr devices list

debug(pid, ip='0.0.0.0', port=4444, gdb_executable='gdb-multiarch')[source]

Runs a gdb server and attaches it to a process.

exec_host(command, wait=True)[source]

Execute a command in host.

exec_target(command, wait=True)[source]

Execute a command in guest.

Parameters
  • command (str) – command to execute

  • return_output (bool) – wait for the process to end and return output

Returns

command output or executable PID

get_sysroot()[source]

Return this instance root path

kill(pid, sig=9)[source]

Kill a processus.

pid(process_name)[source]

Find process ID from process name :param process_name: process name :type process_name: str :return: PID of the process, None on error

ps()[source]

Run ps on this target and return a list of processes.

Returns

list of processes

stop()[source]

Stop instance.

target_start()[source]

Run target in host.

class piotr.api.Piotr[source]

Piotr main API.

static devices()[source]

Enumerate registered devices.

static instance(inst_name)[source]

Find an existing instance by name

static instances()[source]

Enumerate running instances.

class piotr.api.Process(pid=- 1, user=None, path=None)[source]

This class holds information about a process on the emulated system.