def _createAndInjectStartupFile(self, batFileList, hasCdrom): """windows path elements in batFileList is relative to usb disk drive root directory""" # create startup file in tmpDir tmpf = os.path.join(self.param.tmpDir, "startup.bat") nbuf = "" if True: lineList = FvmUtil.readFile(os.path.join(self.param.dataDir, "startup.bat.in")).split("\n") tmplBegin = lineList.index("@@execute_template@@") tmplEnd = lineList.index("@@execute_template_end@@") nbuf += "\n".join(lineList[:tmplBegin]) + "\n" tmplBuf = "\n".join(lineList[tmplBegin + 1:tmplEnd]) + "\n" for vsi in batFileList: ntbuf = tmplBuf ntbuf = ntbuf.replace("@@execName@@", vsi) ntbuf = ntbuf.replace("@@execWorkDir@@", FvmUtil.winDirname(vsi)) ntbuf = ntbuf.replace("@@execFile@@", vsi) nbuf += ntbuf nbuf += "\n".join(lineList[tmplEnd + 1:]) if hasCdrom: nbuf = nbuf.replace("@@driverLetter@@", "E:") else: nbuf = nbuf.replace("@@driverLetter@@", "D:") FvmUtil.writeFile(tmpf, nbuf) # inject startup file mptObj = WinDiskMountPoint(self.param, self.vmObj.getMainDiskImage(), self._getWinLang()) try: startupDir = FvmUtil.getWinDir("startup", self._getWinLang(), FvmUtil.getWinUser()) mptObj.addTmpFile(tmpf, startupDir, False) finally: mptObj.umount()
def _generateUnattendXmlScript(self, uatFile): # read template uatTemplateFile = self._getFile(self.osName, "autounattend") buf = FvmUtil.readFile(uatTemplateFile) # replace content buf = buf.replace("@@timezone@@", self._getTimezone()) buf = buf.replace("@@serial_id@@", self._getSerial()) buf = buf.replace("@@x_resolution@@", "1024") buf = buf.replace("@@y_resolution@@", "768") buf = buf.replace("@@country_code@@", "86") buf = buf.replace("@@area_code@@", "00") buf = buf.replace("@@dialing@@", "Tone") buf = buf.replace("@@language_group@@", "10") buf = buf.replace("@@language@@", "00000804") # write file FvmUtil.writeFile(uatFile, buf)
def _createAndInjectStartupFile(self, batFileList, hasCdrom): """windows path elements in batFileList is relative to usb disk drive root directory""" # create startup file in tmpDir tmpf = os.path.join(self.param.tmpDir, "startup.bat") nbuf = "" if True: lineList = FvmUtil.readFile( os.path.join(self.param.dataDir, "startup.bat.in")).split("\n") tmplBegin = lineList.index("@@execute_template@@") tmplEnd = lineList.index("@@execute_template_end@@") nbuf += "\n".join(lineList[:tmplBegin]) + "\n" tmplBuf = "\n".join(lineList[tmplBegin + 1:tmplEnd]) + "\n" for vsi in batFileList: ntbuf = tmplBuf ntbuf = ntbuf.replace("@@execName@@", vsi) ntbuf = ntbuf.replace("@@execWorkDir@@", FvmUtil.winDirname(vsi)) ntbuf = ntbuf.replace("@@execFile@@", vsi) nbuf += ntbuf nbuf += "\n".join(lineList[tmplEnd + 1:]) if hasCdrom: nbuf = nbuf.replace("@@driverLetter@@", "E:") else: nbuf = nbuf.replace("@@driverLetter@@", "D:") FvmUtil.writeFile(tmpf, nbuf) # inject startup file mptObj = WinDiskMountPoint(self.param, self.vmObj.getMainDiskImage(), self._getWinLang()) try: startupDir = FvmUtil.getWinDir("startup", self._getWinLang(), FvmUtil.getWinUser()) mptObj.addTmpFile(tmpf, startupDir, False) finally: mptObj.umount()
def _getSerial(self): serialFile = self._getFile(self.osName, "serial") buf = FvmUtil.readFile(serialFile) return buf.split("\n")[0]