On 13/03/11 1:30 AM, Ronald Oussoren wrote: > On 12 Mar, 2011, at 6:36, Brendan Simon (eTRIX) wrote: >> I am running on OS 10.6, but my app needs to run on 10.4, 10.5 and >> 10.6 (PPC and Intel). >> I am using Python 2.5.4. >> >> I don't think your test would work if you were to use a custom url, >> rather than 'file:' and a filename/path. >> >> If I ran the command "open myurl:mycommand" from the terminal, and my >> plist has configured 'myurl' as a recognised url, then the app bundle >> should fire up. It may need to be in the Application folder for it >> to work ?? >> >> I expect 'myurl:mycommand' to be appended to sys.argv. >> >> Here is a snippet of my py2app setup.py. >> >> # A custom plist for letting it associate with a URL protocol. >> URLTYPES = [ >> { >> 'CFBundleURLName' : "MyUrl", >> 'CFBundleURLSchemes' : [ "myurl" ] >> } >> ] >> >> Plist = dict( >> NSAppleScriptEnabled = 'YES', >> CFBundleIdentifier = 'com.myurl', >> LSMinimumSystemVersion = "10.4", >> CFBundleURLTypes = URLTYPES >> ) >> >> OPTIONS = { >> 'argv_emulation' : True, >> 'iconfile' : 'images/myurl.icns', >> 'plist' : Plist, >> } >> >> Hope that helps, > > It sure does, this helped me to reproduce the issue. I've added another > > From your original e-mail: > >> + 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') > > Is the decode really necessary? With this one of the times in sys.argv > will be a Unicode string rather than a byte string. I'd therefore > prefer to not have the decode call. > > I've added your patch without the decode call to my repository, > including some tests that ensure that future versions won't accidently > break the code. > > Thank you for the patch,
My pleasure re the patch. It's nice to be able to contribute back to the open-source community (even if it is just a tiny bit). I did the original patch back in 2009. I don't know why the decode('utf8') is in there. I suspect it was a copy-n-paste from somewhere, either some from some code I found via googling or from some code posted on this mailing list. I'm more than happy to remove the decode it as I presume the application itself can do that if necessary. Cheers, Brendan. _______________________________________________ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG