43 lines
1.2 KiB
Python
43 lines
1.2 KiB
Python
global subprocess
|
|
import subprocess
|
|
global shutil
|
|
import shutil
|
|
|
|
opus.wim = Munch()
|
|
opus.wim.index = 0
|
|
opus.wim.location = ""
|
|
|
|
def _wimPath(p = ""):
|
|
if p == "": return pJoin(opus.path.wim,str(opus.wim.index))
|
|
return pJoin(opus.path.wim,str(opus.wim.index),p)
|
|
opus.wim.path = _wimPath
|
|
|
|
def _wimExtractFiles(filePaths):
|
|
fileList = []
|
|
for filePath in filePaths:
|
|
fileList.append("-i!" +pJoin(str(opus.wim.index),filePath))
|
|
|
|
opus.main.output("extracting " +str(len(filePaths))+ " files from " +opus.wim.location+ "...")
|
|
|
|
for filePath in filePaths:
|
|
rtn = subprocess.call(
|
|
["wimlib-imagex","extract",
|
|
opus.wim.location,str(opus.wim.index),
|
|
filePath,
|
|
"--dest-dir=" +opus.wim.path(""),"--preserve-dir-structure"]
|
|
)
|
|
if rtn > 0: raise Exception("wim")
|
|
opus.wim.extractFiles = _wimExtractFiles
|
|
|
|
def _wimReadyFile(inPath,outPath):
|
|
if os.path.isfile(opus.wim.path(outPath)): os.remove(opus.wim.path(outPath))
|
|
shutil.copyfile(inPath,opus.wim.path(outPath))
|
|
opus.wim.readyFile = _wimReadyFile
|
|
|
|
def _wimUpdate():
|
|
opus.main.output("adding changed files to wim...")
|
|
rtn = subprocess.call(
|
|
["wimlib-imagex","update",opus.wim.location,str(opus.wim.index),
|
|
"--command=add '" +opus.wim.path("")+ "' '\\'"]
|
|
)
|
|
opus.wim.update = _wimUpdate |