Re: [Pythonmac-SIG] py2app & multiprocessing
Hi again, I think using multiprocessing should be the way to go, so that you use twisted for the main event loop in one process, and wx for the main event loop in the other. In a simple way, you can also build your own custom multiprocessing tool. You just need one system calls, and one network connection. (for controlling the other process) Like this : pid = os.fork() if pid == 0: # child # no need to call os.execv(), since your code is in python # open TCP socket as a receiver # start event loop else: # child child_pid = pid # open TCP socket as a sender # start event loop ...and no, I am not using twistd. For now, I prefer not to rely on any other executable, and start the main loop in my app. reactor.run() You can also look at some other free software I am working on : * Lunch : https://svn.sat.qc.ca/trac/postures/wiki/Lunch * ToonLoop : http://www.toonloop.com/ * Miville : https://svn.sat.qc.ca/trac/miville * RawMaterials : https://svn.sat.qc.ca/trac/rawmaterials They all use twisted, but RawMaterials is the only for Mac. (the code is rather old and should be updated.) ToonLoop should be ported to mac with a app bundle soon. It is a live stop motion software, which is also the topic of my master. What does your application do ? Is it free software as well ? Ciao, -- Alexandre Quessy http://alexandre.quessy.net/ 2009/8/20 Gabriel Rossetti : > Hello Alexandre, > > His is how I had it before, but it was causing me problems and I was told > that it's better tu run them in separate threads. Do you use twistd (.tac > files)? I'll have a look at your application, thanks! > > Gabriel > > Alexandre Quessy wrote: >> >> Hi everyone, >> I use Twisted everyday, and have worked on a wx GUI for an application >> using it. We also use Py2App to bundle it up. It works flawlessly. I >> use the Twisted main loop, which controls the wx events loop. >> >> To make both of them work together, you need to do the following : >> >> {{{ >> from twisted.internet import wxreactor >> wxreactor.install() >> }}} >> >> You can check our RawMaterials application since it is free software. >> It has a lot of dependencies, so it is rather difficult to build. >> https://svn.sat.qc.ca/trac/rawmaterials/browser/trunk/src/RawMaterials.py >> We use a shell script to build and copy things in the .app : >> https://svn.sat.qc.ca/trac/rawmaterials/browser/trunk/src/make_app.sh >> >> I would say the problem is probably more about multiprocessing than wx >> and twisted. Using subprocess, or pexpect, or commands might be a >> better idea. >> >> a >> >> 2009/8/14 Gabriel Rossetti : >> >>> >>> Christopher Barker wrote: >>> >>>> >>>> Gabriel Rossetti wrote: >>>> >>>>> >>>>> no SSH, nothing) and I have to had reboot it. It uses a combination of >>>>> Twisted and wxPython and is rather large, so I don't know where this >>>>> comes >>>>> from, it could be wx, twisted or the two together. >>>>> >>>> >>>> It's probably not wx -- it is used a fair bit on Macs. >>>> >>>> I don't know how much Twisted is used on the Mac. It might be worth >>>> asking >>>> on a Twisted list. Also, have you tried just a simple Twisted app on its >>>> own? >>>> >>>> And yes, I suppose the two together could be an issue. >>>> >>> >>> Yes actually, it was the two together. I used something someone had told >>> me >>> about a some time ago, that is to use the wx eventloop as the main >>> eventloop >>> and have twisted's run in a separate thread, it now works fine on Mac. >>> >>> I'm still working on the pz2app part though, I'll kep everyone updated. >>> >>> Gabriel >>> >>> >>>> >>>> Oh, and do you have these problems running without py2app? >>>> >>>> >>>>> >>>>> Popen could not find my files when using py2app, >>>>> >>>> >>>> This should be a simple path issue -- a few judicious print statements >>>> should help here. >>>> >>>> >>>>> >>>>> even though they were in the same >>>>> >>>>> directory as the main exec. I even tried putting the execs in the >>>>> resource dir but no luck, >>>>> >>>> >>>> hmm -- I think that is indeed where the working dir is set by py2app >>>> when >>>> starting op. try: >>>> >>>> print os.getcwd() >>>> >>>> you can look in the "Console" app to see stuff printed to stdout. >>>> >>>> -Chris >>>> >>>> >>> >>> ___ >>> Pythonmac-SIG maillist - pythonmac-...@python.org >>> http://mail.python.org/mailman/listinfo/pythonmac-sig >>> >>> >> >> >> >> > ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
Re: [Pythonmac-SIG] py2app & multiprocessing
Hi everyone, I use Twisted everyday, and have worked on a wx GUI for an application using it. We also use Py2App to bundle it up. It works flawlessly. I use the Twisted main loop, which controls the wx events loop. To make both of them work together, you need to do the following : {{{ from twisted.internet import wxreactor wxreactor.install() }}} You can check our RawMaterials application since it is free software. It has a lot of dependencies, so it is rather difficult to build. https://svn.sat.qc.ca/trac/rawmaterials/browser/trunk/src/RawMaterials.py We use a shell script to build and copy things in the .app : https://svn.sat.qc.ca/trac/rawmaterials/browser/trunk/src/make_app.sh I would say the problem is probably more about multiprocessing than wx and twisted. Using subprocess, or pexpect, or commands might be a better idea. a 2009/8/14 Gabriel Rossetti : > Christopher Barker wrote: >> >> Gabriel Rossetti wrote: >>> >>> no SSH, nothing) and I have to had reboot it. It uses a combination of >>> Twisted and wxPython and is rather large, so I don't know where this comes >>> from, it could be wx, twisted or the two together. >> >> It's probably not wx -- it is used a fair bit on Macs. >> >> I don't know how much Twisted is used on the Mac. It might be worth asking >> on a Twisted list. Also, have you tried just a simple Twisted app on its >> own? >> >> And yes, I suppose the two together could be an issue. > > Yes actually, it was the two together. I used something someone had told me > about a some time ago, that is to use the wx eventloop as the main eventloop > and have twisted's run in a separate thread, it now works fine on Mac. > > I'm still working on the pz2app part though, I'll kep everyone updated. > > Gabriel > >> >> Oh, and do you have these problems running without py2app? >> >>> Popen could not find my files when using py2app, >> >> This should be a simple path issue -- a few judicious print statements >> should help here. >> >> > even though they were in the same >>> >>> directory as the main exec. I even tried putting the execs in the >>> resource dir but no luck, >> >> hmm -- I think that is indeed where the working dir is set by py2app when >> starting op. try: >> >> print os.getcwd() >> >> you can look in the "Console" app to see stuff printed to stdout. >> >> -Chris >> > ___ > Pythonmac-SIG maillist - pythonmac-...@python.org > http://mail.python.org/mailman/listinfo/pythonmac-sig > -- Alexandre Quessy http://alexandre.quessy.net/ ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
Re: [Pythonmac-SIG] run python script on another computer's terminal (LAN)
Hi! Do you want to see the output in the remote computer's display? If so, screen might help you. You could also use the "open" command to open the Terminal supplying it a command. The "xterm" terminal in X11 is nice for that. (or better: rxvt) If you just want to get the resulting output, use either subprocess, commands or pxssh ! Anyways, ssh is the way to go. You can look at my "lunch" script for inspiration. https://svn.sat.qc.ca/trac/postures/wiki/Lunch a 2009/8/11 Nicholas Riley : > On Tue, Aug 11, 2009 at 03:35:21PM -0400, Chris Rebert wrote: >> What is "eppc://"? I can't seem to find anything on it. > > It's remote Apple Events (previously known as "Program Sharing"). You > can turn it on in Sharing System Preferences. > > Unfortunately in OS X, remote Apple Events are very flaky. I'd > suggest the original questioner just use SSH, either with the built-in > OpenSSH through subprocess or with paramiko > (http://www.lag.net/paramiko/). I've replaced all my use of remote > Apple Events with it. > > -- > Nicholas Riley > ___ > Pythonmac-SIG maillist - pythonmac-...@python.org > http://mail.python.org/mailman/listinfo/pythonmac-sig > -- Alexandre Quessy http://alexandre.quessy.net/ ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
Re: [Pythonmac-SIG] Fink vs MacPorts vs Framework
Hi ! Seems to me there are a lot of python packages that are available through the MacPorts. In the built-in framework, there are only a few basic packages. Fink gives the same benefits than MacPorts, but there might be fewer packages available though it than through MacPorts. That's why I use MacPorts. Is this right ? a 2009/6/30 Dan Ross : > I currently use a Framework of 2.6.2 for my Python work but I always see a > lot of posts about using Fink or MacPorts builds. > > Could anyone shed some light on why they use these rather than a Framework? > > Advantages/disadvantages? > > Thanks, > > Dan > > ___ > Pythonmac-SIG maillist - pythonmac-...@python.org > http://mail.python.org/mailman/listinfo/pythonmac-sig > -- Alexandre Quessy http://alexandre.quessy.net/ ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
Re: [Pythonmac-SIG] Unable to run python application
Hi beegee ! "/* */" as a comments delimiter is not supported in Python. The simplest way to create comments in Python is to begin each comment line with a #. You can also use triple-delimited strings for documentation. a 2009/4/15 Ned Deily : > In article > <7122b8730904151138o3a0cb401hbfaba2d3babfd...@mail.gmail.com>, > beegee beegee wrote: >> Hi there, I am a beginner in python and I wrote a simple program >> called first.py (using aquamacs) and stored it on my desktop. >> I opened IDLE and wrote the command python first.py >> and I got a syntax error with 'first' being highlighted >> I have a mac os 10.4.11, python 2.6.1 on IDLE >> and I also used the aquamacs compiler for python > > When you are in IDLE, use the Open command from the File menu bar item > to open a python file in a new window. With focus on the new window, > the menu bar will change to include a Run menu. > > -- > Ned Deily, > ...@acm.org > > ___ > Pythonmac-SIG maillist - pythonmac-...@python.org > http://mail.python.org/mailman/listinfo/pythonmac-sig > -- Alexandre Quessy http://alexandre.quessy.net/ ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
[Pythonmac-SIG] Building an app with dependencies
Hi all, I am trying to build a Python Mac OS X application that has quite a lot of dependencies. We rely on wx, appscript, objc, zope, twisted and more. Below I provide my setup.py script. I am trying to use py2app (version py2app-0.3.6-py2.4.egg) as mentionned on the page http://svn.pythonmac.org/py2app/py2app/trunk/doc/index.html#uninstalling-py2app-0-2-x-or-earlier . When I try to build it I get the following error : "running py2app """ Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/py2app-0.3.6-py2.4.egg/py2app/build_app.py", line 548, in _run self.run_normal() File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/py2app-0.3.6-py2.4.egg/py2app/build_app.py", line 600, in run_normal mf = self.get_modulefinder() File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/py2app-0.3.6-py2.4.egg/py2app/build_app.py", line 508, in get_modulefinder debug=debug, File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/modulegraph-0.7-py2.4.egg/modulegraph/find_modules.py", line 243, in find_modules File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/modulegraph-0.7-py2.4.egg/modulegraph/find_modules.py", line 179, in find_needed_modules TypeError: unsubscriptable object > /Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/modulegraph-0.7-py2.4.egg/modulegraph/find_modules.py(179)find_needed_modules() (Pdb) interrupted" """ below is my complete setup.py script. Anyone has an idea on why i get this ? Is one of my arguments of a bad type ? Also, is there an alternative to listing the whole list of packages and modules to be included in the app? I am using Tiger, but I would like this to work also on Leopard, if possible. Thanks !! -- Alexandre Quessy http://alexandre.quessy.net/ import sys from distutils.core import setup import py2app # - # path: for p in ['../lib','../deps/eggs','../deps/suds-0.2.8']: sys.path.append(p) # - # packages are directories of python modules with an __init__.py file. ALLPACKAGES= ['wx','suds','appscript','mactypes','twisted','restclient','xml','objc','QTKit','AppKit'] # modules are python files. ALLMODULES= ['feedparser','ConfigParser','urlparse','htmllib', 'formatter','HTMLParser','pprint', 'os','time','copy','subprocess','glob','urllib','md5','urllib2','sys','shelve','mactypes'] # we would be better to put those in a package: MOREMODULES = ['RawItem','RawChannel','RawConfig','RawSerializable','RawFilter','RawItemsManager','RawMobileMuse','RawSiftAggregator','RawStateSaver','RawTextConvert','saveQuicktimeStream','LivecastSupport','RawHypertextImageExtractor','wxSupport','lib_rawmaterials','osc_protocol','RawHypertextStripper','RawYoutubeRipper'] for m in MOREMODULES: ALLMODULES.append(m) print "" print "ALLMODULES:",ALLMODULES print "ALLPACKAGES:",ALLPACKAGES print "" # - # Build the .app file setup( options={ 'py2app':{ 'iconfile':'resources/RawMaterials.icns', 'packages':ALLPACKAGES, 'includes':ALLMODULES, 'site_packages':True, 'resources':['resources/License.txt'], 'plist':dict( CFBundleName = "RawMaterials", CFBundleShortVersionString = "0.3.0", # must be in X.X.X format CFBundleGetInfoString = "RawMaterials 0.3.0", CFBundleExecutable = "RawMaterials", CFBundleIdentifier = "ca.qc.sat.rawmaterials", ) }, }, app=[ 'RawMaterials.py' ] ) ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
[Pythonmac-SIG] Sniff Wifi jpegs, etc.
hi ! I have heard somewhere that it was possible to dump TCP packets in order to get all the images that are sent and received through a wifi network. Is this possible using Python ? Thanks ! aalex ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig