[Twisted-Python] Sample Script to create Windows Service for Twisted App (1/2)
Schneider, Michael
michael.l.schneider at ugsplm.com
Thu Mar 25 13:11:44 MST 2004
First,
A big thanks to Cory for writing the tap2ntsvc, and for helping
me understand how it work (as well as proving to me that
it can work.
In exchange for all his help, I am sending two .bat files
in 2 messages.
Because of mail filtering, I am going to include the .bat files
at the end of the messages rather then attach them.
Background:
I have a twisted program that leverages WMI, ctypes, and win32
calls. These all need to be included in the exe.
Lessons Learned:
Microsoft uses different type libraries for XP and 2000, the python
wrappers are created in the site-packages\win32com\gen_py\{GUID}1 for 2000,
and site-packages\win32com\gen_py{GUID}2 for XP.
You can create different installers for both, or include them all into
the same service (see the comments in fixup.bat in the 2/2 email)
Have fun,
Mike
----------------------------------------------------------------
Michael Schneider
Senior Software Engineering Consultant
UGS PLM Solutions - an EDS Company
"The Greatest Performance Improvement Is the transitioning from a non-working state to the working state>
------------------ gen.bat---------------------------------------------
rem ------------- BAT file to create Service for twisted app that
rem uses WMI python module
rem Author: Michael Scheider
rem Shadow Author (Cory - he helped me get going,
re and proved to me that it could work)
rem Cory also wrote the tool to package the system
rem in exchange for all his hard work, I am releasing this script
rem under the same license as Twisted (free)
rem Use this file as a roadmap, but you may need other modules,
rem Note: if you are not using WMI, you can comment out the
rem %WIN2000_WMI_MODULES% and the %WINXP_WMI_MODULES% from
rem tap2ntsvc command line
rem Twisted Functionality/Python Modules used
rem
rem WMI- process and disk info
rem ctypes - memory info
rem twisted as web server
rem twisted xml-rpc
rem cgi - perl and python
rm rpy files
rem Special thanks to Cory to get this going
rem Version Info
rem python2.3.3
rem win32all build 163
rem py2exe version 1.4.2
rem inno - latest version
rem Lessons Learned
rem
rem WMI stashes the com wrappers in site-
rem
rem Windows 2000 wrapper location= site-packages\win32com\gen_py\565783C6-CB41-11D1-8B02-00600806D9B6x0x1x1
rem Windows XP wrapper location = site-packages\win32com\gen_py\565783C6-CB41-11D1-8B02-00600806D9B6x0x1x2
rem
rem NOTE: the numbers are the same except for 2000 uses 1 and XP uses 2
rem if you want your installer to run on both you will need
rem to copy the directory from the other machine and include
rem both directories
rem ------------------- WMI modules ------------------------
rem the directory
rem set WINXP_WMI_MODULES=win32com.gen_py.565783C6-CB41-11D1-8B02-00600806D9B6x0x1x2.ISWbemMethod,win32com.gen_py.565783C6-CB41-11D1-8B02-00600806D9B6x0x1x2.ISWbemMethodSet,win32com.gen_py.565783C6-CB41-11D1-8B02-00600806D9B6x0x1x2.ISWbemObjectPath,win32com.gen_py.565783C6-CB41-11D1-8B02-00600806D9B6x0x1x2.ISWbemObjectSet,win32com.gen_py.565783C6-CB41-11D1-8B02-00600806D9B6x0x1x2.ISWbemProperty,win32com.gen_py.565783C6-CB41-11D1-8B02-00600806D9B6x0x1x2.ISWbemPropertySet,win32com.gen_py.565783C6-CB41-11D1-8B02-00600806D9B6x0x1x2.ISWbemServicesEx,win32com.gen_py.565783C6-CB41-11D1-8B02-00600806D9B6x0x1x2.SWbemMethod,win32com.gen_py.565783C6-CB41-11D1-8B02-00600806D9B6x0x1x2.SWbemMethodSet,win32com.gen_py.565783C6-CB41-11D1-8B02-00600806D9B6x0x1x2.SWbemObjectEx,win32com.gen_py.565783C6-CB41-11D1-8B02-00600806D9B6x0x1x2.SWbemObjectPath,win32com.gen_py.565783C6-CB41-11D1-8B02-00600806D9B6x0x1x2.SWbemObjectSet,win32com.gen_py.565783C6-CB41-11D1-8B02-00600806D9B6x0x1x2.SWbemProperty,win32com.gen_py.565783C6-CB41-11D1-8B02-00600806D9B6x0x1x2.SWbemPropertySet,win32com.gen_py.565783C6-CB41-11D1-8B02-00600806D9B6x0x1x2.SWbemServicesEx,win32com.gen_py.565783C6-CB41-11D1-8B02-00600806D9B6x0x1x2.__init__,win32com.gen_py.565783C6-CB41-11D1-8B02-00600806D9B6x0x1x2.ISWbemObjectEx,wmi
set WIN2000_WMI_MODULES=win32com.gen_py.565783C6-CB41-11D1-8B02-00600806D9B6x0x1x1.ISWbemMethod,win32com.gen_py.565783C6-CB41-11D1-8B02-00600806D9B6x0x1x1.ISWbemMethodSet,win32com.gen_py.565783C6-CB41-11D1-8B02-00600806D9B6x0x1x1.ISWbemObject,win32com.gen_py.565783C6-CB41-11D1-8B02-00600806D9B6x0x1x1.ISWbemObjectPath,win32com.gen_py.565783C6-CB41-11D1-8B02-00600806D9B6x0x1x1.ISWbemObjectSet,win32com.gen_py.565783C6-CB41-11D1-8B02-00600806D9B6x0x1x1.ISWbemProperty,win32com.gen_py.565783C6-CB41-11D1-8B02-00600806D9B6x0x1x1.ISWbemPropertySet,win32com.gen_py.565783C6-CB41-11D1-8B02-00600806D9B6x0x1x1.ISWbemServices,win32com.gen_py.565783C6-CB41-11D1-8B02-00600806D9B6x0x1x1.SWbemMethod,win32com.gen_py.565783C6-CB41-11D1-8B02-00600806D9B6x0x1x1.SWbemMethodSet,win32com.gen_py.565783C6-CB41-11D1-8B02-00600806D9B6x0x1x1.SWbemObject,win32com.gen_py.565783C6-CB41-11D1-8B02-00600806D9B6x0x1x1.SWbemObjectPath,win32com.gen_py.565783C6-CB41-11D1-8B02-00600806D9B6x0x1x1.SWbemObjectSet,win32com.gen_py.565783C6-CB41-11D1-8B02-00600806D9B6x0x1x1.SWbemProperty,win32com.gen_py.565783C6-CB41-11D1-8B02-00600806D9B6x0x1x1.SWbemPropertySet,win32com.gen_py.565783C6-CB41-11D1-8B02-00600806D9B6x0x1x1.SWbemServices,win32com.gen_py.565783C6-CB41-11D1-8B02-00600806D9B6x0x1x1.__init__,wmi
python tap2ntsvc --include twisted.web.server,twisted.web.resource,twisted.web.static,twisted.web.script,gridnode.webinfo,gridnode.JobRunner,gridnode.appconfig,gridnode.sendmail,twisted.internet.win32eventreactor,%WIN2000_WMI_MODULES% -r win32 d:\grid\gridnoded.tap
More information about the Twisted-Python
mailing list