
Folks, I've got some questions, with windows usage of Twisted Matrix... I'm considering using TM as the framework for a revival of a another program that I use to write.... But, I ran into *ALOT* of issues on the PC side... (I wasn't even able to get it to work on the Mac due to Line-ending issues, I haven't figured a simple way to convert the entire tree yet). 1) setup.py install died....It stopped when it couldn't find "CL.EXE", while building something in the twisted.spread.cbanana section... 2) A lot of the files, don't have a .py extension. (i.e. mktap, twistd, etc) This is a major hindrance, because either I have to rename the file, or execute it explicitly "python mktap ....etc....". I have windows set to run the .py files via python automatically. 3) web.distrib has some issues. Mainly attempting to use the pwd unit under windows. I was able to add: try: ..... ..... except: pass to the import statement and the actual PWD / user area, without any obvious harmful problems.... 4) Error checking is extremely light.... mktap web failed, until I fixed #3. The program didn't report any useful error messages, it just repeated the help text indicating what types (web, ftp, etc) could be used for the command line. 5) Even after fixing #3, mktap web --static static, isn't working. 6) Under Windows, the default should be -n for twistd, and the PID file shouldn't be created. At least, as it is now. twistd just "stops", after it starts up and drops us back to the command line, and examination shows that the program isn't running. So at least as a workaround, the -n mode works.... I guest a better question is, has twistedmatrix been tested under Windows? It really seems to be unix centric in it's programming... - Benjamin

On Mon, Feb 18, 2002 at 06:34:33PM -0500, Benjamin Schollnick wrote:
Folks,
I've got some questions, with windows usage of Twisted Matrix...
I use Twisted under Windows, so I may be able to offer some help..
CL.EXE is a command line program that comes with MS Visual C++... setup.py is basically trying to compile a C extension module. I can send you a binary for that file if you don't have MS VC++ installed, otherwise run VCVARS32.BAT and try again.
This is easily fixed with short bash script, but I agree, this is annoyed. I'd suggest the Twisted developers look at how, e.g. PyChecker or Teud does it (various scripts get installed in %PYTHONPATH%/scripts/<foo>.bat).
I don't use the twisted.web stuff (yet ;), so I can't offer any help here :(
Yeah, -n uses os.fork, which is not available under Windows. You probably need to use NT services instead... Alternatively, consider using the cygwin version of Python -- it is closer to the unix version, and so os.fork will work. Also, it comes with gcc, so cbanana would compile correctly. Unfortunately, I don't think it can interoperate with the Win32 extensions (at least, not that I know of).
I guest a better question is, has twistedmatrix been tested under Windows? It really seems to be unix centric in it's programming...
It basically works. The other problem to watch out for is that Protocol.connectionFailed won't trigger unless you specify a timeout for your tcp.Client, because select works slightly differently on Windows. Incidentally, I'm not using the twistd stuff *at all* (I don't yet understand the need for it under Windows, but then I don't even know exactly what it's meant to do...). Instead, I'm using this little file: --- ServerFramework/Service.py --- import win32serviceutil, win32service """Example use of this module: from ServerFramework.Service import Service, main import ExampleServer class ExampleServerService(Service): _svc_name_ = "ExampleServerService" _svc_display_name_ = "My Example Server Service" main = ExampleServer.main if __name__ == '__main__': main(ExampleServerService) """ try: import twisted except ImportError: print "Twisted Python must be installed to run this service" raise class Service(win32serviceutil.ServiceFramework): """I am a template service for ServerFramework servers. You should subclass me and override the following attributes: _svc_name_ -- see win32serviceutil docs _svc_display_name_ -- see win32serviceutil docs main -- function that starts your server You can also override: logFile -- filename for where debug messages will be saved (default: c:/<_svc_name_>.log) """ _svc_name_ = "UnnamedServer" _svc_display_name_ = "My UNNAMED Server" main = None logFile = None def __init__(self, *args): win32serviceutil.ServiceFramework.__init__(self, *args) if not self.logFile: self.logFile = 'c:/%s.log' % (self._svc_name_,) def SvcDoRun(self): from twisted.python.log import startLogging startLogging(open(self.logFile,'a')) # Call main, note that it is not a method of this class, so we use # self.main.im_func() instead of self.main(). self.main.im_func() def SvcStop(self): self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING) from twisted.internet.main import shutDown shutDown() def main(svc): win32serviceutil.HandleCommandLine(svc) if __name__ == '__main__': print "This is a library module, and should not be executed." --- It basically wraps up the functionality of the win32serviceutil in a convenient way for Twisted servers. Once you've used it as shown in the example, just run it from the commandline -- it's self explantory (it uses Mark Hammond's win32serviceutil.HandleCommandLine function to let you install the service). I'm not sure if the self.main.im_func trick will work on older Pythons; I use 2.2. I hope this is of some use to you. -Andrew.

On Mon, 2002-02-18 at 18:24, Andrew Bennetts wrote:
Hey Andrew, thanks for answering that question. You beat my response, almost as I was sending it ;) The Twisted team really needs a dedicated windows person. Would you be interested in taking up that mantle and making some of these issues go away in the central distribution? It sounds like you've got a smoother windows work-flow than I have here. -- "Cannot stand to be one of many -- I'm not what they are." -Guster, "Rocketship" glyph lefkowitz; ninjaneer, freelance demiurge glyph @ [ninjaneering|twistedmatrix].com

On Mon, Feb 18, 2002 at 06:52:56PM -0600, Glyph Lefkowitz wrote:
Hey Andrew, thanks for answering that question. You beat my response, almost as I was sending it ;)
Heh.
Most of my time at work is now spent coding Twisted servers, which is why I'm familiar with all these issues. I'd love to take up that mantle, but I rarely run Windows at home... so I won't commit myself fully yet, but I certainly would like to see how much I can help. -Andrew.

On Tue, Feb 19, 2002 at 11:24:35AM +1100, Andrew Bennetts wrote:
Anyone attempting to do anything under windoze should look at the cygwin tools. the cygwin bash shell automaticly executes things with #!/... lines for you. -- ---------------------------------------------------------------------- ABO: finger abo@minkirri.apana.org.au for more info, including pgp key ----------------------------------------------------------------------

on 2/18/02 7:24 PM, Andrew Bennetts at andrew-twisted@puzzling.org wrote:
No Visual C++.... If you don't mind sending it, I would appreciate it... This really needs to be noted.... I admit, I didn't search around too much, but I didn't see anything mentioning that it required a C/C++ compiler... (How about a precompiled Windows binary? Or having Distutils install the precompiled binary)....
That's what I figured.... (By NT Services, you mean the services listed from control panels --> services?) But I dislike the NT services.... I've never seen a service get installed, that will "uninstall" properly... (Usually add/remove program doesn't uninstall the service) I prefer to run the console......reminds me a little bit more of a syslog window... >g<
I use the Win32 services, include ODBC... So that's not really a useable workaround...
Is the following code "temporary".... It's considered a service while running, but doesn't get installed in the services control panel? It looks interesting, but I don't want to register the app as a "true" service... As I mentioned before, I can't find a reliable way to remove a service, without registry hacking... -- Benjamin

On Mon, 2002-02-18 at 21:15, Benjamin Schollnick wrote:
cBanana is an optional C implementation of the regular pure-python banana. You don't need it. I guess for now you can just hack setup.py and comment out the section that looks like this: setup_args['ext_modules'] = [ Extension("twisted.spread.cBanana", [extpath("twisted/spread/cBanana.c")]), ]
It doesn't require one, but apparently the setup scripts barf if you don't have one. -- Chris Armstrong << radix@twistedmatrix.com >> http://twistedmatrix.com/users/carmstro.twistd/

On Mon, Feb 18, 2002 at 09:15:41PM -0500, Benjamin Schollnick wrote:
I'll send it in a private mail. It's compiled for Python 2.2 on Win2k; it should be portable to any Win32, but I'm just guessing about that.
I *think* what's supposed to happen is for it to fallback to a pure Python implementation. It's part of the twisted.spread package; if you're not using spreadable computing, it doesn't really matter anyway.
Yep.
These ones will :) If you've got an ExampleService.py which contains the example below, you can do: ExampleService.py install ExampleService.py start ExampleService.py stop ExampleService.py remove As well as the usual stuff in the control panel... see the docs for the win32serviceutil module for details.
I prefer to run the console......reminds me a little bit more of a syslog window... >g<
Yeah, but that requires you to be logged in for your server to run. But I know what you mean. Have you seen simpleserv.py in the docs/example directory that came with Twisted? It doesn't require mktap or twistd, it just runs standalone -- my servers all run like that, or optionally as a service via that module I posted below. I generally debug them by running them at the command line, and then install them as a service when I think they're ready to run without me needing to watch them :)
Yeah. Are you using ODBC via COM (i.e. by calling win32com.client.Dispatch("ADODB.Connection"))? If so, you will probably want to use the mx.ODBC library with Twisted instead, as it can automatically work with the twisted.enterprise stuff (with a tiny amount of hackery).
No, it's a full-blown service. It can be installed as a service, it can be set to start a startup, etc.
Don't worry, that's already taken care of... this is Python, it plays nice :) I'll be happy to elaborate further on any of this if you like. Perhaps I should whip up an example of installing and using simpleserv.py as a service? -Andrew.

