How to use toKeyName method in fMBT

Best Python code snippet using fMBT_python

fmbtuinput.py

Source:fmbtuinput.py Github

copy

Full Screen

...500 elif ("KEY_" + keyCodeOrName.upper()) in keyCodes:501 return keyCodes["KEY_" + keyCodeOrName.upper()]502 else:503 raise ValueError('Invalid keycode "%s"' % (keyCodeOrName,))504def toKeyName(keyCode):505 if keyCode in keyCodesInv:506 return keyCodesInv[keyCode]507 else:508 raise ValueError('Invalid keycode "%s"' % (keyCode,))509def toButtonCode(buttonCodeOrName):510 if isinstance(buttonCodeOrName, str):511 buttonCode = toKeyCode(buttonCodeOrName)512 elif buttonCodeOrName < 0xf:513 buttonCode = keyCodes["BTN_MOUSE"] + buttonCodeOrName514 else:515 buttonCode = buttonCodeOrName516 return buttonCode517def refreshDeviceInfo():518 global _g_devices...

Full Screen

Full Screen

main.PY

Source:main.PY Github

copy

Full Screen

1#!/usr/bin/python2# -*- coding: UTF-8 -*-3import sys4import os5import configparser6def 清空目录 (path):7 os.system("rd /s /Q \""+ path + "\"")8 if os.path.exists(path)==False:9 os.makedirs(path)10 return11def 复制目录 (path,pathGoTo):12 os.system("xcopy \""+ path+"\" \"" + pathGoTo + "\" /Q /Y /H /R /E")13 return14def 挂载配置单元 (FileName,KeyName):15 os.system ("reg load "+KeyName+" \""+FileName+"\"")16 return17def 卸载配置单元 (KeyName):18 os.system ("reg unload "+KeyName)19 return20def 导入注册表项 (FileName):21 os.system ("reg import \""+FileName+"\"")22 return23def 复制注册表项 (KeyName,toKeyName):24 os.system ("reg copy \""+KeyName+"\" \""+toKeyName+"\" /S /F")25 return 26def 加密PECMD脚本 (path):27 os.system(运行目录+"Bin\Tools\pecmd.exe \"CMPS -bin "+path+","+path+".new\"")28 os.remove(path)29 os.rename(path+".new",path)30 return31os.system("title HotPE生成脚本")32运行目录 = os.path.split( os.path.realpath( sys.argv[0] ) )[0] + "\\"33执行文件名 =sys.argv[0]34# 初始化35PE配置 = configparser.ConfigParser()36# 读取配置文件37PE配置.read(运行目录 +'PE_config.txt', encoding='ANSI')38print("正在清理文件")39清空目录 (运行目录 + "TempFile\\apply")40清空目录 (运行目录 + "TempFile\\config")41光驱盘符 = input ("输入虚拟光驱盘符(不加冒号):")42installWim = 光驱盘符 + ":\\sources\\install.wim"43bootWim = 光驱盘符 + ":\\sources\\boot.wim"44boot分卷 = PE配置.get('wim', 'boot分卷')45install分卷 = PE配置.get('wim', 'install分卷')46wimlibImagex= 运行目录 + "Bin\\Tools\\wimlib\\wimlib-imagex.exe"47print("正在从boot.wim提取文件")48os.system(wimlibImagex+" apply "+bootWim+" "+str(boot分卷)+" "+运行目录+"TempFile\\apply")49print("正在从boot.wim提取Cat文件")50清空目录 (运行目录 + "TempFile\\apply\\Windows\\System32\\CatRoot\\{127D0A1D-4EF2-11D1-8608-00C04FC295EE}\\")51清空目录 (运行目录 + "TempFile\\apply\\Windows\\System32\\CatRoot\\{F750E6C3-38EE-11D1-85E5-00C04FC295EE}\\")52os.system(wimlibImagex+" extract "+bootWim+" "+str(boot分卷)+" @"+运行目录+"Bin\\Files\\Cat.txt "+"--dest-dir="+运行目录+"TempFile\\apply "+" --nullglob --no-acls")53print("正在清理WinSxS文件")54清空目录 (运行目录 + "TempFile\\apply\\Windows\\WinSxS\\")55print("正在从install.wim提取文件")56#os.system(wimlibImagex+" extract "+installWim+" "+str(install分卷)+" \Windows\System32\Recovery\winre.wim "+"--dest-dir="+运行目录+"TempFile\\ "+" --nullglob --no-acls")57os.system(wimlibImagex+" extract "+installWim+" "+str(install分卷)+" @"+运行目录+"Bin\\Files\\install.txt "+"--dest-dir="+运行目录+"TempFile\\apply "+" --nullglob --no-acls")58print("正在从删除无用文件")59for line in open(运行目录+"Bin\\Files\\delFiles.txt", "r"): #打开文件60 rs = line.rstrip('\n') # 移除行尾换行符61 if os.path.isfile(运行目录+"TempFile\\apply\\"+rs):62 os.system("del "+运行目录+"TempFile\\apply\\"+rs+" /F /Q")63 if os.path.isdir(运行目录+"TempFile\\apply\\"+rs):64 os.system("rd "+运行目录+"TempFile\\apply\\"+rs+" /S /Q")65for line in open(运行目录+"Bin\\Files\\delFilesMore.txt", "r"): #打开文件66 rs = line.rstrip('\n') # 移除行尾换行符67 if os.path.isfile(运行目录+"TempFile\\apply\\"+rs):68 os.system("del "+运行目录+"TempFile\\apply\\"+rs+" /F /Q")69 if os.path.isdir(运行目录+"TempFile\\apply\\"+rs):70 os.system("rd "+运行目录+"TempFile\\apply\\"+rs+" /S /Q")71for line in open(运行目录+"Bin\\Files\\delFilesMore(drivers).txt", "r"): #打开文件72 rs = line.rstrip('\n') # 移除行尾换行符73 if os.path.isfile(运行目录+"TempFile\\apply\\"+rs):74 os.system("del "+运行目录+"TempFile\\apply\\"+rs+" /F /Q")75 if os.path.isdir(运行目录+"TempFile\\apply\\"+rs):76 os.system("rd "+运行目录+"TempFile\\apply\\"+rs+" /S /Q")77for line in open(运行目录+"Bin\\Files\\clearDir.txt", "r"): #打开文件78 rs = line.rstrip('\n') # 移除行尾换行符79 清空目录(运行目录+"TempFile\\apply\\"+rs)80 81print("正在从install.wim提取注册表文件:system,drivers")82os.system(wimlibImagex+" extract "+installWim+" "+str(install分卷)+" \Windows\System32\config\system "+"--dest-dir="+运行目录+"TempFile\\config "+" --nullglob --no-acls")83os.system(wimlibImagex+" extract "+installWim+" "+str(install分卷)+" \Windows\System32\config\drivers "+"--dest-dir="+运行目录+"TempFile\\config "+" --nullglob --no-acls")84print("正在添加文件:AddFiles\*")85复制目录(运行目录+"AddFiles",运行目录+"TempFile\\apply")86print("正在加密Pecmd脚本文件")87#加密PECMD脚本(运行目录+"TempFile\\apply\\windows\\system32\\PECMD.ini")88print("正在挂载配置单元")89挂载配置单元 (运行目录+"TempFile\\config\\drivers","hklm\os_drv")90挂载配置单元 (运行目录+"TempFile\\config\\system","hklm\os_sys")91挂载配置单元 (运行目录+"TempFile\\apply\\windows\\system32\\config\\default","hklm\pe_def")92挂载配置单元 (运行目录+"TempFile\\apply\\windows\\system32\\config\\software","hklm\pe_soft")93挂载配置单元 (运行目录+"TempFile\\apply\\windows\\system32\\config\\system","hklm\pe_sys")94挂载配置单元 (运行目录+"TempFile\\apply\\windows\\system32\\config\\DRIVERS","hklm\pe_drv")95print("正在导入注册表项")96导入注册表项 (运行目录 + "Bin\\RegistryFiles\\explorer.reg")97导入注册表项 (运行目录 + "Bin\\RegistryFiles\\pe_def.reg")98导入注册表项 (运行目录 + "Bin\\RegistryFiles\\pe_soft.reg")99导入注册表项 (运行目录 + "Bin\\RegistryFiles\\Pecmd.ini.reg")100print("正在修改C:\\为X:\\")101os.system(运行目录 + "Bin\\Tools\\regfind.exe"+" -p HKEY_LOCAL_MACHINE\\pe_soft -y C:\\ -y -r X:\\")102print("正在处理Interactive User")103os.system(运行目录 + "Bin\\Tools\\regfind.exe"+" -p HKEY_LOCAL_MACHINE\\pe_soft\Classes\AppID -y Interactive User -r")104print("复制必要的SYSTEM注册表到PE")105for line in open(运行目录+"\\Bin\\RegistryFiles\\pe_sys.txt", "r"): #打开文件106 rs = line.rstrip('\n') # 移除行尾换行符107 复制注册表项("hklm\\os_sys\\"+rs,"hklm\\pe_sys\\"+rs)108导入注册表项 (运行目录 + "Bin\\RegistryFiles\\pe_sys.reg")109print("复制必要的drivers注册表到PE")110for line in open(运行目录+"\\Bin\\RegistryFiles\\pe_drv.txt", "r"): #打开文件111 rs = line.rstrip('\n') # 移除行尾换行符112 复制注册表项("hklm\\os_drv\\"+rs,"hklm\\pe_drv\\"+rs)113os.system(运行目录 + "copyDriver.bat")114导入注册表项 (运行目录 + "Bin\\RegistryFiles\\pe_drv.reg") 115print("正在卸载配置单元")116卸载配置单元 ("hklm\os_drv")117卸载配置单元 ("hklm\os_sys")118卸载配置单元 ("hklm\pe_def")119卸载配置单元 ("hklm\pe_soft")120卸载配置单元 ("hklm\pe_sys")121卸载配置单元 ("hklm\pe_drv")122os.system("del /f /q /ah \"" + 运行目录 + "TempFile\\apply\\Windows\\System32\\config\\*.*\"")123print("正在破解USB弹出功能文件")124os.system(运行目录 +"Bin\\Tools\\binmay.exe -u \"" + 运行目录 + "TempFile\\apply\\Windows\\System32\\DeviceSetupManager.dll\" -s u:SystemSetupInProgress -r u:DisableDeviceSetupMgr")125print("正在删除dll备份文件")126os.system("del \"" + 运行目录 + "TempFile\\apply\\Windows\\System32\\DeviceSetupManager.dll.org\"")127print("正在打包成Kernel.wim")128os.system(wimlibImagex+" capture \"" + 运行目录 + "TempFile\\apply\" \""+运行目录+"\\Kernel.wim\" \"HotPE\" --boot --compress=lzx --rebuild")129print("正在打包成ISO")130os.system("del "+运行目录+"TempFile\\ISO\\HotPE\\Kernel.wim /F /S /Q")131os.system("copy \""+运行目录+"Kernel.wim\" \""+运行目录+"TempFile\\ISO\\HotPE\\Kernel.wim\"")132os.system(运行目录 +"Bin\\Tools\\oscdimg.exe -m -o -u2 -udfver102 -h -bootdata:2#p0,e,b"+运行目录+"Bin\\Tools\\Etfsboot.com#pEF,e,b"+运行目录+"Bin\\Tools\\Efisys.bin -l\"HotPE工具箱\" "+运行目录+"TempFile\\ISO\\ "+运行目录+"HotPE工具箱.iso")133input("构建结束,回车启动虚拟机测试")...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run fMBT automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful