使用Esky更新Python Windows服务

2024-04-29 09:22:32 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个正在工作的Windows服务,目前我使用py2exe来构建一个exe,然后使用WiX工具集来构建MSI。在

但是,当将esky引入到静默和自动服务更新的混合中时,我无法正确获得更新版本。在

from distutils.core import setup
import  shutil, os
from esky import bdist_esky

# Setup.py for Windows Service. Works with Py2exe

#
class Target:
    def __init__(self, **kw):
        self.__dict__.update(kw)
        self.version = "1.0.0"
        self.company_name = ""
        self.copyright = "2015"
        self.name = " Edit Service"


myservice = Target(
    description = 'Edit Tracker Service',
    modules = ['Logon_Service'],
    cmdline_style='pywin32'
)


setup(
    name = " Edit Service",
    data_files=[('files', ['configs.yaml']),
               ],
    version = "1.0.0",
    options = {
        "bdist_esky":
        {
        "includes": ['yaml', 'pymysql', 'win32timezone'],
        "freezer_module": 'py2exe',
        }
    },
    zipfile = None,
    service=[myservice]
)

使用上面的设置.py结果生成.zip文件。解压后,可执行文件和服务就可以正确地安装和启动了。在

在增加版本号并再次运行python setup.py bdist_esky之后,我创建了另一个zip文件。在

然后我运行原始的.exe,它可以正确地看到更新,但是它无法执行,返回以下异常

You are running: 1.0.0 ('ERROR UPDATING APP:', OSError(None, 'unable to cleanup: startup hooks not run' ))

我的Win32Service实现与esky相关的摘录如下

^{pr2}$

如果需要更多的信息,我会根据需要添加更多代码。实现以下目标。在

  1. 生成可执行文件/MSI
  2. 到处部署
  3. 从中央服务器自动更新。在

我对Distributions和esky非常陌生,任何建议都将不胜感激!在


Tags: namefrompyimportselfwindowsservicesetup