0
我試圖用當前版本更新我的.ism文件。我沒有發現和替換構建字符串的問題。不過,我正在努力讓我的.ism文件在被美麗的湯加工後保持其格式。以下是我在嘗試用美麗的湯來查找和更新版本的字符串:用beatifulsoup更新InstallShield .ism(MSI)文件並保持其格式化
def upVerIsm(origFile,newFile):
openIsm = origFile
outputIsm = newFile
soup = BeautifulSoup(openIsm)
tblProp = soup.find("table", {"name":"Property"})
rows = tblProp.find_all("row")
for row in rows:
firstCell = row.contents[0].get_text()
if firstCell == "ProductVersion":
tmpProdVer = row.contents[1].string.replace_with(updVerStr)
if(flgMstrVer):
tblReg = soup.find("table", {"name":"Registry"})
# get all rows within registry table
rows = tblReg.find_all("row")
for row in rows:
td4 = row.contents[3].get_text()
if td4 == "MasterVersion":
td5 = row.contents[4].get_text()
tmpMstrStr = re.split('_',unicode(td5))
newBuildStr = tmpMstrStr[0] + "_" + tmpMstrStr[1] + "_" + tmpMstrStr[2] + "_B" + version_num
row.contents[4].string.replace_with(str(newBuildStr))
print row
# tmpIsm = soup.encode("ascii","ignore")
# updatedIsm = soup.prettify(formatter=None) # if i do this i get the ascii code error: (UnicodeEncodeError: 'ascii' codec can't encode character u'\u2019' in position 666845: ordinal not in range(128))
updatedIsm = str(soup) # this alters the content of the .ism file and breaks the build
outputIsm.write(updatedIsm)
return outputIsm,openIsm # new,original files respectively
我堅持,並希望一些指針,並感謝您的閱讀!
謝謝你,克里斯托弗!我接手了另一個整天按下按鈕的人的構建過程,他向我展示瞭如何通過UI改變屬性的手動過程。我試圖自動化構建過程,我顯然沒有做我的功課,做一個簡單的「iscmdbld /?」 – user1951677
ISCMDBLD是一種選擇。 MSBuild是另一個。我使用的是基於Workflow和MSBuild的TFS環境,因此它很好地集成在一起。 PS-歡迎來構建自動化! –