On Tue, Feb 19, 2002 at 01:55:43PM +1100, Andrew Bennetts wrote:
I'll send it in a private mail. It's compiled for Python 2.2 on Win2k; it should be portable to any Win32, but I'm just guessing about that.
In fact, better than private mail: http://poetry.puzzling.org/cBanana.pyd -Andrew.

Andrew Bennetts wrote:
In fact, better than private mail: http://poetry.puzzling.org/cBanana.pyd
Don't bother - cBanana is not used by Twisted at all at this time, since we changed the banana protocol in 0.14, and haven't yet updated cBanana.

Benjamin Schollnick wrote:
It's trying to compile cBanana and failing since you don't have Visual C++. However, cBanana is currently broken and will not be used by Twisted in any case, so this doesn't matter. We really out to distribute win32 .exe installers generated by distutils...

On Mon, Feb 18, 2002 at 06:34:33PM -0500, Benjamin Schollnick wrote:
Folks,
I've got some questions, with windows usage of Twisted Matrix...
I use Twisted under Windows, so I may be able to offer some help..
CL.EXE is a command line program that comes with MS Visual C++... setup.py is basically trying to compile a C extension module. I can send you a binary for that file if you don't have MS VC++ installed, otherwise run VCVARS32.BAT and try again.
This is easily fixed with short bash script, but I agree, this is annoyed. I'd suggest the Twisted developers look at how, e.g. PyChecker or Teud does it (various scripts get installed in %PYTHONPATH%/scripts/<foo>.bat).
I don't use the twisted.web stuff (yet ;), so I can't offer any help here :(
Yeah, -n uses os.fork, which is not available under Windows. You probably need to use NT services instead... Alternatively, consider using the cygwin version of Python -- it is closer to the unix version, and so os.fork will work. Also, it comes with gcc, so cbanana would compile correctly. Unfortunately, I don't think it can interoperate with the Win32 extensions (at least, not that I know of).
I guest a better question is, has twistedmatrix been tested under Windows? It really seems to be unix centric in it's programming...
It basically works. The other problem to watch out for is that Protocol.connectionFailed won't trigger unless you specify a timeout for your tcp.Client, because select works slightly differently on Windows. Incidentally, I'm not using the twistd stuff *at all* (I don't yet understand the need for it under Windows, but then I don't even know exactly what it's meant to do...). Instead, I'm using this little file: --- ServerFramework/Service.py --- import win32serviceutil, win32service """Example use of this module: from ServerFramework.Service import Service, main import ExampleServer class ExampleServerService(Service): _svc_name_ = "ExampleServerService" _svc_display_name_ = "My Example Server Service" main = ExampleServer.main if __name__ == '__main__': main(ExampleServerService) """ try: import twisted except ImportError: print "Twisted Python must be installed to run this service" raise class Service(win32serviceutil.ServiceFramework): """I am a template service for ServerFramework servers. You should subclass me and override the following attributes: _svc_name_ -- see win32serviceutil docs _svc_display_name_ -- see win32serviceutil docs main -- function that starts your server You can also override: logFile -- filename for where debug messages will be saved (default: c:/<_svc_name_>.log) """ _svc_name_ = "UnnamedServer" _svc_display_name_ = "My UNNAMED Server" main = None logFile = None def __init__(self, *args): win32serviceutil.ServiceFramework.__init__(self, *args) if not self.logFile: self.logFile = 'c:/%s.log' % (self._svc_name_,) def SvcDoRun(self): from twisted.python.log import startLogging startLogging(open(self.logFile,'a')) # Call main, note that it is not a method of this class, so we use # self.main.im_func() instead of self.main(). self.main.im_func() def SvcStop(self): self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING) from twisted.internet.main import shutDown shutDown() def main(svc): win32serviceutil.HandleCommandLine(svc) if __name__ == '__main__': print "This is a library module, and should not be executed." --- It basically wraps up the functionality of the win32serviceutil in a convenient way for Twisted servers. Once you've used it as shown in the example, just run it from the commandline -- it's self explantory (it uses Mark Hammond's win32serviceutil.HandleCommandLine function to let you install the service). I'm not sure if the self.main.im_func trick will work on older Pythons; I use 2.2. I hope this is of some use to you. -Andrew.

On Mon, 2002-02-18 at 18:24, Andrew Bennetts wrote:
Hey Andrew, thanks for answering that question. You beat my response, almost as I was sending it ;) The Twisted team really needs a dedicated windows person. Would you be interested in taking up that mantle and making some of these issues go away in the central distribution? It sounds like you've got a smoother windows work-flow than I have here. -- "Cannot stand to be one of many -- I'm not what they are." -Guster, "Rocketship" glyph lefkowitz; ninjaneer, freelance demiurge glyph @ [ninjaneering|twistedmatrix].com

On Mon, Feb 18, 2002 at 06:52:56PM -0600, Glyph Lefkowitz wrote:
Hey Andrew, thanks for answering that question. You beat my response, almost as I was sending it ;)
Heh.
Most of my time at work is now spent coding Twisted servers, which is why I'm familiar with all these issues. I'd love to take up that mantle, but I rarely run Windows at home... so I won't commit myself fully yet, but I certainly would like to see how much I can help. -Andrew.

