From mark at microenh.com Wed May 13 18:56:13 2009 From: mark at microenh.com (Mark Erbaugh) Date: Wed, 13 May 2009 12:56:13 -0400 Subject: [CentralOH] IDLE on Mac Message-ID: <54CA3871-7F59-4631-8D51-9A47ACD9B0F7@microenh.com> I recently began working on a Mac. I was able to configure an application launcher for IDLE. However, when I open a .py file with this launcher, it sets the current working directory to my Documents folder. Under Windows and Linux, the working directory would be the directory containing the .py file and I would like the Mac to do the same. I found the idlemain.py file inside the IDLE launcher and see where it is setting the current working directory, but knowing next to nothing about how the Mac actually launches programs, I don't know how to get the folder of the .py file. I did look at sys.argv being passed to idlemain.py, but it doesn't include the filename of the .py file. Is it possible to create an IDLE launcher that will set the working directory to the folder containing the .py file that I opened? Thanks, Mark From asb.bush at gmail.com Thu May 28 18:14:03 2009 From: asb.bush at gmail.com (Aaron Bush) Date: Thu, 28 May 2009 12:14:03 -0400 Subject: [CentralOH] Help with Twisted Framework Message-ID: <5a8f2d170905280914m453378bdv2a8f29287dbfdc68@mail.gmail.com> Does anyone on the list have experience using the twisted framework? I am looking to pick you brain about the 'best' way to write an application using this framework. Here is the msg that I posted to the twisted mail list: I have just started to look at the Twisted framework and would like to put it to use for a new project I am working on. Not being very familiar with the framework and fairly new to Python in general I would like to ask a design/architecture question. (I have written similar applications in C but would prefer to start this in the right direction and not write Python like C.) The application has the following model: Many clients connect to the Application and prefer to leave the connection open. They will send messages across this connection. They will expect to get a message back at some point later, they do not wait for a response (async). The clients are already coded (legacy) and just need to send their proprietary protocol to the new Application (written using Twisted). The Twisted application will take the data from the clients and do some transformation on it then send the message on to another server (3rd party). This connection to "another" server must be a single connection, not one connection per client. This connection should also be persistent and not opened/closed for each client message sent. Ideally if the 3rd party server is down then I would also not accept client connections as the messages are time sensitive and should not be stored and forwarded. At some point the 3rd part will send a message back and the Application will route it back to the original source. Basically request/reply pattern. I have been reading through the archives and the twisted docs and have also looked over the Hex-dump port-forwarding recipe but not found anything that explains how to use twisted for this model. Hex-dump is close but opens/closes the connection to the server on each client connection. I am thinking that there will be two Factories [and two protocols: 1) for clients and 2) for 3rd party]. I am not sure how to best establish both the listening factory and the client to 3rd party factory. Once they are established what is the preferred way in Twisted to pass a message from one protocol to another? Any pointers or sample code that you can offer is greatly appreciated. I would really like to cook this in Twisted and not go back to the C way. Thanks, -ab -------------- next part -------------- An HTML attachment was scrubbed... URL: From nludban at osc.edu Thu May 28 18:56:48 2009 From: nludban at osc.edu (Neil Ludban) Date: Thu, 28 May 2009 12:56:48 -0400 Subject: [CentralOH] Help with Twisted Framework In-Reply-To: <5a8f2d170905280914m453378bdv2a8f29287dbfdc68@mail.gmail.com> References: <5a8f2d170905280914m453378bdv2a8f29287dbfdc68@mail.gmail.com> Message-ID: <20090528125648.d9d5a03f.nludban@osc.edu> On Thu, 28 May 2009 12:14:03 -0400 Aaron Bush wrote: > Does anyone on the list have experience using the twisted framework? > > I am looking to pick you brain about the 'best' way to write an application > using this framework. > > > Here is the msg that I posted to the twisted mail list: > > > I have just started to look at the Twisted framework and would like to put > it to use for a new project I am working on. Not being very familiar with > the framework and fairly new to Python in general I would like to ask a > design/architecture question. (I have written similar applications in C but > would prefer to start this in the right direction and not write Python like > C.) IMO Twisted is just a C framework design forced into Python. To be fair, Python threading became reliable about the time I was first investigating it, and I never looked at Twisted again. If I needed a robust framework capable of handling hundreds or thousands of simultaneous connections, I'd give it another try. The Python standard library includes a much simpler C-like library: http://docs.python.org/library/asyncore.html as well as a more OOD library: http://docs.python.org/library/socketserver.html From kartic.krish at gmail.com Sun May 31 17:05:53 2009 From: kartic.krish at gmail.com (Kartic Krishnamurthy) Date: Sun, 31 May 2009 08:05:53 -0700 Subject: [CentralOH] Help with Twisted Framework In-Reply-To: <20090528125648.d9d5a03f.nludban@osc.edu> References: <5a8f2d170905280914m453378bdv2a8f29287dbfdc68@mail.gmail.com> <20090528125648.d9d5a03f.nludban@osc.edu> Message-ID: <52ffb22c0905310805s39c7fb0albb7bd2cdd2f7234e@mail.gmail.com> On Thu, May 28, 2009 at 9:56 AM, Neil Ludban wrote: > On Thu, 28 May 2009 12:14:03 -0400 > Aaron Bush wrote: >> Does anyone on the list have experience using the twisted framework? >> >> I am looking to pick you brain about the 'best' way to write an application >> using this framework. Upon reading your requirements, it appears that you need some sort of Reverse HTTP or a COMET-style communication mechanism. If you want to use Twisted primarily (though to do r-HTTP or COMET, you don't /need/ Twisted), you can give orbited (http://orbited.org/) a shot or you could roll out your own. You might also be interested in the "ptth" proposal ;) > IMO Twisted is just a C framework design forced into Python. ?To be > fair, Python threading became reliable about the time I was first > investigating it, and I never looked at Twisted again. ?If I needed > a robust framework capable of handling hundreds or thousands of > simultaneous connections, I'd give it another try. > > The Python standard library includes a much simpler C-like library: > ? ? ? ?http://docs.python.org/library/asyncore.html > as well as a more OOD library: > ? ? ? ?http://docs.python.org/library/socketserver.html I would recommend that you look at Eventlet (based on greenlet: http://pypi.python.org/pypi/greenlet). http://wiki.secondlife.com/wiki/Eventlet (prefer using the Mercurial repo version). And there is a good end-to-end example of a chat server: http://www.evilchuck.com/2008/02/toy-chat-server-with-eventlet-and-mulib.html (You might have to make some modifications, just in case the example code is incompatible with eventlet 0.8.11-pre) If you like what you see, please join the eventlet mailing list and you will definitely get help. Thanks, +Kartic