Re: [Pythonmac-SIG] status pyobjc on osx
On Thu, Jun 14, 2012 at 07:03:33AM -0700, Ronald Oussoren wrote: I don't understand what you mean when you say that the included python libs no longer include pyobjc. Pyobjc has never been part of the stdlib. My original assumption was that he might have been talking about /System/Library/Frameworks/Python.framework/Versions/*/Extras/lib/python/PyObjC/, but that's still present in the latest OS X versions. So, no idea... -- Nicholas Riley njri...@illinois.edu ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG
Re: [Pythonmac-SIG] PyCon..
On Sat, Mar 10, 2012 at 04:56:26PM -0800, Ronald Oussoren wrote: On 10 Mar, 2012, at 15:05, Chris Barker wrote: On Tue, Feb 14, 2012 at 7:23 AM, Ned Deily n...@acm.org wrote: I'm planning to sprint through Thursday. I've added a Mac OS X Support project to the PyCon sprint page. Feel free to add topics and add yourself. Hope to see you all there! I'm at PyCon (with a laptop/external drive that has 10.6, 10.7 and 10.8 installed, so I can do some testing across OSes) and should be able to spend a day or two sprinting on MacPython. -- Nicholas Riley njri...@illinois.edu ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG
Re: [Pythonmac-SIG] Any chance of getting this to run on OSX?
On Sun, Feb 26, 2012 at 10:50:27PM +0800, Leo wrote: There is this simple python script: http://coderstalk.blogspot.com/2010/02/create-network-interfaces-list-using.html Any idea how to fix it so that it runs on OSX? Thanks. Leo That script is an excellent example of how not to do things; it makes assumptions about constant values and structure layout that may not hold true on one operating system, much less between operating systems. You are almost certainly better off using another mechanism. What interface information are you trying to obtain? -- Nicholas Riley njri...@illinois.edu ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG
Re: [Pythonmac-SIG] locale module missing function
On Sun, Jan 29, 2012 at 08:32:38PM +0100, mk0...@towb.de wrote: I need locale.bindtextdomain (to influence PyGTK) but in the Python supplied with Snow Leopard it doesn't exist!? OS X does not provide gettext. You'll need to compile your own Python against the version of gettext PyGTK is using, or use another method of calling bindtextdomain (e.g. ctypes). -- Nicholas Riley njri...@illinois.edu ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG
Re: [Pythonmac-SIG] Ownership of installed Python on Mac
On Tue, Aug 09, 2011 at 11:35:11PM +0100, Michael Foord wrote: On 9 August 2011 22:42, Ned Deily n...@acm.org wrote: Hmm... for 3.2 and 2.7 I was using Activestate installers not Python.org ones - so perhaps it's their bug (in which case sorry for the noise). Nope - this is from a new Mac mini that shipped with Lion and has not had any non-system Pythons installed: bookworm% ls -ld /Library/Python/*/site-packages drwxr-xr-x 4 root wheel 136 Jun 25 08:05 /Library/Python/2.3/site-packages drwxr-xr-x 3 root wheel 102 Jul 2 17:08 /Library/Python/2.5/site-packages drwxr-xr-x 3 root wheel 102 Jul 2 17:08 /Library/Python/2.6/site-packages drwxr-xr-x 3 root wheel 102 Jul 2 17:08 /Library/Python/2.7/site-packages I'd say if any of the python.org or ActiveState Python installers mess with these directories' ownership or permissions, they're doing something wrong. While the contents of these directories is up to the user, their permissions are part of the OS install. Many folders in the System domain that were previously owned by the admingroup are now owned by the wheel group. This isn't quite right (the System domain means /System); it's the part a bit later that says All subdirectories within /Library now have mode 755 (writable only by root) permissions instead of mode 775 (writable by the admin group) except... [a bunch of directories that do not include Python]. Anyway, the workaround is simple enough - and yeah, still pretty necessary to install pip/virtualenv themselves. -- Nicholas Riley njri...@illinois.edu ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG
Re: [Pythonmac-SIG] py2app looking for ae.so in the wrong place
On Mon, Jan 03, 2011 at 09:27:09PM -0600, Nicholas Riley wrote: I finally upgraded my iMac from 10.5 to 10.6 and tried to recompile one of my py2app apps with the system Python 2.6.1 and current py2app. The application uses appscript, but for some reason it's trying to import ae.so from /System: [...] For anyone else who runs into a similar problem - I didn't get any responses on this so I just uninstalled the current py2app and went back to the 10.6-bundled version, which worked fine. -- Nicholas Riley njri...@illinois.edu ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG
[Pythonmac-SIG] py2app looking for ae.so in the wrong place
I finally upgraded my iMac from 10.5 to 10.6 and tried to recompile one of my py2app apps with the system Python 2.6.1 and current py2app. The application uses appscript, but for some reason it's trying to import ae.so from /System: % dist/StreamVision.app/Contents/MacOS/StreamVision Traceback (most recent call last): File /Users/nicholas/Documents/Development/StreamVision/dist/StreamVision.app/Contents/Resources/__boot__.py, line 31, in module _run('StreamVision.py') File /Users/nicholas/Documents/Development/StreamVision/dist/StreamVision.app/Contents/Resources/__boot__.py, line 28, in _run execfile(path, globals(), globals()) File /Users/nicholas/Documents/Development/StreamVision/dist/StreamVision.app/Contents/Resources/StreamVision.py, line 4, in module from appscript import app, k, its, CommandError File appscript/__init__.pyc, line 8, in module File aem/__init__.pyc, line 5, in module File aem/ae.pyc, line 18, in module File aem/ae.pyc, line 15, in __load ImportError: '/System/Library/Frameworks/Python.framework/Versions/Current/lib/python2.6/lib-dynload/aem/ae.so' not found 2011-01-03 21:23:47.306 StreamVision[82885:903] StreamVision Error ae.so is indeed in the app package: % ls **/ae.so dist/StreamVision.app/Contents/Resources/lib/python2.6/lib-dynload/aem/ae.so Any ideas what's going on here? Everything worked fine on 10.5 with Python 2.5. -- Nicholas Riley njri...@illinois.edu ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG
Re: [Pythonmac-SIG] Mac OS X native DNS lookups
On Wed, Nov 03, 2010 at 11:25:49AM +1000, James Mills wrote: Been looking around the web for how you might resolve hostnames on Mac OS X using OS X's sys calls to do so. Can anyone shed any light on this ? Try socket.gethostbyname for IPv4-only or socket.getaddrinfo for IPv4/IPv6. For example: import socket socket.gethostbyname('mary.local') '192.168.71.1' socket.getaddrinfo('bookworm.griley.members.mac.com', None, socket.AF_INET6, socket.SOCK_STREAM) [(30, 1, 6, '', ('fda1:5f1b:430f:37cc:214:51ff:fe0b:d94', 0, 0, 0))] Check the Python docs (http://docs.python.org/library/socket.html) for information on the tuples returned by getaddrinfo. -- Nicholas Riley njri...@illinois.edu ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG
Re: [Pythonmac-SIG] Mac OS X native DNS lookups
On Wed, Nov 03, 2010 at 12:16:34PM +1000, James Mills wrote: The problem with this (that we have) is that when/if the dns servers change (example: unplug the wire, turn on the wireless) this method of resolving names isn't able to tell that the dns servers have changed quickly enough. On Windows we've solved this by hooking into win32 calls (windns I believe) and using ctypes. We're after something similar on the Mac OS X platform ideally... socket.* *does* use the Mac native resolution mechanism. What you're running into is that they cache too aggressively; I've noticed this myself especially on 10.6. Executing 'dscacheutil -flushcache' should help; it doesn't require any privileges. You can use the SystemConfiguration framework to watch for DNS changes (State:/Network/Global/DNS). It's wrapped by PyObjC. At least on my 10.5 Mac here there's a demo script in /Developer/Examples/Python/PyObjC/SystemConfiguration/CallbackDemo/callbacks.py which registers for dynamic store notifications. You could also talk to scutil if you wanted; it's also got the ability to register for notifications: % scutil n.add State:/Network/Global/DNS n.watch notification callback (store address = 0x103730). changed key [0] = State:/Network/Global/DNS -- Nicholas Riley njri...@illinois.edu ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG
Re: [Pythonmac-SIG] Mac OS X native DNS lookups
On Wed, Nov 03, 2010 at 12:38:41PM +1000, James Mills wrote: On Wed, Nov 3, 2010 at 12:32 PM, Nicholas Riley njri...@illinois.edu wrote: At least on my 10.5 Mac here there's a demo script in /Developer/Examples/Python/PyObjC/SystemConfiguration/CallbackDemo/callbacks.py I don't seem to have a Python directory in /Developer/Examples/ on my Mac (10.6.4) It's distributed with PyObjC - you can also get it from http://svn.red-bean.com/pyobjc/trunk/pyobjc/pyobjc-framework-SystemConfiguration/Examples/CallbackDemo/ -- Nicholas Riley njri...@illinois.edu ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG
Re: [Pythonmac-SIG] [Python-Dev] sad state of OS X Python testing...
On Sat, Oct 02, 2010 at 10:08:09PM +0200, Martin v. Löwis wrote: Surely someone could volunteer an old Intel Mac to run some tests? (Actually, two someones -- we'd need separate machines for Leopard and Snow Leopard.) I'd be happy to stick it in a server room at PARC and keep an eye on it. (Right now I've got a rack full of old eMacs and a G5 running PPC buildbots.) Perhaps we could get Apple to contribute some seconds? I believe donations to the PSF are deductible. The issue isn't really to get the hardware. The issue is to find somebody to volunteer running a build slave. I'm already running a Jython buildslave on an Intel Mac Pro which is pretty underused - I'd be happy to run a CPython one there too, if it'd be worthwhile. -- Nicholas Riley njri...@illinois.edu ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG
Re: [Pythonmac-SIG] [Python-Dev] sad state of OS X Python testing...
On Sat, Oct 02, 2010 at 10:37:40PM +0200, Martin v. Löwis wrote: I'm already running a Jython buildslave on an Intel Mac Pro which is pretty underused - I'd be happy to run a CPython one there too, if it'd be worthwhile. I think Bill was specifically after Snow Leopard - what system are you using? It's still on Leopard but I could use another (slower, but still probably fine) machine that has Snow Leopard on it. -- Nicholas Riley njri...@illinois.edu ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG
Re: [Pythonmac-SIG] py2app problems with spawn
On Mon, Jul 26, 2010 at 10:41:29AM -0400, Tom MacWright wrote: This error is happening even just running the 'python' executable, so I think it's pretty safe to say that it's not related to Flask? Flask restarts the Python interpreter when it detects changes to its source files - that's how the reloader works. I imagine it's doing something that is not safe for Mac apps. -- Nicholas Riley njri...@illinois.edu ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG
Re: [Pythonmac-SIG] py2app problems with spawn
On Sun, Jul 25, 2010 at 11:35:04PM -0400, Tom MacWright wrote: * Restarting with reloader... python: posix_spawn: /Users/tmcw/Code/python/mapsonastick_env/mapsonastick/dist/moas.app/Contents/MacOS/../Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python: Unknown error: 0 Any idea what's going on here? Or if there's a different route I can take that might bring this a bit closer to something resembling success? I imagine with the source code packaged inside an app wrapper you do not need to use Flask's reloader. Just disable it. -- Nicholas Riley njri...@illinois.edu ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG
Re: [Pythonmac-SIG] Using Python 2.5 on Snow Leopard
On Fri, Sep 11, 2009 at 08:02:10PM +0100, Thijs Triemstra | Collab wrote: On 11 Sep 2009, at 18:50, Bill Janssen wrote: I was happy to see that Python 2.5 still shipped with SL, but now I'm less happy. I can't seem to compile PIL for Python 2.5 on Snow Leopard. Hm, haven't upgraded to snow leopard yet but i'd expect 2.6 to be in there.. heard they also removed twisted :( 2.5 and 2.6 both ship with SL, just built differently - Python 2.5 is obviously there for compatibility with Leopard, which I really appreciate. % lipo -info /usr/bin/python2.[56] Architectures in the fat file: /usr/bin/python2.5 are: i386 ppc7400 Architectures in the fat file: /usr/bin/python2.6 are: x86_64 i386 ppc7400 and Twisted is there still too: % find /System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/twisted | wc -l 1675 % find /System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python/twisted | wc -l 1675 -- Nicholas Riley njri...@illinois.edu ___ 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)
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 njri...@illinois.edu ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
Re: [Pythonmac-SIG] Can't get ASDictionary to work (py2app problems?)
To bring a (temporary) conclusion to all of this, the reason I upgraded the system version of py2app (or rather its dependency, modulegraph) was that it was incompatible with the current version of setuptools (0.7a1). I think this is actually a setuptools bug, which I've reported: http://bugs.python.org/setuptools/issue74 After removing my compiled versions of PyObjC, py2app, modulegraph *and* setuptools, then installing aemreceive, osaterminology and HTMLTemplate, ASDictionary built and runs fine against the stock 10.5 Python/PyObjC/py2app. That was painful, but hopefully this thread means nobody else will have to go through it :-) -- Nicholas Riley njri...@uiuc.edu ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
Re: [Pythonmac-SIG] Can't get ASDictionary to work (py2app problems?)
On Jun 2, 2009, at 1:58 AM, Ronald Oussoren wrote: I don't have time to look into the py2app issues right now. That said, I wouldn't install a new version of pyobjc in the system install of python because this might break other bits of the system. Thanks for the warning - you may want to make this clear in big letters on the PyObjC Web site. --Nicholas ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
Re: [Pythonmac-SIG] Can't get ASDictionary to work (py2app problems?)
On Mon, Jun 01, 2009 at 09:19:01PM +0100, has wrote: Odd. The osax module appears to be puking on a System Events command (it uses SE to get a list of installed osaxen). What versions of appscript and ASDictionary? What happens if you try to import the osax module into a regular script? Anything unusual about your setup (permissions, haxies, etc.)? Gah, I should have thought of this. I've got Default Folder X installed, which loads itself by pretending to be an osax. When I disabled it, ASDictionary opened successfully. I'll report it as a bug in Default Folder X. PyObjC/py2app questions I'll leave to those that know more about these things. (FWIW, I build ASDictionary using user-installed Python 2.5.2 framework + PyObjC 1.x for portability.) Anyone (Ronald?) have any idea about these problems? They're less important given that I have a fix for my ASDictionary issue, but still seem pretty serious. Thanks, -- Nicholas Riley njri...@uiuc.edu x ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
[Pythonmac-SIG] Can't get ASDictionary to work (py2app problems?)
almost driving me to AppleScript! Thanks, -- Nicholas Riley njri...@uiuc.edu ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
Re: [Pythonmac-SIG] mactypes Alias/File object question
On Mon, Apr 06, 2009 at 11:26:52AM -0700, Jeffery Beeland wrote: I'm using appscript to interface with Photoshop, which has gone pretty well to this point. The problem is that I can't seem to find a way to get a posix path out of an Alias or File object from mactypes. As best I can tell there are no public methods for the classes. This becomes a problem when I want to query a list of open documents and expect to be able to get at the actual file path for something like display of file information in a UI component. No public methods, but a public property (path) will give you what you want. http://appscript.sourceforge.net/py-appscript/doc/mactypes/ -- Nicholas Riley njri...@uiuc.edu ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
Re: [Pythonmac-SIG] [PyObjC] setting button name in NSOpenPanel
On Thu, Apr 02, 2009 at 09:52:26AM +0200, Steph-info wrote: Hi, I have the following piece of code : @objc.IBAction def chooseRec_(self, sender): op = NSOpenPanel.openPanel() op.setTitle_('Choisir un dossier') op.setCanChooseDirectories_(True) op.setCanChooseFiles_(False) op.setResolvesAliases_(True) op.setAllowsMultipleSelection_(False) result = op.runModalForDirectory_file_types_(None, None, None) if result == NSOKButton: self.pathRec = op.filename() self.pathField.setStringValue_(self.pathRec) which open an NSOpenPanel but I can't find how to change the default Open and Cancel button's names. Could anybody post a line of code demonstrating how to achieve this task ? op.setPrompt_('foo') will change Open. Note that NSOpenPanel inherits from NSSavePanel and a bunch of the API you might be looking for is in NSSavePanel. I don't believe it's possible to change 'Cancel' (beyond localizing it). -- Nicholas Riley njri...@uiuc.edu ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
Re: [Pythonmac-SIG] [PyObjC] setting button name in NSOpenPanel
On Thu, Apr 02, 2009 at 01:36:46PM +0200, Steph-info wrote: Thanks Nicholas, it works for the Open button. I found the following cocoa reference for the Cancel button : NSSavePanel *panel = [NSSavePanel savePanel]; NSButton* cancelButton = [[panel contentView] buttonWithTag:NSFileHandlingPanelCancelButton]; Do you know how I can translate this to PyObjC ? This is a hack - NSFileHandlingPanelCancelButton is 0, so trying to match the tag like this will match all buttons with no tag assigned (as is the default in Interface Builder). In addition, it assumes that the button is a direct descendant of the window's content view - since 2002 when the code above was written, it is no longer the case, so that code is already broken on OS X 10.5. That said, if you really must, a better way would be to check the control's action rather than its tag, searching through the entire hierarchy - something like this. def buttons_with_action(view, action): for subview in view.subviews(): if isinstance(subview, NSButton) and subview.action() == action: yield subview for i in buttons_with_action(subview, action): yield i cancelButtons = list(buttons_with_action(openPanel.contentView(), 'cancel:')) if len(cancelButtons) != 1: pass # handle error cancelButtons[0].setTitle_('Go Away') openPanel.runModalForTypes_(None) and assuming you're going to be distributing your app, make sure you handle the case when the button isn't there, or there are two of them, or the button doesn't have a title, or something else weird happens in a future OS version. -- Nicholas Riley njri...@uiuc.edu ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
Re: [Pythonmac-SIG] unicode problem w/pyapp 2.5 vs 2.6
On Sat, Feb 21, 2009 at 07:44:12AM -0500, tom wible wrote: i had simply copied aem from the 2.5 site-packages to the 2.6's...is there something i missed in doing that? some data is ok (the dates) Looks like you might have a UCS-4 version of one Python and a UCS-2 version of the other. Extension modules are not compatible between the two, although usually you get a link error. It's probably easiest just to reinstall install appscript on 2.6. -- Nicholas Riley njri...@uiuc.edu | http://www.uiuc.edu/ph/www/njriley ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
Re: [Pythonmac-SIG] LOLpatents
On Sun, Dec 14, 2008 at 12:15:37AM +0100, Jack Jansen wrote: I think the various other non-Applescript OSA implementations (what was the name of that database-like package again?) don't count as prior art for this patent because of the automatically build glue classes clause, but the original MacPython OSA interfaces definitely did that. Frontier and its derivatives semi-automatically built glue scripts (and mappings from names to constants, etc.), which it stored statically in the object database. Sometimes the glue scripts didn't work properly out of the box and you had to edit them manually. There's some discussion of the process here: http://pages.sbcglobal.net/mattneub/frontierDef/ch32.html#pgfId-896 All that code is open-source now, for example the 'aete' parser is here: http://frontierkernel.sourceforge.net/cgi-bin/lxr/source/Common/source/osaparseaete.c Code from an earlier time. How I miss Frontier... -- Nicholas Riley njri...@uiuc.edu | http://www.uiuc.edu/ph/www/njriley ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
Re: [Pythonmac-SIG] Creator, type and other means of file detection
On Mon, Dec 01, 2008 at 07:34:37PM +0100, Henning Hraban Ramm wrote: Ok, but how can I convert those Ints to string? I get them as Ints also from UTGetOSTypeFromString: from LaunchServices import UTGetOSTypeFromString UTGetOSTypeFromString('public.jpeg') 1886741100 from LaunchServices import UTGetOSTypeFromString ostype = UTGetOSTypeFromString('public.jpeg') ('%x' % ostype).decode('hex') 'publ' I don't think that is what you want though. Instead, use: import LaunchServices LaunchServices.UTTypeCopyPreferredTagWithClass('public.jpeg', LaunchServices.kUTTagClassOSType) u'JPEG' -- Nicholas Riley [EMAIL PROTECTED] | http://www.uiuc.edu/ph/www/njriley ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
Re: [Pythonmac-SIG] Teething troubles - Getting up an running on a mac
On Sun, Aug 03, 2008 at 10:12:23AM -0400, Kevin Walzer wrote: Question 2: In Finder, If I click on Search For Past week, I can see a sequence of folders under the horizontal scroll bar at the bottom of the window, allowing me to determine that some files that were placed under Applications MacPython 2.5 Extra Demo. But I do not seem to be able to see the sequence of folders under the horizontal scroll bar in any finder window. What do I need to do to make the folder sequence visible in all Finder Windows? Finder doesn't work that way--not sure what to tell you. Actually, this isn't the case in Leopard - you can use View Show Path Bar to turn it on. (However, this uses way too much screen space for me - I find it easier to Command-click - or, also new in Leopard, right-click - on the window title.) -- Nicholas Riley [EMAIL PROTECTED] | http://www.uiuc.edu/ph/www/njriley ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
Re: [Pythonmac-SIG] 64-bit Python?
On Wed, Jun 04, 2008 at 11:02:46AM -0500, Chris Kees wrote: I'm wondering how to coordinate having python executables in 32 and 64 bit mode on the same machine. Will the patched python 2.6 build a python and a python64? There's no need for two separate executables; Mach-O files can contain 1-4 architectures (or more, potentially for CPU specific variants). You can use the 'arch' command in Leopard to choose whether you want to execute the 64-bit or 32-bit version of an executable (a bit like isaexec on Solaris). When I build extension models do I then need to build/install each module twice e.g. 'python setup.py install' and 'python64 setup.py install'? Could I help this effort out by starting to work with your branch of python 2.6? I've been building a non- framework, non-universal build of python to work in 64 bit but it would be nice to take advantage of the universal build stuff as well as use some gui tools in 64 bit. That's up to how Ronald modifies distutils I guess. Unfortunately there are lots of places where code makes assumptions that it's building for a single architecture, so short of for example running the setup script once for each architecture and merging the build products it would be difficult to find a fully general solution. -- Nicholas Riley [EMAIL PROTECTED] | http://www.uiuc.edu/ph/www/njriley ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
Re: [Pythonmac-SIG] Carbon bindings' future
Internet Config is deprecated in 10.5; you should use SCDynamicStoreCopyProxies instead (see SCDynamicStoreCopySpecific.h). -- Nicholas Riley [EMAIL PROTECTED] | http://www.uiuc.edu/ph/www/njriley ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
Re: [Pythonmac-SIG] Carbon bindings' future
On Apr 11, 2008, at 3:50 PM, Daniel Miller wrote: BTW, I'm not sure if I'm doing the memory management correctly, especially with the values returned from CFDictionaryGetValue (it might need a CFRelease in there). Could someone double-check me on that please? The general CF rule is that if you use a function named *Get*, then you don't need to CFRelease; if you use a function named *Copy* or *Create*, you do. So, what you've written looks fine. -- Nicholas Riley [EMAIL PROTECTED] | http://www.uiuc.edu/ph/www/njriley ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
Re: [Pythonmac-SIG] Having trouble building Python w/ Tcl/Tk on my new Macbook Pro
On Feb 9, 2008, at 8:21 PM, [EMAIL PROTECTED] wrote: There are a number of frameworks there which look suspiciously old. How can I tell which are PPC and which are Intel? file(1) is probably easiest. You'll need to run them on the actual dylib inside the framework. For example: % file /Library/Frameworks/QtGui.framework/QtGui /Library/Frameworks/QtGui.framework/QtGui: Mach-O universal binary with 2 architectures /Library/Frameworks/QtGui.framework/QtGui (for architecture ppc): Mach- O dynamically linked shared library ppc /Library/Frameworks/QtGui.framework/QtGui (for architecture i386): Mach-O dynamically linked shared library i386 otool -fv works too but is considerably more verbose. Is it okay to just remove the Tcl Tk frameworks? (Renaming them caused the link to succeed.) I noticed much more recent versions in /System/Library/Frameworks. Unless you've got something else that relies on them, I don't see why not. You should be able to nuke anything in /Library in general; it's supposed to be user-serviceable (or at least administrator-serviceable). -- Nicholas Riley [EMAIL PROTECTED] | http://www.uiuc.edu/ph/www/njriley ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
Re: [Pythonmac-SIG] Key Bindings on cross platform apps.
On Mon, Feb 04, 2008 at 02:52:43PM -0500, Tom Pollard wrote: My recollection is that the control key has been around since the stone ages (ASR-33 teletypes, at least) and that many of the standard control-key combinations (ctl-C, for one) had their well-defined meanings long before the Mac was introduced. For Apple to introduce a command key rather than saying ctl-c no longer meant 'interrupt' but now 'copy' makes sense. That MS (or IBM, or whoever) decided to start using ctl-key combinations to mirror Apple's cmd-key combinations seems like the more egregious offense. (If I'm misremembering the history, please correct me.) That's more or less it. The Apple II had a Control key before it had open/closed-Apple (Command/Option) keys. The Mac Plus and earlier had only Command-Option keys and no Control (or Escape) key, which made terminal emulation software rather unhappy - they typically used the Option key. The Apple IIgs and Mac SE/II were the first machines to get ADB, and thus keyboard compatibility between the two. The other II/Mac unification changes were the Escape key, renaming Backspace to Delete and adding the (open) Apple logo to the Command key, from which it was only recently removed. Apple had three ADB keyboards at that point: - the Apple Extended keyboard, the basis of every desktop Apple keyboard since, until the recent aluminum keyboard design http://en.wikipedia.org/wiki/Image:Apple_Extended_Keyboard.jpg - the Apple Standard keyboard, with Control to the left of A, caps lock at the bottom left, escape to the left of 1 and arrow keys in order: http://en.wikipedia.org/wiki/Image:Apple_ADB_Keyboard.jpg - the IIgs keyboard, which was essentially a smaller version of the Apple Standard keyboard (and came out first): http://en.wikipedia.org/wiki/Image:Apple_IIgs_Keyboard_B.jpg The Extended keyboard was designed to be infrequently purchased, only by those people who wanted to run PC software on their Macs (Apple also shipped a 5 1/4 drive to be used with Macintosh PC Exchange around the same time), but it ended up becoming the dominant keyboard. -- Nicholas Riley [EMAIL PROTECTED] | http://www.uiuc.edu/ph/www/njriley ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
Re: [Pythonmac-SIG] Get the locale on OSX
On Sun, Dec 02, 2007 at 03:18:14PM +0100, Chris Van Bael wrote: I'm trying to port an python application which runs fine on Windows and Linux to OSX. However, it seems lang = locale.getdefaultlocale()[0] doesn't work. I've searched quite some bit on the Internet and on this mailinglist, and apparently it is a problem, but I haven't found any solution for it. What are you trying to do with the locale information? Leopard's Terminal does have an option to 'set LANG environment variable on startup', which when checked does cause locale.getdefaultlocale() to work, but this is of no help in general. -- Nicholas Riley [EMAIL PROTECTED] | http://www.uiuc.edu/ph/www/njriley ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
Re: [Pythonmac-SIG] Problem with numpy on Leopard
On Fri, Nov 02, 2007 at 01:06:08PM -0700, Christopher Barker wrote: Ned Deily wrote: The easiest way is to use the install_requires keyword in setup.py. See the setuptools documentation here: http://peak.telecommunity.com/DevCenter/setuptools That appears to handle dependencies: install_requires A string or list of strings specifying what other distributions need to be installed when this one is. See the section below on Declaring Dependencies for details and examples of the format of this argument. Which looks quite dangerous, as a matter of fact. For example, I do easy_install foo foo has install_requires(numpy==1.0.3) now setuptools will download and install numpy1.0.3, but it won't get used, 'cause there is an older numpy earlier on the pythonpath. From http://peak.telecommunity.com/DevCenter/setuptools#declaring-dependencies: Any scripts in your project will be installed with wrappers that verify the availability of the specified dependencies at runtime, and ensure that the correct versions are added to sys.path (e.g. if multiple versions have been installed). setuptools definitely supports multiple versions of packages being installed at once, and the ability to select them. It rewrites your scripts for you at installation time to resolve the depdendencies. If you want to use the versioned dependencies during development, that's what 'setup.py develop' is for. -- Nicholas Riley [EMAIL PROTECTED] | http://www.uiuc.edu/ph/www/njriley ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
Re: [Pythonmac-SIG] Leopard python architectures in setup.py
On Thu, Nov 01, 2007 at 11:32:58AM -0500, William Kyngesburye wrote: (Is it OK to ask about Apple's Leopard Python 2.5?) I'm a little confused about the 64bit-ness of Apple's Python 2.5. I see that the framework is, but the python executable is only universal 32bit. The modules (lib/python2.5/lib-dynload) and extras are a mix of 64bit and non-64bit, I presume because some depend on Carbon, which is not 64bit). When I build a package with setup.py, it always seems to build universal non-64bit, even though I've checked that the extras that it depends on (numpy) are 64bit-capable. Is there a way to get setup.py to build 64bit? I'm just building a package from source, and don't really know much about developing python extensions. Apple documents this in their release notes: http://developer.apple.com/releasenotes/OpenSource/PerlExtensionsRelNotes/ -- Nicholas Riley [EMAIL PROTECTED] | http://www.uiuc.edu/ph/www/njriley ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
Re: [Pythonmac-SIG] ctypes and OS X CF types?
On Mon, Oct 22, 2007 at 08:26:37AM -0700, Bill Janssen wrote: I'm trying to call the Spotlight system from Python, and I thought I'd try using the ctypes support in Python 2.5 to use the MDQuery framework. However, it seems that I'll have to unearth and write ctypes definitions for a number of Core Foundation C++ types, in order to do that. Has anyone already done this? Created ctypes definitions for the standard CF types, and made them available somewhere? CoreFoundation is C, not C++. That said, it'd probably be easier to use PyObjC with NSMetadataQuery instead. -- Nicholas Riley [EMAIL PROTECTED] | http://www.uiuc.edu/ph/www/njriley ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
[Pythonmac-SIG] py-appscript changes to filtering?
Hi, I ran into a bug with py-appscript 0.17.2 (handling apps that had quit while you still had a reference to them) and updated to the current trunk. This fixed this problem but broke some of my other code. This code: systemEvents = app(id='com.apple.systemEvents') frontName = systemEvents.processes[its.frontmost][1].name() which worked fine with 0.17.2 doesn't work any more. I get: File /Library/Python/2.3/site-packages/appscript-0.18.0-py2.3-macosx-10.4-ppc.egg/appscript/reference.py, line 457, in __getitem__ return Reference(self.AS_appdata, self.AS_aemreference.byfilter( File /Library/Python/2.3/site-packages/appscript-0.18.0-py2.3-macosx-10.4-ppc.egg/aem/types/objectspecifiers/specifier.py, line 385, in byfilter return ElementsByFilter(self.AEM_want, self, expression) File /Library/Python/2.3/site-packages/appscript-0.18.0-py2.3-macosx-10.4-ppc.egg/aem/types/objectspecifiers/specifier.py, line 425, in __init__ raise TypeError, 'Not a test specifier: %r' % key TypeError: Not a test specifier: its.property('pisf') It works if I use [its.frontmost == True], but that's kind of ugly. Is this intentional? Thanks, -- Nicholas Riley [EMAIL PROTECTED] | http://www.uiuc.edu/ph/www/njriley ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
Re: [Pythonmac-SIG] Accessing Resource forks
On Fri, Jul 13, 2007 at 02:55:55PM -0700, Christopher Barker wrote: The other obvious option is to look for the ._* files, which is where the resource fork is stored with the SMB protocol. However, we're concerned that that may not be reliable -- if a file were put up with SMB, then replaced with AFP, there may be a ._* file, but it won't work right. This actually seems pretty likely as while we have this mixed system, there have been a lot of that didn't work, please put the file back up with APF iterations. Yeah, SFM uses NTFS's stream support to store the resource fork and other Mac specific metadata elsewhere. You can check the resource fork size by looking at /path/to/file/..namedfork/rsrc but since the type and creator aren't stored in the resource fork, you'll have to get those in other ways if you want to preserve them. Note that forthcoming Mac OS X versions may no longer use ._ files to store resource forks on SMB mounted volumes (some third-party clients already don't), instead reading/writing to alternate streams just as SFM does. -- Nicholas Riley [EMAIL PROTECTED] | http://www.uiuc.edu/ph/www/njriley ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
Re: [Pythonmac-SIG] Build Applet Environ problem...
On Mon, Jun 25, 2007 at 01:25:20PM -0400, Jerry LeVan wrote: Hi, This weekend I got a MBP and started to transition to the Intel from PPC. I use the Build Applet tool to make lightweight apps that I can launch from the Dock. Some of my apps use environmental variables to simplify the environment setup. On the PPC G4 the applets would pick up the environmental variables when launched from the dock. On the Intel side this does not appear to be the case. If I launch the app from the command line open -a the environment vars will be picked up. Is this problem somehow my fault or is this a PythonMac/Intel problem? Stuff you launch from the dock shouldn't read your shell rc files. You'll need to use ~/.MacOSX/environment.plist instead. -- Nicholas Riley [EMAIL PROTECTED] | http://www.uiuc.edu/ph/www/njriley ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
Re: [Pythonmac-SIG] findertools.launch reports no eligible process
On Thu, Jun 14, 2007 at 01:16:08PM -0700, Christopher Barker wrote: However, if was nice to have some stuff without any external dependencies -- is there a lightweight way to do just Easy Dialogs, without all of PyObjC? It shouldn't be hard to simply wrap a Cocoa EasyDialogs implementation in C to construct a traditional Python module, but it make ssense to wait and see how much of Carbon is no longer going to be supported in 64-bit on Leopard (probably the WWDC attendees find out today but it's NDA'd). Cocoa doesn't have a generic API that matches that of EasyDialogs as much as Carbon does. -- Nicholas Riley [EMAIL PROTECTED] | http://www.uiuc.edu/ph/www/njriley ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
Re: [Pythonmac-SIG] CGI + appscript newbie question/problem
On Sun, May 27, 2007 at 05:04:25PM -0700, Andres Francisco Rojas wrote: but when I try to import appscript into the script run as cgi I get an 500 Internal Server Error. Typically you should look in the Web server logs (/var/log/httpd/error_log) in that case to see the details of the error, which are not returned in the browser to preserve security. You can also do: import cgitb; cgitb.enable() at the beginning of your script, so you get a nice HTML traceback if you get a Python exception. The thing is, I tried your script (after cleaning it up slightly) and I don't get a 500 error or the expected result, I simply get the following in the error log: INIT_Processeses(), could not establish the default connection to the WindowServer. Since you're using /usr/bin/python and assuming you're using 10.4.x, that should be the system Python 2.3.5. What version of appscript are you using? (You can print it with 'import appscript; appscript.__version__'). # Define function to generate HTML form. def generate_form(): print HTML\n 'print' already includes newlines, you don't need to use them. Not that string printing is a recommended templating mechanism, but if you do need to do it, you might try one of Python's other quoting styles; you can always use single quotes so you don't need to escape things, or triple quotes for multiline strings. For example, instead of: print \tFORM METHOD=post ACTION=\1.cgi\\n print \tINPUT TYPE=hidden NAME=\action\ VALUE=\launch\\n use: print '\tform method=post action=1.cgi' print '\tinput type=hidden name=action value=launch' So, as other people mentioned, you don't have access to control local apps as the Web server user. This is a good thing for security. However, you may be able to use remote Apple Events to do it. I couldn't figure out a way to get a remote application to launch without using the Finder. Appscript fails because it can't get the app's terminology; with terms=False on a non-running TextEdit, I get AppData instance has no attribute 'path'. This is really hacky, but it works sometimes; other times I get a timeout during terminology retrieval. This may just be my slow old machine. app(url='eppc://user:[EMAIL PROTECTED]/Finder').startup_disk.files['Applications:TextEdit.app'].open() texteditGUI = app(url='eppc://user:[EMAIL PROTECTED]/System%20Events').processes['TextEdit'] app(url='eppc://user:[EMAIL PROTECTED]/TextEdit', path='/Applications/TextEdit.app').activate() mref = texteditGUI.menu_bars[1].menus mref['File'].menu_items['New'].click() mref['Edit'].menu_items['Paste'].click() mref['Window'].menu_items['Zoom'].click() Replace user:password with your username and password, above. mref['Window'].menu_items['Zoom Window'].click() On my 10.4.9 machine this menu item is Zoom, not Zoom Window. -- Nicholas Riley [EMAIL PROTECTED] | http://www.uiuc.edu/ph/www/njriley ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
Re: [Pythonmac-SIG] How to create a desktop alias to run a python file?
On Sat, Mar 24, 2007 at 12:24:08AM +0100, Jack Jansen wrote: Is anyone else familiar with such simple .app bundles? That's how the various NeXT OSes - and OS X Server 1.x, IIRC - did it. (I did just try sticking the OS X Server 1.2 CD into a Mac running Tiger, but couldn't mount the Apple_Rhapsody_UFS partition.) -- Nicholas Riley [EMAIL PROTECTED] | http://www.uiuc.edu/ph/www/njriley ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
Re: [Pythonmac-SIG] Compiling Scipy/available binaries for Universal Python 2.4?
On Thu, Jan 11, 2007 at 02:21:19PM -0800, Christopher Barker wrote: Is it that hard to make a binary to put up (OK, two - one for PPC, one for Intel), once you've gotten it all built? At least a few people have gotten it going recently. Could someone please make them available? How about posting them on your own Web site then? If you don't have one, the price of commodity Web hosting is virtually zero, and there are plenty of free open source project hosting services around, some of them even good. It's been repeatedly stated on this mailing list that the currently pythonmac.org maintainer doesn't have time, and would be happy to relinquish control to someone who did. But nobody's volunteered. It is really rather tiresome to read about people asking for someone to do something when everyone's doing this work for free. -- Nicholas Riley [EMAIL PROTECTED] | http://www.uiuc.edu/ph/www/njriley ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
Re: [Pythonmac-SIG] How to fathom appscript
On Mon, Dec 18, 2006 at 11:11:27PM +, Hamish Allan wrote: itunes = app('iTunes') x = itunes.sources.first.playlists[its.name.contains('MyName')] This code fetches any playlists containing the string 'MyName'. But I want an exact match. Using 'equals' rather than 'contains' doesn't work. You just use '==' instead. In [4]: itunes.sources.first.playlists[its.name == 'Stations']() Out[4]: [app(u'/Applications/iTunes.app').sources.ID(41).user_playlists.ID(1936)] But in this case, you don't need to. In [6]: itunes.sources.first.playlists['Stations']() Out[6]: app(u'/Applications/iTunes.app').sources.ID(41).user_playlists.ID(1936) Most objects support multiple reference forms, as you'll see if you look at their documentation. How do I find out which operations its.name supports? And more generally, what is possible in other similar situations with different objects? Use .help(). So, for example, you can see that the playlists can be referenced by index, name or ID: In [7]: itunes.sources.first.playlists.help() == Appscript Help (-t) Reference: app(u'/Applications/iTunes.app').sources.first.playlists -- Description of reference Element: playlists -- by index, name, id [...] Note the reference forms above. It also helps to view the scripting dictionary, either using appscript's tools for doing so in a Web browser, or just with Script Editor (as I normally do). I also want to do what the following code suggests: x = itunes.sources.first.playlist_folders[its.name.equals('MyFolder')] You want 'folder_playlists' not 'playlist_folders'. So again it's pretty simple: In [15]: itunes.sources.first.folder_playlists['Statistics']() Out[15]: app(u'/Applications/iTunes.app').sources.ID(41).folder_playlists.ID(122340) y = itunes.sources.first.playlists[its.parent.equals(x)] Unfortunately here you run into a problem, as Apple didn't fully implement terminology for 'folder playlists', but you can view the scripting dictionary to figure it out. 'parent', while a property of playlists, isn't always set. So the only thing I could figure out was to iterate through them in Python: In [45]: stats_id = itunes.folder_playlists['Statistics'].id() In [46]: [p for p in itunes.user_playlists() if p.parent.exists() : and p.parent.id() == stats_id] Out[46]: [app(u'/Applications/iTunes.app').sources.ID(41).user_playlists.ID(1032), app(u'/Applications/iTunes.app').sources.ID(41).user_playlists.ID(1158), app(u'/Applications/iTunes.app').sources.ID(41).user_playlists.ID(1060)] -- Nicholas Riley [EMAIL PROTECTED] | http://www.uiuc.edu/ph/www/njriley ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
Re: [Pythonmac-SIG] pythonmac packages question
On Thu, Dec 07, 2006 at 12:38:36AM -0800, belinda thom wrote: On Dec 7, 2006, at 12:36 AM, belinda thom wrote: Thanks Nicholas, So how do I use easy install :-)? http://peak.telecommunity.com/DevCenter/EasyInstall Of particular importance is the section on custom installation locations: http://peak.telecommunity.com/DevCenter/EasyInstall#custom-installation-locations Before starting you probably want to edit the ~/.pydistutils.cfg file to specify a different location for installing scripts (for example, /usr/local/bin). If you just want to install the packages for yourself, then check out the Mac OS X User installation section. Then download and run ez_setup.py, which bootstraps setuptools, and run easy_install IPython. This will work with many simple packages, and some complex ones too. -- Nicholas Riley [EMAIL PROTECTED] | http://www.uiuc.edu/ph/www/njriley ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
Re: [Pythonmac-SIG] controlling iTunes with appscript
On Fri, Dec 01, 2006 at 07:45:38PM -0800, Craig Amundsen wrote: t.location.set(f) Yeah, you can't do this. If you look in the dictionary (for example, opening it in Script Editor), you'll see: location (alias, r/o) : the location of the file represented by this track The location property is read only. The only way I can think to move files across disks in iTunes and have the references stay intact is to use the Consolidate Library command. To do that, reset the iTunes Music Library location (Preferences Advanced General) to where you want the files to go, then choose Consolidate Library from the Advanced menu, and all your music will move there. Sorry for giving you advice before checking what you wanted to do was possible. That's the second time today I've made that mistake recently (the other one cost me about 2 hours of trying to compile Kerberos on AIX today.) In the strange coincidences category, Cherry Blossom Girl just came on the streaming station I'm listening to. Scary. -- Nicholas Riley [EMAIL PROTECTED] | http://www.uiuc.edu/ph/www/njriley ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
Re: [Pythonmac-SIG] controlling iTunes with appscript
On Tue, Nov 28, 2006 at 11:09:41AM -0800, Craig Amundsen wrote: I've moved a bunch of my files around and rather than do the 1 at a time showing iTunes the new location, I'd like to use appscript to set the location of the moved songs to the new value. Just FYI if you don't know already, iTunes uses aliases to keep track of file locations, so if you're not moving across volumes, you shouldn't have to do anything at all. Based on my reading it looks like track.location.set('/Path/To/The/File') should do what I want. You may end up needing to use HFS rather than POSIX paths, or even aliases, depending on what iTunes expects. The trouble I'm having is getting iTunes to give me a list of all the tracks in the library. I've tried various versions of things in the wiki and hints I've found via Google, but none have worked for me. Is there a canonical appscript call into iTunes that will return a list of all tracks in the library? iTunes.sources.filter(its.kind==k.library)[1].library_playlists[1].tracks() if you're using a newer appscript, you'd want instead: iTunes.sources.[its.kind==k.library][1].library_playlists[1].tracks() -- Nicholas Riley [EMAIL PROTECTED] | http://www.uiuc.edu/ph/www/njriley ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
Re: [Pythonmac-SIG] Why Do I Explicitly Need MacPython
On Tue, Oct 03, 2006 at 07:24:24PM +0200, Ronald Oussoren wrote: My guess is that it is much more convenient to build a very shallow wrapper around easy_install, basicly just a window with a textbox where you can enter an easy_install command-line and larger textview to show the output of easy_install. Double-clicking on an egg can open this window with the right command-line filled in. Or it could just build a .term file and launch Terminal with it. That should be good enough, I think, and you don't have to worry if something weird happens because there'd be a fully capable terminal with which the user can interact. -- Nicholas Riley [EMAIL PROTECTED] | http://www.uiuc.edu/ph/www/njriley ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
[Pythonmac-SIG] Fix Mac page again?
Can someone fix the download link on this page? http://www.python.org/download/mac/ It's the one marked an installer for the latest version. If the 2.5 installer is compatible with 10.3-10.3.8, then the next paragraph could mostly go away too, I guess. Just make sure it doesn't get reworded to suggest running the TclTkAqua installer on 10.4 - if you run it on an Intel machine it'll break things horribly since it's PowerPC only, as I discovered today (and the uninstaller doesn't restore the tclsh/wish links properly). I had someone ask me today where to get Python 2.5, and apparently they missed the link on the main download page. Thanks, -- Nicholas Riley [EMAIL PROTECTED] | http://www.uiuc.edu/ph/www/njriley ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
Re: [Pythonmac-SIG] Please critique my first appscript - a fix for Palm sync of iCal Tasks (for kGTD)
These are (mostly) all issues of personal opinion, but anyway... On Tue, Aug 29, 2006 at 12:49:44AM -0400, Marcin Komorowski wrote: #!/usr/bin/env /usr/bin/pythonw There's no point of using env if you specify an absolute path. #!/usr/bin/env pythonw is probably what you want. def myDebug( txt ): if txt == None: sys.stderr.flush() else: sys.stderr.write( txt ) stderr should be unbuffered by default; you shouldn't need to flush it at all. Also, if you've got a sentinel value, try representing it with a default/optional argument, e.g.: def myDebug(txt, flush=False): or: def myDebug(txt=None): def getTaskList(): appCal = app( 'iCal' ) Use a bundle ID or creator to refer to iCal, in case it is renamed. cal_todos = appCal.calendars.filter(its.name != '').todos.properties() tasks = [ todo for cals in cal_todos for todo in cals] Consider being more consistent about spacing - see PEP 8 for one possible coding style. Also, wow, I never noticed how backwards reading nested list comprehensions is - yuck (Python problem, not yours...). # Iterate flattened list, builing a local dictionary of dictionaries, by uid tasks_data = {} for task in tasks: if task[ k.class__ ] == k.todo: Why do you need to do this? It seems if you ask for todos, all you get is todos, right? :) If you're working around some iCal bug it makes sense to comment it. uid = task[ k.uid ] tasks_data[uid] = task; myDebug('.') myDebug(None) You could do the above with a generator expression, e.g: tasks_data = dict((todo[k.uid], todo) for todos in cal_todos for todo in todos if todo[k.class__] == k.todo) (this should be fast enough; I can't imagine it'd be worth displaying progress) k_decode = { k.priority : k.priority, k.due_date : k.due_date, k.completion_date : k.completion_date, k.description : k.description, k.url : k.url, k.uid : k.uid, k.summary : k.summary, k.class__ : k.class__ } There's no need to do this; you can just print k.priority, etc., directly. def diffTaskLists( task_list1, task_list2 ): diff_list = [] for uid in [ id for id in task_list1.keys() if task_list2.has_key( id ) ]: You can use 'id in task_list2' instead of 'task_list2.has_key(id)'. For clarity (if not necessarily speed) you might consider using the set data type instead. t1 = task_list1[uid] t2 = task_list2[uid] found_difference = False for field in [ k.priority, k.due_date, k.completion_date, k.description, k.url, k.summary ]: if t1[field] != t2[field]: if found_difference == False: I generally find it easier to read if not found_difference. myDebug( task ID %s:\n % str( uid ) ) You don't need to use 'str', that's what %s does already. And don't be afraid of the print statement, e.g.: print sys.stderr, ' task ID %s:' % uid myDebug( field %s: % k_decode[field] ); try: myDebug( t1 = '%s' t2 = '%s' % ( t1[field], t2 [field] ) ) except: pass Eww. If there are problems converting the fields to a string, you should address them (or report a bug in appscript or iCal...) At the very list, make your except statement more specific so it doesn't mask other exceptions. myDebug( \n ) found_difference = True break Huh, what's the point of checking 'found_difference' then, if you break immediately after setting it to true? Looks like you can get rid of it completely. def updateTimeStamp( task_uid_list, timestamp ): myDebug( Setting new timestamp for task UIDs %s\n % repr ( task_uid_list ) ) You can use '%r' % task_uid_list to get the repr. def usage(): print USAGE: + sys.argv[0] + save|check It's a bit more efficient (and clearer, IMO) to use commas to give print multiple arguments rathern than using + to concatenate strings. def main(mode): if mode != 'save' and mode != 'check': if mode not in ('save', check'): pp = pprint.PrettyPrinter(indent=4) Since you only use this once, it makes sense to move it closer to its definition and/or combine the creation and invocation. -- Nicholas Riley [EMAIL PROTECTED] | http://www.uiuc.edu/ph/www/njriley ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
Re: [Pythonmac-SIG] Problem with open_app Action Event
On Fri, Jul 14, 2006 at 08:43:53PM +0200, Stefan Holmer wrote: I'm writing the application in Python using the MiniAEFrame module which comes with MacPython. I've built it mostly like the example test class in MiniAEFrame named _Test. Try using aemreceive, part of appscript (http://freespace.virgin.net/hamish.sanderson/appscript.html) instead of MiniAEFrame - it's a much better version. A script I wrote using aemreceive is here: http://dev.sabi.net/trac/dev/browser/trunk/RetroStatus/RetroStatus.py It's extremely special-purpose, but should give you some ideas. There are also some examples (and documentation) included with appscript. -- Nicholas Riley [EMAIL PROTECTED] | http://www.uiuc.edu/ph/www/njriley ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
Re: [Pythonmac-SIG] Fwd: Re: python appscript is displaying warning/errors sometimes
On Wed, Jun 28, 2006 at 05:47:34PM -0700, Bob Ippolito wrote: You have some kind of haxie-like-thing (an InputManager maybe) installed. That haxie is broken and causing those messages. #6 0x059be320 in DFPatch::Initialize () No symbol table info available. Looks like SCPatch/Default Folder X. Report it as a bug. -- Nicholas Riley [EMAIL PROTECTED] | http://www.uiuc.edu/ph/www/njriley ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
Re: [Pythonmac-SIG] Bundling Python framework with app
On Mon, Jun 19, 2006 at 07:43:57PM +0100, Banoffi wrote: Um, why not? I know it's not as simple as drag-and-drop, but neither is it particularly hard work for the user. (And I'm not at all confident of getting the embedded package approach to work.) One major reason I avoid .pkg installers is there's no easy way to uninstall. With an app bundle, you just trash it. (And yes, this is Apple's problem that they still don't have a robust installer after 5 years.) -- Nicholas Riley [EMAIL PROTECTED] | http://www.uiuc.edu/ph/www/njriley ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
[Pythonmac-SIG] exception on NSWorkspace.launchAppWithBundleIdentifier_options_additionalEventParamDescriptor_launchIdentifier_
Hi, I'm trying to launch an app in the background, as follows: ws = NSWorkspace.sharedWorkspace() ws.launchAppWithBundleIdentifier_options_additionalEventParamDescriptor_launchIdentifier_(bundleID, NSWorkspaceLaunchAndHide | NSWorkspaceLaunchWithoutActivation, None) I've tried simplifying this and changing it, for example: ws.launchAppWithBundleIdentifier_options_additionalEventParamDescriptor_launchIdentifier_(u'com.apple.Finder', 0, NSAppleEventDescriptor.nullDescriptor()) But no matter what I do, I get an IndexError: NSRangeException - *** -[NSCFArray objectAtIndex:]: index (0) beyond bounds (0) This occurs inside the method; that's about all I can tell from here: #0 0x92991008 in -[NSException raise] () #1 0x92990e5c in +[NSException raise:format:] () #2 0x92954050 in -[NSCFArray objectAtIndex:] () #3 0x93b739f8 in -[NSWorkspace launchAppWithBundleIdentifier:options:additionalEventParamDescriptor:launchIdentifier:] () #4 0x002be654 in ffi_call_DARWIN () #5 0x002be248 in ffi_call () #6 0x002c840c in PyObjCFFI_Caller () #7 0x002dc5c0 in PyObjCSelector_GetFlags () #8 0x0040d5a4 in PyObject_Call (func=0x12278e0, arg=0x90aae1a0, kw=0x54) at /Volumes/Data/Users/ronald/Universal/python24-fat/Objects/abstract.c:1795 The exception is raised after the method has successfully done its work, so if I catch it and ignore it, everything works, but that doesn't exactly fill me with feelings of happiness. The same method invocation works fine from Objective-C. What's going on? I'm using Python 2.4.3 Universal on a PPC 10.4.6 machine, and PyObjC 1.3.7. Thanks, -- Nicholas Riley [EMAIL PROTECTED] | http://www.uiuc.edu/ph/www/njriley ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
Re: [Pythonmac-SIG] Python Unicode and NSString...
On Tue, May 30, 2006 at 09:33:32AM +0200, whamoo wrote: Hi all! i'm at war with unicode python and cocoa, and seem that i cannot win... =) i've wrote this function: def makeNSString(self, oldString): try: oldString = NSString.stringWithUTF8String_(oldString) return oldString except Exception, e: print Exception, e return oldString And it work, now in my app i have all the ?,?,?,? correctly written, but it raise this exception each time: exceptions.Exception depythonifying 'charptr', got 'unicode' This is normal? what can i do? ;) What are you trying to do? If the string is already Unicode, PyObjC will make it into a NSString for you. If you want to encode a Unicode string as UTF-8, then use oldString.encode('utf-8'). -- Nicholas Riley [EMAIL PROTECTED] | http://www.uiuc.edu/ph/www/njriley ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
Re: [Pythonmac-SIG] question about ic.py on Mac OS X
On Sat, May 20, 2006 at 09:21:06PM -0400, Ishwinder Kaur Banga wrote: MAC OS version 10.4.6 Python Version 2.4.1 Problem is that the url is valid but the python icglue tells me that it is not found Are you on PPC or x86? Does this happen with the current Python 2.4.3 or the built-in Python 2.3.5? Does this happen when opening URLs using Launch Services, or with Internet Config in other apps? (You can try my 'launch' tool - with the -l option it uses IC, without it, it uses LS). -- Nicholas Riley [EMAIL PROTECTED] | http://www.uiuc.edu/ph/www/njriley ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
Re: [Pythonmac-SIG] Fwd: MacPython icon mockup
On Sun, Apr 23, 2006 at 04:36:26PM -0400, Jacob Rus wrote: has wrote: I could draw up a grinder or something in Illustrator, but it probably won't be for some days. If you can find something sooner, that's cool, otherwise let me know middle of next week and I'll see what I can do. Okay, this is kind of goofy, but might work. The second image is the drop state. Check out the zip to see it in action. PNG: http://hcs.harvard.edu/~jrus/python/py-grinder.png ZIP: http://hcs.harvard.edu/~jrus/python/py-grinder.zip Nice looking, but unrecognizable and impractical at small sizes. Even at full size, I had to stare at it for a few seconds before I recongized what it was trying to depict. The dropping action at a small size (say 32x32) looks like something kicking out, rather than a handle turning. -- Nicholas Riley [EMAIL PROTECTED] | http://www.uiuc.edu/ph/www/njriley ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
Re: [Pythonmac-SIG] Fwd: MacPython icon mockup
On Sun, Apr 23, 2006 at 08:20:48PM -0400, Jacob Rus wrote: Donovan Preston wrote: What about something more like the Help Indexer in /Developer/ Applications/Utilities. A little more stylized and less photorealistic. Should look better at smaller sizes. Yeah, building on Brendan Simons' idea of what a Help Indexer-esque Applet Builder.app icon should look like, here's what I've come up with: http://hcs.harvard.edu/~jrus/python/prettified-py-icons.png Sadly, the grinder isn't destined for glory. (I agree that it's not so great at small sizes, or even at 128x128, but at full size it's fun to drop stuff on :-) Sorry to rain on your parade :-) The new icon looks great. Can these icons (and their source Photoshop files, etc.) be checked into some Subversion repository, so they can continue to be developed? I'd hate to see someone else have to start from scratch in the event new Mac OS X icons need to be produced. -- Nicholas Riley [EMAIL PROTECTED] | http://www.uiuc.edu/ph/www/njriley ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
Re: [Pythonmac-SIG] Fwd: MacPython icon mockup
On Thu, Apr 20, 2006 at 01:40:00AM -0400, Jacob Rus wrote: Easy enough: http://hcs.harvard.edu/~jrus/python/pyc-icon-variations.png Which do you prefer? I'd say PYC, because although it isn't a word, the icon does a better job of connoting the file contents than any of the other words, and for people who know Python, PYC means something. My second choice would be the unadorned one. I'm actually wondering if using the folded-corner document icon for .pyc files is a good idea at all. The document icon usually indicates something that can be edited or at least viewed, and a .pyc file certainly can't be (easily :). Consider the executable icon (cd into /bin or whatever) as an example - although, I guess even run-only AppleScripts get a document icon. -- Nicholas Riley [EMAIL PROTECTED] | http://www.uiuc.edu/ph/www/njriley ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
Re: [Pythonmac-SIG] Fwd: MacPython icon mockup
On Thu, Apr 20, 2006 at 11:11:19PM -0400, Brendan Simons wrote: I've attached a few more mockups using Jacob's excellent aquified logo. Have a look here: http://www.flickr.com/photos/[EMAIL PROTECTED]/132185325/ The .pyc logo is a great improvement over everything else I've seen - the bit patterns don't quite line up nicely. You might also consider using a small snippet of Python bytecode instead, like the XP icons did: http://doxdesk.com/img/software/py/icons2.png I don't think stealing the Apple Installer icon is a good idea for .egg though - double-clicking it doesn't install anything. Perhaps something closer to a StuffIt archive icon (a closed box) or a Python logo behind Apple's zipper icon with EGG underneath. Or an egg? Anyone remember Software Ventures' logo? :) http://www.levenez.com/NeXTSTEP/MicroPhonePro.jpg The PYTHON text appears to be in the wrong font. By analogy with AppleScript, perhaps the text shouldn't be there at all (although how many people will recognize the Python logo anyway?) Otherwise, looks terrific! Wish I had any artistic talent so I could offer something other than suggestions. -- Nicholas Riley [EMAIL PROTECTED] | http://www.uiuc.edu/ph/www/njriley ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
Re: [Pythonmac-SIG] Fwd: MacPython icon mockup
On Fri, Apr 21, 2006 at 12:56:45AM -0400, Jacob Rus wrote: 6. I've never used .egg files, but this icon makes them look like installers. Is that what they are? No, they're the equivalent of jar files (archives of Python code), except they're not launchable. Unfortunately the jar icon is rather boring: it's just a coffee cup in a document with JAR underneath it. -- Nicholas Riley [EMAIL PROTECTED] | http://www.uiuc.edu/ph/www/njriley ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
Re: [Pythonmac-SIG] Fwd: MacPython icon mockup
On Thu, Apr 20, 2006 at 10:00:45PM -0700, Donovan Preston wrote: I don't think stealing the Apple Installer icon is a good idea for .egg though - double-clicking it doesn't install anything. Perhaps something closer to a StuffIt archive icon (a closed box) or a Python logo behind Apple's zipper icon with EGG underneath. Or an egg? Anyone remember Software Ventures' logo? :) How about just the lego brick used for components with the python logo on the side. Look in /System/Library/Components. Gah, I meant to suggest this in my last email. I think this is a good idea too. Or an egg-shaped brick? *ducks* The PYTHON text appears to be in the wrong font. By analogy with AppleScript, perhaps the text shouldn't be there at all (although how many people will recognize the Python logo anyway?) Probably the python logo is enough, since the file ends in .py. Good point - .py is unlikely to be a hidden extension. -- Nicholas Riley [EMAIL PROTECTED] | http://www.uiuc.edu/ph/www/njriley ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
Re: [Pythonmac-SIG] Fixing the documentation...
On Wed, Apr 19, 2006 at 02:38:22PM +0100, has wrote: 2.3 ic -- Access to Internet Config No idea about this. Anyone else know if this is still working/relevant? It is basically deprecated for LaunchServices now. It would be really good if we could get a decent LaunchServices binding - as of now, there are several, all of which have some problems (?). 4.1 Carbon.AE -- Apple Events Ronald's been thinking it might be best to deprecate both Carbon.AE and Carbon.OSA and keep all the AE/OSA/appscript stuff together. Dunno if he's got any further on that yet; you could ask. How far do you think your stuff is from being able to be incorporated in the standard library? It'd be much nicer to just replace it rather than removing it. 4.7 Carbon.Cm -- Component Manager According to Apple's docs CM is largely historical; modern apps should use Core Foundation's Plug-in Services. Other Carbon APIs still rely on it though, so do nothing. Not to mention QuickTime and CoreAudio, which aren't going away any time soon. 4.20 Carbon.Res -- Resource Manager and Handles According to Apple's docs, RM is historical, but I'm not sure about alternatives; need to check out Bundle Services. For now, probably do nothing. Resources are still used quite a bit by OS X; don't think it's worth deprecating. 5. Undocumented Modules 5.1 applesingle -- AppleSingle decoder No idea. Anyone? Dunno, but it'd sure be nice if there were a programmatic interface to Bom.framework (which does AppleDouble, zips and cpio files with Mac metadata). This is Apple's problem, not ours, though. 5.4 icopen -- Internet Config replacement for open() Presumably in the same boat as '2.3 ic'. Anyone? Yeah, deprecate for LaunchServices. -- Nicholas Riley [EMAIL PROTECTED] | http://www.uiuc.edu/ph/www/njriley ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
Re: [Pythonmac-SIG] Fwd: MacPython icon mockup
On Wed, Apr 19, 2006 at 04:41:59PM -0400, Jacob Rus wrote: Ok, got it. Well, I've now put more time into this than I wanted to, but I've got a glassy version of the correct python logo at full size, [here][4]. Let me know what you all think. If it looks good to everyone, I can make a .py icon like the one linked above, and an editor icon like Script Editor and TextEdit's, though someone will have to help me with the pen/pencil/whatever. I'm still not clear what the drag-n-drop script runner icon should look like. Looks great. Quick, make the other icons before anyone else complains! :) -- Nicholas Riley [EMAIL PROTECTED] | http://www.uiuc.edu/ph/www/njriley ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
Re: [Pythonmac-SIG] Building apps with hardcoded options using py2app
On Mon, Apr 17, 2006 at 04:59:21PM -0400, Mike Covill wrote: I would like to package up different versions of our application which we normally specify on the command line with different command line options. For example: myapp.py or myapp.py -sim Can I use py2app to make different 'double-clickable' applications that would give us the same functionality? If so, how? Where would I specify the options? Use -argv-inject. python setup.py py2app --help for more information. -- Nicholas Riley [EMAIL PROTECTED] | http://www.uiuc.edu/ph/www/njriley ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
Re: [Pythonmac-SIG] Marking the pre-built extensions as Intel-capable...
On Mon, Mar 27, 2006 at 04:00:07PM -0800, Christopher Barker wrote: What happens if you double-click on a *.egg? That'd be an incredibly cool utility to have, and a lot easier to write than something like PackageManager. -- Nicholas Riley [EMAIL PROTECTED] | http://www.uiuc.edu/ph/www/njriley ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
Re: [Pythonmac-SIG] py2app is building semi-standalone package only.
On Wed, Mar 22, 2006 at 05:20:12PM -0500, Russell Finn wrote: On 3/22/06, Christopher Barker [EMAIL PROTECTED] wrote: 2) you mentioned a programmatic API: In fact, I think there is a plist somewhere that sets the default environment variables for all apps, you could add a PATH entry (or add to it) programmaticly easily enough. Yes, it's ~/.MacOSX/environment.plist; see Apple's QA1067 http://developer.apple.com/qa/qa2001/qa1067.html. Perhaps the new Python installer should set this location instead of .profile (which doesn't help people using csh/tcsh)? (Be sure to include the standard path /usr/bin:/bin:/usr/sbin:/sbin as well -- the settings in the .plist file are *not* cumulative.) Please, no. Editing the shell init files is bad enough (but necessary to support users who aren't aware of the difference between /usr and /usr/local); really, there should be a better way of doing this. Even worse is changing the path somewhere hardly anyone knows where to look. 3) PATH is only relevant to command line apps: if you've never gone back from using a GUI -- you'll never need to care about this. But I would guess a number of Python-based GUI applications probably use command-line utilities under the covers, which is why a global setting is useful. If Mac GUI apps depend on custom environment variables or a paritcular PATH being set, they're broken. They should use command-line utilities inside their bundles or frameworks, which py2app and friends make very easy to accomplish. -- Nicholas Riley [EMAIL PROTECTED] | http://www.uiuc.edu/ph/www/njriley ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
Re: [Pythonmac-SIG] os.environ
On Sun, Mar 19, 2006 at 07:20:51AM +, Nicholas Cole wrote: I hope that this is not an FAQ, but I can't find an answer on it. I know that Terminal.app is setting the environment variables LINES and COLUMNS (I can see them with the bash set command), but os.environ['LINES'] and os.environ['COLUMNS'] don't exist. Why is that? LINES and COLUMNS are not typically exported by the shell (passed to child processes). You can use 'export LINES' or 'export COLUMNS' to do so if you wish. -- Nicholas Riley [EMAIL PROTECTED] | http://www.uiuc.edu/ph/www/njriley ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
Re: [Pythonmac-SIG] My stab at a new page
On Mon, Feb 13, 2006 at 09:06:06AM -0800, Christopher Barker wrote: Bill Janssen wrote: You missed the first part of my message, I think. The system version would be installed under /usr/libexec/, or some such place, not under /usr/bin/. That is a good idea, but how do we get Apple to do it? So the end result is that the system Python (and Perl, Tcl, Ruby, ...) isn't visible? Yuck - as started earlier in this thread, there are plenty of people for whom the system Python 2.3.x is plenty usable. Not everyone creates bundled applications for redistribution, or needs Python 2.4. Way back when Redhat used python1.5 with a bunch of added extensions for its admen tools. All their tools had usr/local/bin/env python in the #! line. This was a pain in the *$^%* when you wanted to upgrade your standard python, just like it's a pin now with Apple. However, all they needed to do was put a darn version on the #! line: /usr/bin/env python1.5 Apple could do the same thing, then all their admin tools would be insulated from adding additional, newer pythons anywhere on the PATH. What Apple does now, i.e. #!/usr/bin/python (see the contents of /usr/libexec/fax, for example), is better - what if you had a replacement Python 2.3 which didn't have Apple's CoreGraphics bindings in it, for example? It's not always going to be the case that Apple provides a Python version one major version behind the current one. Also, a lot of Apple's tools run from within a GUI context where the path is set by the loginwindow environment (~/.MacOSX/environment.plist), not by your shell initialization files, which makes absolute paths more attractive. They could use #!/usr/bin/python2.3, I guess... NOTE: Even better would be a way to specify multiple versions in order of preference, and a python launcher that would sort that out for you. This would be particularly nice on Windows, where you can only associate *.py with one thing. Maybe some day I'll want that enough to write it! Apple does something similar with its Java launching mechanism; you can specify exactly this JVM version or this major version or at least this version and so forth in the Info.plist file. It'd be nice if Apple provided a standard way to handle versioning for any system-provided interpreter, though whatever they did would only be likely to apply to bundled applications, not command-line stuff. -- Nicholas Riley [EMAIL PROTECTED] | http://www.uiuc.edu/ph/www/njriley ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
Re: [Pythonmac-SIG] New Page, first proposal
On Fri, Feb 10, 2006 at 12:37:55PM -0800, Christopher Barker wrote: Yes, but it then puts the scripts in the weird bin directory buried in the Framework, and one extra step is one extra step too many. This definitely needs to be a FAQ, at least, if not a changed default in the Python framework install. I've seen this catch a large number of people using Python web apps that install scripts for management, such as Trac, TurboGears and so forth. Even if we could just recommend a ~/.pydistutils.cfg like this: [install] install_scripts = /usr/local/bin we'd be better off. -- Nicholas Riley [EMAIL PROTECTED] | http://www.uiuc.edu/ph/www/njriley ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
Re: [Pythonmac-SIG] building universal binaries
On Sat, Feb 04, 2006 at 09:41:32AM +0100, Ronald Oussoren wrote: An alternative to fat might be 'ppc,i386'. That is longer, but is clearer about which architectures are supported (just in case someone decides to donate support for a threeway universal build). Patching setuptools to know that an architecture string that contains a comma is actually a list of architectures shouldn't be too hard. This sounds like a good idea, and this is not just a legacy issue with ppc64 - we'll likely have a 64-bit x86 Mac variant to handle within the year. -- Nicholas Riley [EMAIL PROTECTED] | http://www.uiuc.edu/ph/www/njriley ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
Re: [Pythonmac-SIG] Spotlight Importing without .py
On Sun, Jan 22, 2006 at 12:13:07AM -0500, Nicholas Matsakis wrote: So, is it possible there is _no_ standard type code for python source? If not, any thoughts on registering one? Indeed, they're text files. I wouldn't want them to behave any other way. The basic problem is that a four-character HFS type code is insufficient to describe the role of a piece of (potentially executable) source code. UTIs map as of 10.4 to a file extension, MIME type, pasteboard flavor, or OSType (four-character code). What is lacking is the ability to assign a UTI directly to a file in place of the HFS type code, and/or to sniff a document to determine its UTI, for example by looking at the shebang line. The latter was possible in OS 9 with the Translation Manager, whereby the installed translation extensions could in turn examine a document to determine if they could open it. This facility was dropped in OS X for whatever reason and has never been restored, but it's a good bet that a future version of Spotlight will gain something similar though UTI-based. So, really, all we can do as of 10.4, short of patching frameworks, is to file bug reports and wait. Naming your executable Python scripts something ending in .py or .pyw works too. :-) -- Nicholas Riley [EMAIL PROTECTED] | http://www.uiuc.edu/ph/www/njriley ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
Re: [Pythonmac-SIG] pythonw stay open
On Wed, Dec 07, 2005 at 06:18:49AM +, Ryan Wilcox wrote: Hello all, I have a bunch of CGIs that make use of pythonw (+cgiwrap) to allow me to send AppleEvents (via appscript) to applications on the web server machine. Everytime I hit one of these CGIs, pythonw launches a Python application (which makes sense). While this machine is under heavy-ish load (CPU hogging applications), it feels like launching pythonw takes too long (read: a second or two, which is too long in CGI time.) Is it possible to leave pythonw open all of the time, and avoid paying the launch costs, or is the price for launching pythonw too minimal to notice (time... says...)? (Meaning that I should try to optimize my system some other way, like moving the CPU hogging process off that machine...) Use FastCGI, SCGI, or similar? -- Nicholas Riley [EMAIL PROTECTED] | http://www.uiuc.edu/ph/www/njriley ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
Re: [Pythonmac-SIG] problem trying to use aemreceive with Tkinter app
On Thu, Dec 01, 2005 at 02:45:10PM -0600, Kennedy, Andrew (GE Healthcare) wrote: I'm trying to use aemreceive to process AppleEvents in a Tkinter-GUI'd Python app. I have been able to use argvemulator.py from plat-mac to handle double clicking on a file and having it open in the application automatically. I'm now trying to catch 'ocon' and 'odoc' AppleEvents within the application to handle dragging files onto the icon and double clicking on files while the application is running. I can add the event handler per the code below: if sys.platform == 'darwin': import aemreceive aemreceive.installeventhandler(AEOpenFile, 'aevtodoc', ('','AliasList', aemreceive.ArgListOf(aemreceive.kAE.typeAlias))) What am I missing? Do I need to modify my main loop to handle the events? I never seem to get into the event handler code this way, so there must be something else at work here. Is my event handler at the wrong level of the stack? The crash log is included after my signature. Any assistance anyone can offer would be greatly appreciated. It's trying to execute your event handler; it looks like the Python thread state (PyThreadState) passed to PyFrame_New is null. I imagine this happens because the Python code is being dispatched when it doesn't expect to be running Python code at all. There might be a way to wrap your event handler but I'm not familiar enough with the internals of aemreceive to say how. The only Python AE receive stuff I've done has been using aemreceive.sfba. I was able to use aemreceive.sfba.starteventloop() for that. It seems from the stack trace that Tk still removes and dispatches an event at a time, so it doesn't play well with other event consumers. Maybe you can run your own event loop and dispatch events to Tk yourself? Or you could try using Tk's event handler instead. You can try evaluating a definition of ::tk::mac::OpenDocument, which according to the TkAqua FAQ should be called on an aevt/odoc event. -- Nicholas Riley [EMAIL PROTECTED] | http://www.uiuc.edu/ph/www/njriley ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
Re: [Pythonmac-SIG] appscript and quicktime
On Mon, Oct 03, 2005 at 09:21:41AM +0200, captnswing wrote: if (can export movie 1 as DV stream) is true then try with timeout of 360 seconds export movie 1 to POSIX file the_newname as DV stream using settings the_settings with replacing end timeout on error errorMsg number errNo ... end try end if = can export? with timeout? not sure how to do this in appscript... Generally you replace multi-word commands in AppleScript with word1_word2_... in appscript. In [6]: qt.help('-o') [...] Commands: can_export [...] In [7]: qt.can_export.help() Appscript Help (-t) Reference: app(u'/Applications/QuickTime Player.app').can_export Description of reference Terminology for can_export command Command: can_export(...) -- Determine if a movie or track can be exported to the desired type Reference -- the movie or track to export as=k.AIFF | k.AVI | k.BMP | k.DV_stream | k.Fast_Start_QTVR_Movie | k.FLC | k.hinted_movie | k.image_sequence | k.interframe_compressed_VR_object_movie | k.MuLaw | k.MPEG2 | k.MPEG4 | k.picture | k.QuickTime_media_link | k.QuickTime_movie | k.QuickTime_TeXML | k.standard_MIDI | k.System_7_sound | k.text_file | k.ThreeGPP | k.wave -- the desired file type Result: Boolean -- is the export supported In [8]: qt.can_export(qt.movies[1], as=k.DV_stream) Out[8]: True Timeout is a keyword argument to all commands, so you'd do something like: In [40]: qt.export(qt.movies[1], to='i:Users:nicholas:Desktop:foo.dv', as=k.DV_stream, replacing=True, timeout=360) and you'd get back a CommandError exception if the event timed out. also the following: = --get number of tracks and kind of movie tell application QuickTime Player activate open the_file tell movie file_name set track_count to the count of tracks set track_kind to the kind of track 1 end tell end tell --if movie is muxed mpeg if (track_count is equal to 1) and (track_kind contains Muxed) then . = it is unclear to me how to get to the track_kind property of a movie are not all properties and functions mapped over to appscript? In [14]: len(qt.movies[1].tracks()) Out[14]: 2 In [15]: qt.movies[1].tracks[1].kind() Out[15]: u'Sound' I think there are some things that appscript still doesn't do, but I haven't ever run into them. also I wonder how you can tell which appscript command takes what parameters. I remember the Quark Express discussion a while ago where there was a astype parameter to the get command: pw.get(astype=k.Char) You can either generate HTML documentation or interactively probe the terminology with appscript; see: http://freespace.virgin.net/hamish.sanderson/appscripthelpsystem.html and finally, what does the k. in the documentation (and the above get () call) stand for? keyword, I think. -- Nicholas Riley [EMAIL PROTECTED] | http://www.uiuc.edu/ph/www/njriley ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
Re: [Pythonmac-SIG] How to tell if a .app is clicked again?
On Tue, Aug 16, 2005 at 09:51:57AM -1000, Bob Ippolito wrote: IIRC, on Mac OS X, there isn't a difference between re-launching and becoming active. Double-clicking the app should have the same behavior as cmd-tabbing over to it (or using expos?, or the dock, etc.), because LaunchServices recognizes that the application is already open and just tells it to activate. It used to be, back in System 7, but at some point (7.6? 8.0?) the 'aevt'/'rapp' (kAEReopenApplication) event was sent when an application is double-clicked in the Finder and is already open. The same occurs when you click on the application's dock icon in OS X. You can test this, for example, with TextEdit. Open it, close the untitled window, switch somewhere else, then cmd-tab to it: you don't get an untitled window. Then switch somewhere else and click on its icon in the dock: you do get an untitled window. Another issue: It puts an icon in the dock, but I don't have any wxWindows or anything, so it doesn't do much. The only way I can figure out how to stop it is to right click on the icon in the dock and select force quit. I see two possible solutions: It depends on the Web server you're using and how well it fits with CF/NSRunLoop and friends. Chris might be able to run a regular PyObjC app (from which you can easily set up a NSApplication delegate to implement applicationShouldHandleReopen_hasVisibleWindows_) and the Web server in other threads, or not... -- Nicholas Riley [EMAIL PROTECTED] | http://www.uiuc.edu/ph/www/njriley ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
Re: [Pythonmac-SIG] How to tell if a .app is clicked again?
On Tue, Aug 16, 2005 at 03:02:04PM -0700, Chris Barker wrote: Well, it's not, but that is an idea. If I have a little launcher stub, it could just check and see what's running, and then launch what it needs to, then quit. That way it would just get started up again if the user double clicked again, and then do what it needed to. That would require more than one app to be installed, however. Which leads me to another idea: Can I tell OS-X that I DO want another instance of the app launched rather than raising an existing one? That way, I could do the Windows trick: On launch, check for an existing one, of it's there, start the browser and quit. If it's not, start the server, then the browser, and don't quit. This would let me have the app and the launching stub be the same app. You can do this (LaunchServices lets you multi-launch apps, or you can always execute the binary directly), but not from the Finder. However, you could do something slightly different, and closer to your first idea: embed the actual app inside the launcher app's bundle. Then start your real app, with an icon or not, when the launcher app runs; the launcher app would then exit. If the launcher app notes that the real app is already running, then just open the page in the browser. The user would only see one app, and since the Finder in OS X no longer shows apps differently when they're open, they'd never know the difference. -- Nicholas Riley [EMAIL PROTECTED] | http://www.uiuc.edu/ph/www/njriley ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
Re: [Pythonmac-SIG] Getting Sharing name of the Macintosh via Python?
On Wed, Aug 03, 2005 at 03:21:53PM -0400, Schollnick, Benjamin wrote: Folks, Anyone have any idea on how to get the Machine Name from the Sharing Preference pane? The only real solution that I have thought up is to find the plist and read it from there http://developer.apple.com/qa/qa2001/qa1078.html -- Nicholas Riley [EMAIL PROTECTED] | http://www.uiuc.edu/ph/www/njriley ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
Re: [Pythonmac-SIG] appscript help - supposed to work?
On Fri, Jul 15, 2005 at 01:20:58AM -0500, Nicholas Riley wrote: I seem to remember this used to work... I tried with a couple of other apps too; same problem. And five seconds after sending that, I realize you're supposed to use foo.help() instead. It would be nice if help() didn't barf quite as badly though. -- Nicholas Riley [EMAIL PROTECTED] | http://www.uiuc.edu/ph/www/njriley ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
Re: [Pythonmac-SIG] Tricky question?
On Tue, Jun 14, 2005 at 12:09:38PM -0400, Schollnick, Benjamin wrote: Is there any way to gather a list of applications that have been installed on the Macintosh This information is available, but there is no public API for accessing it. So you have a few choices - use a SPI, parse the output of lsregister, or collect the information yourself. The SPI is _LSCopyAllApplicationURLs() in LaunchServices.framework, which works back several OS versions, but may be removed at any point. /System/Library/Frameworks/ApplicationServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -dump also gives you what you want, though the format of the output is likely to change. No matter what you do, please file a bug (bugreport.apple.com) and ask for this to be made a public API in future. Also, anyway to tell what the current screen saver settings are? (ie. Screen Saver is set to turn on at XX minutes, and is password protected?) Again, you're on your own here - no supported API. Have fun... As much as you can, it may help both here and in your bug reports to describe why you need the above information; there may be another way to do what you want. -- Nicholas Riley [EMAIL PROTECTED] | http://www.uiuc.edu/ph/www/njriley ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
Re: [Pythonmac-SIG] making a C extension compatible across OS versions?
On Thu, May 26, 2005 at 02:28:59PM +0100, has wrote: Obviously the extension needs to be built on Tiger to provide sdef support, but what should I do to ensure that, say, applications containing that binary extension will still work OK when run on earlier OSes? For example, should I include both extension builds in the osaterminology package and have it import the appropriate one according to OS version, or is there a better/more elegant/official way of doing it? You can use weak linking if you don't need to support 10.1.x or earlier, otherwise you'll have to load individual bundles, or use CFBundle or some lower-level mechanism to obtain and call through function pointers. http://developer.apple.com/technotes/tn2002/tn2064.html -- Nicholas Riley [EMAIL PROTECTED] | http://www.uiuc.edu/ph/www/njriley ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
Re: [Pythonmac-SIG] Python Metadata Importer
On Thu, May 26, 2005 at 10:54:59AM -0400, Jonathan Wight wrote: After adding Gideon's suggestion for CRLF ending file. My importer is failing on only 8 files out of 3084 files. All the failures are with Python files that try to generate the __version__ attribute with code instead, e.g.: __version__ = string.split('$Revision: 1.8 $')[1] __version__ = '$Revision: 1.6 $'[11:-2] And so on. My options are: #1 Continue to fail and not process the script any further (easiest solution ;-) #2 Just ignore the attribute in question. #3 Convert the attribute into a string even though it might not make much sense. #4 Execute the line and get the computed value of the attribute. I don't really want to execute the line - who the heck knows what it could do. Unless anyone has any better ideas I'm just going to try and gracefully ignore the attribute. How about just recognizing versions that have the form $Revision: foo$ and stripping the tag info, just as the code above does? -- Nicholas Riley [EMAIL PROTECTED] | http://www.uiuc.edu/ph/www/njriley ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
Re: [Pythonmac-SIG] Python Metadata Importer
On Thu, May 26, 2005 at 10:52:05AM -0700, Bob Ippolito wrote: There are still other places where you'll have version expressions. PyOpenGL's is the most braindead, it reads the version from *A FILE*. Many extensions bring in the version from some extension (i.e. PyObjC). I'd go ahead and just ignore anything that isn't a string. 99.74% of modules isn't bad. Not many people do the CVS thing these days, and that number is going to get smaller and smaller since people are replacing CVS with Subversion and others. Subversion supports keyword substitution, too. Seems reasonable to support if it's common and 1 line of code, otherwise...yeah, whatever. -- Nicholas Riley [EMAIL PROTECTED] | http://www.uiuc.edu/ph/www/njriley ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
Re: [Pythonmac-SIG] convert binary plist to xml string
On May 7, 2005, at 12:13 PM, Florian Munz wrote: since the format of plist files changed to binary by default on Tiger my little program, which works on xml plists doesn't work anymore. Is there a way to convert a binary plist to xml with Python or PyObjC? I know this on the command line: plutil -convert xml1 Bookmarks.plist but I'm searching a way to do this directly. In [1]: from Foundation import * In [2]: import os In [3]: plist, format, error = NSPropertyListSerialization.propertyListFromData_mutabilityOption_format_errorDescription_(NSData.dataWithContentsOfMappedFile_(os.path.expanduser('~/Library/Preferences/com.apple.keychainsync.plist')), NSPropertyListImmutable, 0) In [4]: plist Out[4]: {KeychainSyncList = (); } In [5]: data, error = NSPropertyListSerialization.dataFromPropertyList_format_errorDescription_(plist, NSPropertyListXMLFormat_v1_0) In [6]: data.writeToFile_atomically_('foo.plist', False) Out[6]: 1 In [7]: print file('foo.plist').read() ?xml version=1.0 encoding=UTF-8? !DOCTYPE plist PUBLIC -//Apple Computer//DTD PLIST 1.0//EN http://www.apple.com/DTDs/PropertyList-1.0.dtd; plist version=1.0 dict keyKeychainSyncList/key array/ /dict /plist -- Nicholas Riley [EMAIL PROTECTED] | 4111 Siebel Center Department of Computer Science| 201 N. Goodwin Ave. and Medical Scholars Program | Urbana, IL 61801-2302 Univ. of Illinois at Urbana-Champaign | +1 217 244 2274 ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
Re: [Pythonmac-SIG] Distinguishing between Aqua Tk and X11 Tk
On Mon, May 02, 2005 at 07:17:25PM +0200, [EMAIL PROTECTED] wrote: Is there a reliable method to find out at runtime if Tkinter uses Aqua Tk or X11 Tk? I need this to define keyboard shortcuts, they use Command with Aqua, but since X11 Tk doesn't seem to support this, they will need Control in that case. I answered this question for you (!) in September 2004. http://mail.python.org/pipermail/pythonmac-sig/2004-September/011615.html -- Nicholas Riley [EMAIL PROTECTED] | http://www.uiuc.edu/ph/www/njriley ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
Re: [Pythonmac-SIG] site-packages symlink location changed in Tiger?
On Sat, Apr 30, 2005 at 10:23:21PM -0700, Kevin Ollivier wrote: Hi all, Like a good Mac citizen, I promptly picked up my copy of Tiger and upgraded yesterday, and I noticed that most of my third-party Python packages weren't being discovered. After re-installing one, I saw what (on my machine) was causing the problem: after upgrading, the location pointed to by the site-packages symlink in Tiger's Python.Framework was moved from /Library/Python/2.3/ to Library/ Python/2.3/site-packages/. Has anyone else seen this? I want to make sure I didn't run into some sort of glitch. This was covered on this mailing list a few days ago. http://mail.python.org/pipermail/pythonmac-sig/2005-April/013823.html -- Nicholas Riley [EMAIL PROTECTED] | http://www.uiuc.edu/ph/www/njriley ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
Re: [Pythonmac-SIG] converting file paths between HFS and POSIX formats
On Fri, Apr 22, 2005 at 02:05:28PM +0100, has wrote: Just wondering if there's anything in MacPython for converting HFS paths to POSIX and vice-versa, or is my memory playing tricks on me? If not, does anyone have some code they don't mind sharing? Keep in mind that HFS paths aren't unique, whereas POSIX paths are, so you should be using FSRefs, CFURLs, POSIX paths or aliases for canonical representations, cognizant of all the tradeoffs between those formats. In [1]: from Carbon.CoreFoundation import * In [2]: from Carbon.CF import * In [3]: u = CFURLCreateFromFileSystemRepresentation('/Applications', False) In [4]: u.CFURLCopyFileSystemPath(kCFURLPOSIXPathStyle).toPython() Out[4]: u'/Applications' In [5]: u.CFURLCopyFileSystemPath(kCFURLHFSPathStyle).toPython() Out[5]: u'Onyx:Applications' If you _really_ must go from an imprecise HFS path to something else: In [5]: u = toCF('Onyx:').CFURLCreateWithFileSystemPath(kCFURLHFSPathStyle, False) In [6]: u.CFURLCopyFileSystemPath(kCFURLPOSIXPathStyle).toPython() Out[6]: u'/Applications' and so forth. -- Nicholas Riley [EMAIL PROTECTED] | http://www.uiuc.edu/ph/www/njriley ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
Re: [Pythonmac-SIG] converting file paths between HFS and POSIX formats
On Fri, Apr 22, 2005 at 05:08:47PM +0100, has wrote: I'm kinda leery of using MacPython's CF wrapper as it's a bit buggy in places. Still your example looks like it works ok - good suggestion, thanks. One bit I'm not sure about though - if I run this: u = toCF('A Non-mounted Drive:').CFURLCreateWithFileSystemPath(kCFURLHFSPathStyle, False) print u.CFURLCopyFileSystemPath(kCFURLPOSIXPathStyle).toPython() I get '/A Non-mounted Drive' whereas I was assuming it should be '/Volumes/A Non-mounted Drive' - is that correct? u = toCF('Data:').CFURLCreateWithFileSystemPath(kCFURLHFSPathStyle, False) u.CFURLCopyFileSystemPath(kCFURLPOSIXPathStyle).toPython() u'/Volumes/Data' u = toCF('Foo:').CFURLCreateWithFileSystemPath(kCFURLHFSPathStyle, False) u.CFURLCopyFileSystemPath(kCFURLPOSIXPathStyle).toPython() u'/Foo' Yeah, I see what you mean. You can't expect this kind of conversion to work on a nonexistent file, and it's not one-to-one in any case... I'd suggest just documenting it and leaving it. -- Nicholas Riley [EMAIL PROTECTED] | http://www.uiuc.edu/ph/www/njriley ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
Re: [Pythonmac-SIG] CFURL Pain
On Mon, Feb 28, 2005 at 06:41:47PM +, has wrote: import Carbon.CF as CF f = CF.CFURLCreateFromFileSystemRepresentation('file://localhost/Users/has/', True) That's not a filesystem representation (code for UTF-8 encoded path). u'./file://localhost/Users/has' (Where did './' come from?) print f.toPython() # MacOS.Error: (-192, 'Resource not found') print f.CFURLGetFSRef() # crashes print f.CFURLGetFSRef()[1].as_pathname() # MacOS.Error: (-35, 'no such volume') When CF stuff crashes, you can often get more information by using the debug version of frameworks: % DYLD_IMAGE_SUFFIX=_debug ipython 2005-02-28 15:34:18.928 python[16198] CFLog (0): Assertions enabled In [1]: import Carbon.CF as CF In [2]: f = CF.CFURLCreateFromFileSystemRepresentation('/Users/nicholas', True) In [3]: f.CFURLGetString().toPython() 2005-02-28 15:34:29.168 python[16198] CFLog (15): CFStringGetCharacters(): string range 0,32 out of bounds (length 31) Out[3]: u'file://localhost/Users/nicholas' In [4]: f.CFURLGetFSRef() zsh: 16198 bus error DYLD_IMAGE_SUFFIX=_debug ipython [...] In [3]: f.CFURLGetFSRef()[1].as_pathname() DebugAssert: Third Party Client: err == 0 [-43] FSPathMakeRef_GetObjectInfoFailed [line 1670, file Files/HighLevelCalls.c] DebugAssert: Third Party Client: volume != NULL FSMakePath_VolNotFound [line 848, file Files/FilePathUtils.c] DebugAssert: Third Party Client: (tempMapOffset = (fileLength - kNullMapLength)) exit CheckMapHeaderCommon(), Resource Manager: EOF truncates resource map.[line 195, file Resources/Source/ResourceUtils.c] --- Error Traceback (most recent call last) /Users/nicholas/console Error: (-35, 'no such volume') In [4]: f.CFURLGetFSRef()[1] DebugAssert: Third Party Client: err == 0 [-43] FSPathMakeRef_GetObjectInfoFailed [line 1670, file Files/HighLevelCalls.c] Out[4]: Carbon.File.FSRef object at 0x5756a8 In [5]: f = CF.CFURLCreateFromFileSystemRepresentation('/Users/nicholas/', True) In [6]: f.CFURLGetFSRef()[1].as_pathname() Out[6]: '/Users/nicholas' It's hard to say if the crash is Python's fault or CF's fault, but there's definitely a wrapper bug in there. And it looks like you need the trailing slash; didn't bother to check if that is by design or not. -- Nicholas Riley [EMAIL PROTECTED] | http://www.uiuc.edu/ph/www/njriley ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
Re: [Pythonmac-SIG] [OT] To upgrade Mac OSX or not?
On Tue, Jan 25, 2005 at 09:53:38AM -0600, Skip Montanaro wrote: Here's the rub. Apple seems to rather quickly drop support for what appear (numerically) to be minor releases. 10.1 is long gone. I have 10.3 on my G5 and 10.2 on my laptop. I'm loathe to buy 10.3 at this point for my laptop because 10.4 is in beta (right? Apple offered a preview version of 10.4 to me for $500 recently). I figure as soon as I buy 10.3, 10.4 final will be released. 10.3 will start to corrode and I'll be stuck again with old software once again. 10.3's popularity was a lot greater than 10.2's; also, the time between 10.3 and 10.4 was considerably greater. I imagine it'll last you longer than 10.2 did, but you may find yourself wishing for 10.4 in a few months. Only now I have two Macs, so the costs are double. Not quite; you can get a family pack good for up to 5 machines owned by an individual or family for less than twice the price. http://www.amazon.com/exec/obidos/ASIN/BE6NKA/104-1061095-1859926 It seems that Apple's upgrade policy almost forces me to buy new versions as soon as they are released. If I snooze when new releases come out I quickly get left in the dust and wind up either skipping a version or upgrading right before the next release. (This has happened to me in the past.) I really hate to say this, but in this respect backward compatibility in Windows seems to be much better. Am I missing something? Only that Mac OS X started out a lot less mature than recent versions of Windows, and is evolving a lot faster than Windows, so often the reason why a new Mac OS X version is required is that the functionality simply didn't exist in the prior version. Yes, backwards compatibility in Windows is better than Mac OS X, with most products I see still supporting back to Windows 98, and some requiring Windows 2000 (released December 1999, to use one definition). Mac OS X 10.0 wasn't even released until March 2001. I used 10.0, but had to reboot into Mac OS 9 a lot. 10.1 (September 2001) was a marginal improvement, but not a paid upgrade; still I couldn't use OS X full-time. 10.2 (August 2002) was the first version I voluntarily gave other people to use, and 10.3 (October 2003) the version I gave my mother. 10.4 is unlikely to be released before April 2005. Note that the time between releases continues to increase. I doubt Mac OS X is ever going to see Windows' multi-year release cycles, but you can expect better backwards compatibility in future. -- Nicholas Riley [EMAIL PROTECTED] | http://www.uiuc.edu/ph/www/njriley ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig