【问题标题】:Updating InstallShield .ism (MSI) file with beatifulsoup and maintaining its formatting使用 beatifulsoup 更新 InstallShield .ism (MSI) 文件并保持其格式
【发布时间】:2013-07-25 22:17:42
【问题描述】:

我正在尝试使用当前构建版本更新我的 .ism 文件。查找和替换构建字符串没有问题。但是,我正在努力让我的 .ism 文件在被美丽的汤处理后保持其格式。以下是我尝试使用漂亮的汤来查找和更新构建版本字符串:

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

我被困住了,希望得到一些指点,感谢您的阅读!

【问题讨论】:

    标签: python unicode windows-installer beautifulsoup installshield


    【解决方案1】:

    您不需要更新 ISM,只需将构建版本(和许多其他内容)传递给编译器即可。如果你真的想更新 ISM,InstallShield 提供了一个自动化接口。您打开项目,更新属性,然后保存并关闭项目。

    此外,尽管我很喜欢 InstallShield,但 ISM 只是底层 MSI 表数据的 DTD XML 转换。如果代码表达能力真的是您的首要任务,那么基于 WiX XSD 的 XML 是不错的选择。

    【讨论】:

    • 谢谢你,克里斯托弗!我从另一个整天按按钮的人那里接手了构建过程,他向我展示了如何通过 ui 更改属性的手动过程。我正在尝试自动化构建过程,但我显然没有做功课并做了一个简单的“iscmdbld /?”
    • ISCMDBLD 是一种选择。 MSBuild 是另一个。我正在使用基于 Workflow 和 MSBuild 的 TFS 环境,因此它可以很好地集成。 PS-欢迎构建自动化!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-05-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-06-23
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多