On Tue, Feb 19, 2002 at 11:24:35AM +1100, Andrew Bennetts wrote:
Anyone attempting to do anything under windoze should look at the cygwin tools. the cygwin bash shell automaticly executes things with #!/... lines for you. -- ---------------------------------------------------------------------- ABO: finger abo@minkirri.apana.org.au for more info, including pgp key ----------------------------------------------------------------------

on 2/18/02 7:24 PM, Andrew Bennetts at andrew-twisted@puzzling.org wrote:
No Visual C++.... If you don't mind sending it, I would appreciate it... This really needs to be noted.... I admit, I didn't search around too much, but I didn't see anything mentioning that it required a C/C++ compiler... (How about a precompiled Windows binary? Or having Distutils install the precompiled binary)....
That's what I figured.... (By NT Services, you mean the services listed from control panels --> services?) But I dislike the NT services.... I've never seen a service get installed, that will "uninstall" properly... (Usually add/remove program doesn't uninstall the service) I prefer to run the console......reminds me a little bit more of a syslog window... >g<
I use the Win32 services, include ODBC... So that's not really a useable workaround...
Is the following code "temporary".... It's considered a service while running, but doesn't get installed in the services control panel? It looks interesting, but I don't want to register the app as a "true" service... As I mentioned before, I can't find a reliable way to remove a service, without registry hacking... -- Benjamin

On Mon, 2002-02-18 at 21:15, Benjamin Schollnick wrote:
cBanana is an optional C implementation of the regular pure-python banana. You don't need it. I guess for now you can just hack setup.py and comment out the section that looks like this: setup_args['ext_modules'] = [ Extension("twisted.spread.cBanana", [extpath("twisted/spread/cBanana.c")]), ]
It doesn't require one, but apparently the setup scripts barf if you don't have one. -- Chris Armstrong << radix@twistedmatrix.com >> http://twistedmatrix.com/users/carmstro.twistd/

On Mon, Feb 18, 2002 at 09:15:41PM -0500, Benjamin Schollnick wrote:
I'll send it in a private mail. It's compiled for Python 2.2 on Win2k; it should be portable to any Win32, but I'm just guessing about that.
I *think* what's supposed to happen is for it to fallback to a pure Python implementation. It's part of the twisted.spread package; if you're not using spreadable computing, it doesn't really matter anyway.
Yep.
These ones will :) If you've got an ExampleService.py which contains the example below, you can do: ExampleService.py install ExampleService.py start ExampleService.py stop ExampleService.py remove As well as the usual stuff in the control panel... see the docs for the win32serviceutil module for details.
I prefer to run the console......reminds me a little bit more of a syslog window... >g<
Yeah, but that requires you to be logged in for your server to run. But I know what you mean. Have you seen simpleserv.py in the docs/example directory that came with Twisted? It doesn't require mktap or twistd, it just runs standalone -- my servers all run like that, or optionally as a service via that module I posted below. I generally debug them by running them at the command line, and then install them as a service when I think they're ready to run without me needing to watch them :)
Yeah. Are you using ODBC via COM (i.e. by calling win32com.client.Dispatch("ADODB.Connection"))? If so, you will probably want to use the mx.ODBC library with Twisted instead, as it can automatically work with the twisted.enterprise stuff (with a tiny amount of hackery).
No, it's a full-blown service. It can be installed as a service, it can be set to start a startup, etc.
Don't worry, that's already taken care of... this is Python, it plays nice :) I'll be happy to elaborate further on any of this if you like. Perhaps I should whip up an example of installing and using simpleserv.py as a service? -Andrew.

On Tue, Feb 19, 2002 at 01:55:43PM +1100, Andrew Bennetts wrote:
I'll send it in a private mail. It's compiled for Python 2.2 on Win2k; it should be portable to any Win32, but I'm just guessing about that.
In fact, better than private mail: http://poetry.puzzling.org/cBanana.pyd -Andrew.

Andrew Bennetts wrote:
In fact, better than private mail: http://poetry.puzzling.org/cBanana.pyd
Don't bother - cBanana is not used by Twisted at all at this time, since we changed the banana protocol in 0.14, and haven't yet updated cBanana.

Benjamin Schollnick wrote:
It's trying to compile cBanana and failing since you don't have Visual C++. However, cBanana is currently broken and will not be used by Twisted in any case, so this doesn't matter. We really out to distribute win32 .exe installers generated by distutils...
participants (7)
-
abo@minkirri.apana.org.au
-
Andrew Bennetts
-
Andrew Bennetts
-
Benjamin Schollnick
-
Christopher Armstrong
-
Glyph Lefkowitz
-
Itamar Shtull-Trauring