Documentation¶
The PyMemuc
module¶
a wrapper for memuc.exe as a library to control virual machines
- class PyMemuc(memuc_path: str | None = None, debug: bool = False)[source]¶
Bases:
object
A class to interact with the memuc.exe command line tool to control virtual machines.
- Parameters:
- change_gps_vm(latitude: float, longitude: float, vm_index: int | None = None, vm_name: str | None = None) Literal[True] ¶
Change the GPS location on a VM, must specify either a vm index or a vm name
- Parameters:
- Raises:
PyMemucIndexError – an error if neither a vm index or a vm name is specified
- Returns:
True if the vm GPS change was successful
- Return type:
Literal[True]
- connect_internet_vm(vm_index: int | None = None, vm_name: str | None = None) Literal[True] ¶
Connect the internet on a VM, must specify either a vm index or a vm name
- create_app_shortcut_vm(package_name: str, vm_index: int | None = None, vm_name: str | None = None) Tuple[int, str] ¶
Create an app shortcut on a VM, must specify either a vm index or a vm name
- Parameters:
- Raises:
PyMemucIndexError – an error if neither a vm index or a vm name is specified
PyMemucTimeoutExpired – an error if the command times out
- Returns:
the return code and the output of the command.
- Return type:
- disconnect_internet_vm(vm_index: int | None = None, vm_name: str | None = None) Literal[True] ¶
Disconnect the internet on a VM, must specify either a vm index or a vm name
- execute_command_vm(command: str, vm_index: int | None = None, vm_name: str | None = None) Tuple[int, str] ¶
Execute a command on a VM, must specify either a vm index or a vm name
- Parameters:
- Raises:
PyMemucIndexError – an error if neither a vm index or a vm name is specified
- Returns:
the return code and the output of the command.
- Return type:
- get_adb_connection(vm_index: int | None = None, vm_name: str | None = None, timeout: float | None = None) Tuple[str | None, int | None] ¶
Get the adb connection information for a VM
- Parameters:
- Raises:
PyMemucIndexError – an error if neither a vm index or a vm name is specified
PyMemucTimeoutExpired – an error if the command times out
PyMemucError – an error if the command fails
- Returns:
the ip and port of the adb connection as a tuple
- Return type:
- get_app_info_list_vm(vm_index: int | None = None, vm_name: str | None = None, timeout: float = 10) list[str] ¶
Get the list of apps installed on a VM, must specify either a vm index or a vm name
- Parameters:
- Raises:
PyMemucIndexError – an error if neither a vm index or a vm name is specified
PyMemucError – an error if the command failed
- Returns:
the list of packages installed on the VM
- Return type:
- get_public_ip_vm(vm_index: int | None = None, vm_name: str | None = None) Tuple[int, str] ¶
Get the public IP of a VM, must specify either a vm index or a vm name
- input_text_vm(text: str, vm_index: int | None = None, vm_name: str | None = None) Literal[True] ¶
Input text on a VM, must specify either a vm index or a vm name
- Parameters:
- Raises:
PyMemucIndexError – an error if neither a vm index or a vm name is specified
- Returns:
True if the vm text input was successful
- Return type:
Literal[True]
- install_apk_vm(apk_path: str, vm_index: int | None = None, vm_name: str | None = None, create_shortcut: bool = False) Literal[True] ¶
Install an APK on a VM, must specify either a vm index or a vm name
- Parameters:
- Raises:
PyMemucIndexError – an error if neither a vm index or a vm name is specified
- Returns:
True if the vm apk installation was successful
- Return type:
Literal[True]
- rotate_window_vm(vm_index: int | None = None, vm_name: str | None = None) Literal[True] ¶
Rotate the window on a VM, must specify either a vm index or a vm name
- Parameters:
vm_index (int, optional) – VM index. Defaults to None.
- Raises:
PyMemucIndexError – an error if neither a vm index or a vm name is specified
- Returns:
True if the vm window rotation was successful
- Return type:
Literal[True]
- send_adb_command_vm(command: str | list[str], vm_index: int | None = None, vm_name: str | None = None, timeout: float | None = None) str ¶
Send an ADB command to a VM, must specify either a vm index or a vm name
- Parameters:
- Raises:
PyMemucIndexError – an error if neither a vm index or a vm name is specified
PyMemucTimeoutExpired – an error if the command times out
- Returns:
the return code and the output of the command.
- Return type:
- set_accelerometer_vm(value: tuple[float, float, float], vm_index: int | None = None, vm_name: str | None = None) Tuple[int, str] ¶
Set the accelerometer on a VM, must specify either a vm index or a vm name
- Parameters:
- Raises:
PyMemucIndexError – an error if neither a vm index or a vm name is specified
- Returns:
the return code and the output of the command.
- Return type:
- start_app_vm(package_name: str, vm_index: int | None = None, vm_name: str | None = None, timeout: float | None = None) Literal[True] ¶
Start an app on a VM, must specify either a vm index or a vm name
- Parameters:
package_name (str) – Package name of the APK, e.g.
com.android.chrome
. This can be found usingget_app_info_list_vm()
, excluding the readable name and version suffix.vm_index (int, optional) – VM index. Defaults to None.
vm_name (str, optional) – VM name. Defaults to None.
timeout (float, optional) – Timeout in seconds. Defaults to None.
- Raises:
PyMemucIndexError – an error if neither a vm index or a vm name is specified
- Returns:
True if the vm app start was successful
- Return type:
Literal[True]
- stop_app_vm(package_name: str, vm_index: int | None = None, vm_name: str | None = None) Literal[True] ¶
Stop an app on a VM, must specify either a vm index or a vm name
- Parameters:
- Raises:
PyMemucIndexError – an error if neither a vm index or a vm name is specified
- Returns:
True if the vm app stop was successful
- Return type:
Literal[True]
- trigger_keystroke_vm(key: Literal['back', 'home', 'menu', 'volumeup', 'volumedown'], vm_index: int | None = None, vm_name: str | None = None) Literal[True] ¶
Trigger a keystroke on a VM, must specify either a vm index or a vm name
- Parameters:
- Raises:
PyMemucIndexError – an error if neither a vm index or a vm name is specified
- Returns:
True if the vm keystroke trigger was successful
- Return type:
Literal[True]
- trigger_shake_vm(vm_index: int | None = None, vm_name: str | None = None) Literal[True] ¶
Trigger a shake on a VM, must specify either a vm index or a vm name
- uninstall_apk_vm(package_name: str, vm_index: int | None = None, vm_name: str | None = None) Literal[True] ¶
Uninstall an APK on a VM, must specify either a vm index or a vm name
- Parameters:
- Raises:
PyMemucIndexError – an error if neither a vm index or a vm name is specified
- Returns:
True if the vm apk uninstallation was successful
- Return type:
Literal[True]
- zoom_in_vm(vm_index: int | None = None, vm_name: str | None = None) Literal[True] ¶
Zoom in on a VM, must specify either a vm index or a vm name
- zoom_out_vm(vm_index: int | None = None, vm_name: str | None = None) Literal[True] ¶
Zoom out on a VM, must specify either a vm index or a vm name
- reboot_vm(vm_index: int | None = None, vm_name: str | None = None, non_blocking: bool = False) Literal[True] ¶
Reboot a VM, must specify either a vm index or a vm name
- Parameters:
- Raises:
PyMemucIndexError – an error if neither a vm index or a vm name is specified
- Returns:
True if the vm was rebooted successfully
- Return type:
Literal[True]
- start_vm(vm_index: int | None = None, vm_name: str | None = None, headless: bool = False, non_blocking: bool = False, timeout: float | None = None) Literal[True] ¶
Start a VM, must specify either a vm index or a vm name
- Parameters:
vm_index (int, optional) – VM index. Defaults to None.
vm_name (str, optional) – VM name. Defaults to None.
headless (bool, optional) – Whether to start the VM in headless mode. Defaults to False.
non_blocking (bool, optional) – Whether to run the command in the background. Defaults to False.
timeout (float, optional) – Timeout in seconds. Cannot be used if non blocking. Defaults to None.
- Raises:
PyMemucIndexError – an error if neither a vm index or a vm name is specified
- Returns:
True if the vm was started successfully
- Return type:
Literal[True]
- stop_all_vm(non_blocking: bool = False, timeout: float | None = None) Literal[True] ¶
Stop all VMs
- Parameters:
- Raises:
PyMemucError – an error if the vm stop failed
- Returns:
True if the vm was stopped successfully
- Return type:
Literal[True]
- stop_vm(vm_index: int | None = None, vm_name: str | None = None, non_blocking: bool = False, timeout: float | None = None) Literal[True] ¶
Stop a VM, must specify either a vm index or a vm name
- Parameters:
vm_index (int, optional) – VM index. Defaults to None.
vm_name (str, optional) – VM name. Defaults to None.
non_blocking (bool, optional) – Whether to run the command in the background. Defaults to False.
timeout (float, optional) – Timeout in seconds. Cannot be used if non blocking. Defaults to None.
- Raises:
PyMemucIndexError – an error if neither a vm index or a vm name is specified
- Returns:
True if the vm was stopped successfully
- Return type:
Literal[True]
- clone_vm(vm_index: int | None = None, vm_name: str | None = None, new_name: str | None = None, non_blocking: bool = False) Literal[True] ¶
Clone a VM, must specify either a vm index or a vm name
- Parameters:
- Raises:
PyMemucIndexError – an error if neither a vm index or a vm name is specified
- Returns:
True if the vm was cloned successfully
- Return type:
Literal[True]
- compress_vm(vm_index: int | None = None, vm_name: str | None = None, non_blocking: bool = False) Literal[True] ¶
Compress a VM, must specify either a vm index or a vm name
- Parameters:
- Raises:
PyMemucIndexError – an error if neither a vm index or a vm name is specified
PyMemucError – an error if the vm compress failed
- Returns:
True if the vm was compressed successfully
- Return type:
Literal[True]
- delete_vm(vm_index: int | None = None, vm_name: str | None = None) Literal[True] ¶
Delete a VM, must specify either a vm index or a vm name
- export_vm(vm_index: int | None = None, vm_name: str | None = None, file_name: str = 'vm.ova', non_blocking: bool = False)¶
Export a VM, must specify either a vm index or a vm name
- Parameters:
- Raises:
PyMemucIndexError – an error if neither a vm index or a vm name is specified
- Returns:
the return code and the output of the command
- Return type:
- get_configuration_vm(config_key: Literal['name', 'cpus', 'cpucap', 'memory', 'is_full_screen', 'is_hide_toolbar', 'turbo_mode', 'graphics_render_mode', 'enable_su', 'enable_audio', 'fps', 'vkeyboard_mode', 'sync_time', 'phone_layout', 'start_window_mode', 'win_x', 'win_y', 'win_scaling_percent2', 'is_customed_resolution', 'resolution_width', 'resolution_height', 'vbox_dpi', 'linenum', 'imei', 'imsi', 'simserial', 'microvirt_vm_brand', 'microvirt_vm_model', 'microvirt_vm_manufacturer', 'selected_map', 'latitude', 'longitude', 'picturepath', 'musicpath', 'moviepath', 'downloadpath', 'macaddress', 'cache_mode', 'geometry', 'custom_resolution', 'disable_resize', 'ssid'], vm_index: int | None = None, vm_name: str | None = None) str ¶
Get a VM configuration, must specify either a vm index or a vm name
- import_vm(file_name: str = 'vm.ova', non_blocking: bool = False) Literal[True] ¶
Import a VM from a file
- Parameters:
- Raises:
PyMemucError – an error if the vm import failed
- Returns:
True if the vm was imported successfully
- Return type:
Literal[True]
- list_vm_info(vm_index: int | None = None, vm_name: str | None = None, running: bool = False, disk_info: bool = False) list[VMInfo] ¶
List VM info, must specify either a vm index or a vm name
- Parameters:
- Raises:
PyMemucIndexError – an error if neither a vm index or a vm name is specified
- Returns:
a list of VM info, each VM info is a dictionary with the following keys: index: VM index title: VM title top_level: VM top level running: whether the VM is running pid: VM pid disk_usage: VM disk usage
- Return type:
- randomize_vm(vm_index: int | None = None, vm_name: str | None = None) Literal[True] ¶
Randomize a VM, must specify either a vm index or a vm name
- rename_vm(vm_index: int | None = None, vm_name: str | None = None, new_name: str | None = None) Literal[True] ¶
Rename a VM, must specify either a vm index or a vm name
- Parameters:
- Raises:
PyMemucIndexError – an error if neither a vm index or name is specified
PyMemucError – an error if the vm rename failed
- Returns:
True if the vm was renamed successfully
- Return type:
Literal[True]
- set_configuration_vm(config_key: Literal['name', 'cpus', 'cpucap', 'memory', 'is_full_screen', 'is_hide_toolbar', 'turbo_mode', 'graphics_render_mode', 'enable_su', 'enable_audio', 'fps', 'vkeyboard_mode', 'sync_time', 'phone_layout', 'start_window_mode', 'win_x', 'win_y', 'win_scaling_percent2', 'is_customed_resolution', 'resolution_width', 'resolution_height', 'vbox_dpi', 'linenum', 'imei', 'imsi', 'simserial', 'microvirt_vm_brand', 'microvirt_vm_model', 'microvirt_vm_manufacturer', 'selected_map', 'latitude', 'longitude', 'picturepath', 'musicpath', 'moviepath', 'downloadpath', 'macaddress', 'cache_mode', 'geometry', 'custom_resolution', 'disable_resize', 'ssid'], config_value: str, vm_index: int | None = None, vm_name: str | None = None) Literal[True] ¶
Set a VM configuration, must specify either a vm index or a vm name
- Parameters:
- Raises:
PyMemucIndexError – an error if neither a vm index or a vm name is specified
- Returns:
True if the vm configuration was set successfully
- Return type:
Literal[True]
- memuc_run(args: list[str], non_blocking: bool = False, timeout: float | None = None) Tuple[int, str] ¶
run a command with memuc.exe. Memuc can support non-blocking commands, returning a task id. A timeout can be specified if memuc is expected to hang, but this will not work with non-blocking commands.
- Parameters:
- Returns:
the return code and the output of the command
- Return type:
- Raises:
PyMemucError – an error if the command failed
PyMemucTimeoutExpired – an error if the command timed out
The ConfigKeys
alias¶
- ConfigKeys¶
alias of
Literal
[‘name’, ‘cpus’, ‘cpucap’, ‘memory’, ‘is_full_screen’, ‘is_hide_toolbar’, ‘turbo_mode’, ‘graphics_render_mode’, ‘enable_su’, ‘enable_audio’, ‘fps’, ‘vkeyboard_mode’, ‘sync_time’, ‘phone_layout’, ‘start_window_mode’, ‘win_x’, ‘win_y’, ‘win_scaling_percent2’, ‘is_customed_resolution’, ‘resolution_width’, ‘resolution_height’, ‘vbox_dpi’, ‘linenum’, ‘imei’, ‘imsi’, ‘simserial’, ‘microvirt_vm_brand’, ‘microvirt_vm_model’, ‘microvirt_vm_manufacturer’, ‘selected_map’, ‘latitude’, ‘longitude’, ‘picturepath’, ‘musicpath’, ‘moviepath’, ‘downloadpath’, ‘macaddress’, ‘cache_mode’, ‘geometry’, ‘custom_resolution’, ‘disable_resize’, ‘ssid’]
Key |
Description |
---|---|
|
The name of the VM. |
|
The number of CPUs to allocate to the VM. |
|
The CPU cap to allocate to the VM. ( |
|
The amount of memory to allocate to the VM. (Unit: MB) |
|
Whether the VM should be started in full screen mode. ( |
|
Whether the VM’s toolbar should be hidden. ( |
|
Whether the VM should be started in turbo mode. ( |
|
The graphics render mode to use. ( |
|
Whether the VM should be started with super user privileges. ( |
|
Whether the VM should be started with audio support. ( |
|
The VM’s frames per second. ( |
|
The VM’s virtual keyboard mode. ( |
|
Whether the VM should be started with time synchronization. ( |
|
The VM’s phone layout. ( |
|
The VM’s start window mode. ( |
|
The VM’s window X offset from upper-left corner. ( |
|
The VM’s window Y offset from upper-left corner. ( |
|
The VM’s window scaling percentage. (Unit: %) |
|
Whether the VM should be started with a custom resolution. ( |
|
The VM’s custom resolution width. ( |
|
The VM’s custom resolution height. ( |
|
The VM’s virtual box DPI. ( |
|
The VM’s phone number. |
|
The VM’s IMEI. |
|
The VM’s IMSI. |
|
The VM’s SIM serial number. |
|
The VM’s brand. |
|
The VM’s model. |
|
The VM’s manufacturer. |
|
The VM’s selected gps provider. ( |
|
The VM’s gps latitude. (Unit: Degree) |
|
The VM’s gps longitude. (Unit: Degree) |
|
The path to the VM’s shared picture path. |
|
The path to the VM’s shared music path. |
|
The path to the VM’s shared movie path. |
|
The path to the VM’s shared download path. |
|
Device MAC address |
|
Cache mode, 1 is acceleration (good performance, but there is a risk of damage to the image when the power is off accidentally), 0 is stable (the image file is not easy to be damaged, and the performance is slightly worse) ( |
|
Top left coordinate and size of simulator ( |
|
Android resolution and dpi (width height dpi) |
|
Fixed window size, 1 is fixed, 0 is stretchable |
|
WIFI name ( |