文档¶
PyMemuc 模块¶
a wrapper for memuc.exe as a library to control virual machines.
- class PyMemuc(memuc_path: str | None = None, debug: bool = False)[源代码]¶
基类:
object与 memuc.exe 命令行工具交互以控制虚拟机的类。
- 参数:
- 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.
- 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.
- 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.
- 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.
- 参数:
- 抛出:
PyMemucIndexError -- 如果既未指定虚拟机索引也未指定虚拟机名称,则会出现错误
PyMemucTimeoutExpired -- 如果命令超时则出错
PyMemucError -- an error if the command fails
- 返回:
adb连接的IP和端口,以元组形式返回
- 返回类型:
- 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.
- 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.
- 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.
- 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.
- 参数:
vm_index (int, optional) -- 虚拟机索引。 默认为 None。
- 抛出:
PyMemucIndexError -- 如果既未指定虚拟机索引也未指定虚拟机名称,则会出现错误
- 返回:
如果虚拟机窗口旋转成功,则为 True
- 返回类型:
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.
- 参数:
- 抛出:
PyMemucIndexError -- 如果既未指定虚拟机索引也未指定虚拟机名称,则会出现错误
PyMemucTimeoutExpired -- 如果命令超时则出错
- 返回:
命令的返回码和输出。
- 返回类型:
- 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.
- 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.
- 参数:
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) -- 虚拟机索引。 默认为 None。
vm_name (str, optional) -- 虚拟机名称。 默认为 None。
timeout (float, optional) -- Timeout in seconds. Defaults to None.
- 抛出:
PyMemucIndexError -- 如果既未指定虚拟机索引也未指定虚拟机名称,则会出现错误
- 返回:
如果虚拟机应用程序启动成功,则为 True
- 返回类型:
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.
- 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.
- 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.
- 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.
- 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.
- 参数:
- 抛出:
PyMemucIndexError -- 如果既未指定虚拟机索引也未指定虚拟机名称,则会出现错误
- 返回:
如果虚拟机成功启动则为 True
- 返回类型:
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.
- 参数:
- 抛出:
PyMemucIndexError -- 如果既未指定虚拟机索引也未指定虚拟机名称,则会出现错误
- 返回:
如果虚拟机已成功停止,则为 True
- 返回类型:
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.
- 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.
- 参数:
- 抛出:
PyMemucIndexError -- 如果既未指定虚拟机索引也未指定虚拟机名称,则会出现错误
PyMemucError -- an error if the vm compress failed
- 返回:
True if the vm was compressed successfully
- 返回类型:
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) tuple[int, str]¶
Export a VM, must specify either a vm index or a vm name.
- get_configuration_vm(config_key: ConfigKeys, 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.
- 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.
- 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.
- set_configuration_vm(config_key: ConfigKeys, 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.
- 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.
The ConfigKeys alias¶
- ConfigKeys¶
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'] 的别名
配置键 |
配置描述 |
|---|---|
|
虚拟机的名称。 |
|
分配给虚拟机的 CPU 数量。 |
|
分配给虚拟机的最大 CPU 使用率。 ( |
|
分配给虚拟机的内存量。 (单位:兆字节) |
|
虚拟机是否应该以全屏模式启动。 ( |
|
虚拟机的工具栏是否应该隐藏。 ( |
|
虚拟机是否应该以涡轮模式启动。 ( |
|
要使用的图形渲染模式。 ( |
|
虚拟机是否应该以超级用户权限启动。 ( |
|
虚拟机是否应以音频支持启动。 ( |
|
虚拟机的每秒帧数。 ( |
|
虚拟机的虚拟键盘模式。 ( |
|
虚拟机是否应以时间同步启动。 ( |
|
虚拟机的电话布局。 ( |
|
虚拟机的启动窗口模式。 ( |
|
虚拟机窗口水平轴偏离左上角。( |
|
虚拟机窗口垂直轴偏离左上角。 ( |
|
虚拟机的窗口缩放百分比。 (单元: %) |
|
虚拟机是否应以自定义分辨率启动。 ( |
|
虚拟机的自定义分辨率宽度。( |
|
虚拟机的自定义分辨率高度。( |
|
虚拟机的虚拟机 DPI。( |
|
虚拟机的电话号码 |
|
虚拟机的 IMEI |
|
虚拟机的 IMSI |
|
虚拟机的 SIM 序列号。 |
|
虚拟机的品牌。 |
|
虚拟机的型号。 |
|
虚拟机的制造商。 |
|
虚拟机选择的 GPS 提供商。 ( |
|
虚拟机的 GPS 纬度。 (单位:学位) |
|
虚拟机的 GPS 经度。 (单位:学位) |
|
虚拟机共享图片路径的目录路径。 |
|
虚拟机共享音乐路径的目录路径。 |
|
虚拟机共享电影路径的目录路径。 |
|
虚拟机共享下载路径的目录路径。 |
|
设备 MAC 地址 |
|
缓存模式,1 表示加速(性能良好,但存在意外断电时图像损坏的风险),0 表示稳定(图像文件不容易损坏,性能略有下降)(1, 0) |
|
模拟器的左上坐标和尺寸(x y 宽度 高度) |
|
Android 分辨率和 DPI(宽度 高度 DPI) |
|
固定窗口大小,1 表示固定,0 表示可伸缩 |
|
WIFI名称(uylnhxb557|auto)(auto 代表自动生成) |