From: Mark H. <ski...@gm...> - 2015-09-09 02:41:15
|
IIRC, these message resources aren't simple string resources, so I don't think it will be as simple as writing strings. I believe the win32api functions used by resource.py will be capable of writing message resources by putting together binary blobs, but I can't recall any such examples. The message sources can be found in win32service_messages.mc and includes more info than plain strings. It might be possible to have the build process copy the resources from the .pyd into the .exe, but py2exe doesn't do that either. None of the services that I created with py2exe attempted to bundle everything into a single file for this and various other reasons (eg, I often ended up needing to ship other exes along with the service exe) so having the registry point at the .pyd wasn't a problem. So sadly I think you will be largely on-your-own in terms of working out how to get these resources into the generated .exe, and you may even find your best option is to look for some external tool that can patch the generated .exe after py2exe has done its thing. Mark On 9/09/2015 11:53 AM, David Rueter wrote: > I have been able to get Py2Exe to work well with my Python 3.4 code that > implements a Windows service (that implements a Tornado HTTP server). > Thanks, Mark and others who have made Py2Exe such a useful tool! > > I am having one problem, which is this: when I install the service by > running: "myservice.exe - install", the service gets installed fine. I can > start the service, and this tries to register the .dll (.pyd) that contains > the string resource files needed by the Windows event viewer. However, my > options in setup.py call for files to be bundled into the .exe. (In other > words: bundle_files: 1, compressed: true, and zipfile=None.) > > This leads to errors when trying to access Windows event log events: "The > description for Event ID 4100 from source myservice cannot be found. Either > the component that raises this event is not installed on your local computer > or the installation is corrupted. You can install or repair the component on > the local computer." > > When I inspect the Windows registry, I see that > (HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog\Application\m > yservice > ) gets updated with something like this: > C:\Projects\MyApp\dist\myservice.exe\servicemanager.pyd This makes sense, > sort of, except that Windows can't really access the .pyd file inside the > zip archive bundled into myservice.exe. > > If I manually make a copy of servicemanager.pyd, and manually edit the > registry to point to C:\Projects\MyApp\dist\servicemanager.pyd then Windows > Event Viewer works fine to view messages logged by myservice. > > What I would really like to be able to do is to write the needed string > resources to the myservices.exe file itself, and register THIS .exe file for > the Windows event viewer to use. This way I would not need to distribute > any additional files, and would not need to manually mess around with things > (though my app may need to explicitly update the registry setting.) > > Can anyone provide any information on any of the following: > > 1) Writing to string resources in myservice.exe (such as in a script that > runs after Py2Exe builds myservices.exe). Is there any reason why this > should not be possible? > > 2) Is Py2Exe currently building string resources? I see resources.py, but > would love some more information or suggestions. I saw an old post that > suggests using pyrcc4 ( > http://comments.gmane.org/gmane.comp.python.py2exe/2907 ) to add in > resources, but if Py2Exe can write the resources natively that seems > cleaner. > > 3) Am I making this harder than it needs to be? Is there just a setting > that I am missing that would tell Py2Exe to include the resources > automatically? > > 4) Is there any other active community or wiki for Py2Exe, or is this > mailing list the best place to ask questions and collaborate on Py2Exe? > > > FYI, here is Microsoft documentation on creating Event Sources: > > https://msdn.microsoft.com/en-us/library/windows/desktop/aa363648(v=vs.85).a > spx > https://msdn.microsoft.com/en-us/library/windows/desktop/aa363661(v=vs.85).a > spx > https://msdn.microsoft.com/en-us/library/windows/desktop/aa363669(v=vs.85).a > spx > > Thanks in advance. > > David Rueter > dr...@as... > > > > > ------------------------------------------------------------------------------ > Monitor Your Dynamic Infrastructure at Any Scale With Datadog! > Get real-time metrics from all of your servers, apps and tools > in one place. > SourceForge users - Click here to start your Free Trial of Datadog now! > http://pubads.g.doubleclick.net/gampad/clk?id=241902991&iu=/4140 > _______________________________________________ > Py2exe-users mailing list > Py2...@li... > https://lists.sourceforge.net/lists/listinfo/py2exe-users > |