Below is my patch to get URLs/URIs to be added to sys.argv when an app is opened via the Launcher.
It should be applied to: /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/py2app/bootstrap/argv_emulation.py Can this patch *please* be integrated (please modify if necessary) in to 0.5.3 release !! eg. You can test with "open myapp myurl:test" The sys.argv attribute should include "myurl:test" :) NOTE: for some reason the AppleEvent constants kAEInternetSuite and kAEISGetURL does not work as they are set to 'gurl' (lowercase). However using 'GURL' does work :) Cheers, Brendan. --- argv_emulation_orig.py 2011-03-11 08:49:13.000000000 +1100 +++ argv_emulation.py 2011-03-11 09:47:00.000000000 +1100 @@ -7,7 +7,8 @@ import traceback from Carbon import AE from Carbon.AppleEvents import kCoreEventClass, kAEOpenApplication, \ - kAEOpenDocuments, keyDirectObject, typeAEList, typeAlias + kAEOpenDocuments, keyDirectObject, typeAEList, typeAlias, \ + kAEInternetSuite, kAEISGetURL, typeChar from Carbon import Evt from Carbon import File from Carbon.Events import highLevelEventMask, kHighLevelEvent @@ -23,10 +24,14 @@ self.__runapp) AE.AEInstallEventHandler(kCoreEventClass, kAEOpenDocuments, self.__openfiles) + #AE.AEInstallEventHandler(kAEInternetSuite, kAEISGetURL, self.__geturl) + AE.AEInstallEventHandler('GURL', 'GURL', self.__geturl) def close(self): AE.AERemoveEventHandler(kCoreEventClass, kAEOpenApplication) AE.AERemoveEventHandler(kCoreEventClass, kAEOpenDocuments) + #AE.AERemoveEventHandler(kAEInternetSuite, kAEISGetURL) + AE.AERemoveEventHandler('GURL', 'GURL') def mainloop(self, mask = highLevelEventMask, timeout = 1*60): # Note: this is not the right way to run an event loop in OSX or @@ -91,6 +96,20 @@ self._quit() + def __geturl(self, requestevent, replyevent): + try: + listdesc = requestevent.AEGetParamDesc(keyDirectObject, typeAEList) + for i in range(listdesc.AECountItems()): + desc = listdesc.AEGetNthDesc(i+1, typeChar)[1] + url = desc.data.decode('utf8') + sys.argv.append(url) + except Exception, e: + print "argvemulator.py warning: can't unpack a GetURL event" + import traceback + traceback.print_exc() + + self._quit() + return ArgvCollector() def _argv_emulation(): _______________________________________________ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG