Best Python code snippet using fMBT_python
fmbtuinput.py
Source:fmbtuinput.py
...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...
main.PY
Source:main.PY
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("æ建ç»æï¼å车å¯å¨èææºæµè¯")...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!