From sdm7g@Virginia.EDU Thu Jul 3 23:50:30 1997 From: sdm7g@Virginia.EDU (Steven D. Majewski) Date: Thu, 3 Jul 1997 18:50:30 -0400 (EDT) Subject: [PYTHONMAC-SIG] ProgressBar resources Message-ID: Jack, Guido, or whoever is going to be doing the next Mac release: I don't know if I mentioned this in my EasyDialog patches, but could you please edit the ProgressBar dialog resource in the next release to extend the width of the text field to extend over the stop button, closer to the right edge of the box ? The current text field truncates all of my displayed filenames. I've modified my PythonPPC Core resources, but it would be nice if this was fixed in the default. Jack: I recall you were going to use some of my mods and suggestions in the next release, but you were going to change a few things youself. Do you have a final version ? I'm working on some modules that will use this, and since it's going to rely on those fixes, I thought I might as well make sure it works with that interface. If not I'll search thru my mail archives to remember what we had decided on for the labeling, and add the mods to my version. I think it was to have two methods: title(str) and label(str). Is that still the plan for the 1.5 release ? ( BTW: Tk8b2 is released with CW-PRO-1 support, but I haven't built it yet. I had some trouble getting past the CGI survey to get the sources, but you can go directly to the ftp directory and bypass the CGI if you have problems. ) ---| Steven D. Majewski (804-982-0831) |--- ---| Department of Molecular Physiology and Biological Physics |--- ---| University of Virginia Health Sciences Center |--- ---| P.O. Box 10011 Charlottesville, VA 22906-0011 |--- All power corrupts and obsolete power corrupts obsoletely." - Ted Nelson _______________ PYTHONMAC-SIG - SIG on Python for the Apple Macintosh send messages to: pythonmac-sig@python.org administrivia to: pythonmac-sig-request@python.org _______________ From sdm7g@Virginia.EDU Fri Jul 11 21:07:29 1997 From: sdm7g@Virginia.EDU (Steven D. Majewski) Date: Fri, 11 Jul 1997 16:07:29 -0400 (EDT) Subject: [PYTHONMAC-SIG] file modes in Mac Python (frustrating) Message-ID: When I try to open a file with read and write access using __builtin__ open on MacPython 1.4, I get an error when I try to write: IOError: (0, 'component result = no error') According to MSL Reference, "rb+", "wb+" modes should work. ( Or is it using I/O routines from CWGUSI ? ) Using os.open, os.read, os.write, os.lseek seems to work properly for read and write access to a file. ( But I've had to look up the hex values of flags from the .h files. These aren't defined in a Mac module anywhere, are they ? ) Module posixfile works somewhat. It import without an error, but some methods import and use posix, fcntl, FCNTL which aren't on Mac, so they will fail. ( For example, you can't create a posixfile and use flags to change it's mode, because that uses fcntl. Note that there is an fcntl call in MSL, but it only supports F_DUPFD. ) Anyone else have any tips on the best, most portable IO methods in Mac Python ? ( Since the obvious way doesn't seem to work! Well -- the lib ref manual *does* say that whether 'r+' et.al. work is platform dependent. ) ---| Steven D. Majewski (804-982-0831) |--- ---| Department of Molecular Physiology and Biological Physics |--- ---| University of Virginia Health Sciences Center |--- ---| P.O. Box 10011 Charlottesville, VA 22906-0011 |--- All power corrupts and obsolete power corrupts obsoletely." - Ted Nelson _______________ PYTHONMAC-SIG - SIG on Python for the Apple Macintosh send messages to: pythonmac-sig@python.org administrivia to: pythonmac-sig-request@python.org _______________ From guido@CNRI.Reston.Va.US Fri Jul 11 21:22:48 1997 From: guido@CNRI.Reston.Va.US (Guido van Rossum) Date: Fri, 11 Jul 1997 16:22:48 -0400 Subject: [PYTHONMAC-SIG] Re: file modes in Mac Python (frustrating) In-Reply-To: Your message of "Fri, 11 Jul 1997 16:07:29 EDT." References: Message-ID: <199707112022.QAA24629@eric.CNRI.Reston.Va.US> > When I try to open a file with read and write access using __builtin__ > open on MacPython 1.4, I get an error when I try to write: > > IOError: (0, 'component result = no error') > > According to MSL Reference, "rb+", "wb+" modes should work. > ( Or is it using I/O routines from CWGUSI ? ) It might be. But I recall that I tested dumbdbm.py on a Mac (in fact I wrote it on a Mac) and it uses 'rb+' (it also seems to use non-binary mode in a few places, but that seems a bug). I don't see why GUSI would break this, but I'm not totally sure either... > Using os.open, os.read, os.write, os.lseek seems to work properly > for read and write access to a file. > > ( But I've had to look up the hex values of flags from the .h files. > These aren't defined in a Mac module anywhere, are they ? ) In 1.5, O_RDONLY, O_RDWR and O_WRONLY (and other flags) will be defined in the os module (which gets them from the posix module, and, presumably, from the mac module -- Jack???) > Module posixfile works somewhat. Oh please, stay away from posixfile. It is obsolete. The new version of the documentation states: \emph{Note:} This module will become obsolete in a future release. The locking operation that it provides is done better and more portably by the \code{fcntl.lockf()} call. > Anyone else have any tips on the best, most portable IO methods > in Mac Python ? ( Since the obvious way doesn't seem to work! > Well -- the lib ref manual *does* say that whether 'r+' et.al. > work is platform dependent. ) Well, 'r+' et al. should work whenever the stdio library is ANSI C compatible, so they are about as portable as you can get. --Guido van Rossum (home page: http://www.python.org/~guido/) _______________ PYTHONMAC-SIG - SIG on Python for the Apple Macintosh send messages to: pythonmac-sig@python.org administrivia to: pythonmac-sig-request@python.org _______________ From Robin.K.Friedrich@USAHQ.UnitedSpaceAlliance.com Fri Jul 11 21:46:39 1997 From: Robin.K.Friedrich@USAHQ.UnitedSpaceAlliance.com (Robin.K.Friedrich@USAHQ.UnitedSpaceAlliance.com) Date: Fri, 11 Jul 1997 15:46:39 -0500 Subject: [PYTHONMAC-SIG] file modes in Mac Python (frustrating) Message-ID: <000FDB19.1924@freedom.rsoc.rockwell.com> I just noticed the same thing the other night. This really bugs me because I know for a FACT that the vanilla open() function used to work fine on the Mac. ______________________________ Reply Separator _________________________________ Subject: [PYTHONMAC-SIG] file modes in Mac Python (frustrating) Author: "Steven D. Majewski" at INTERNET Date: 7/11/97 3:07 PM When I try to open a file with read and write access using __builtin__ open on MacPython 1.4, I get an error when I try to write: IOError: (0, 'component result = no error') _______________ PYTHONMAC-SIG - SIG on Python for the Apple Macintosh send messages to: pythonmac-sig@python.org administrivia to: pythonmac-sig-request@python.org _______________ From sdm7g@Virginia.EDU Fri Jul 11 22:31:02 1997 From: sdm7g@Virginia.EDU (Steven D. Majewski) Date: Fri, 11 Jul 1997 17:31:02 -0400 (EDT) Subject: false alarm - RTFM [was: [PYTHONMAC-SIG] file modes in Mac Python] In-Reply-To: <000FDB19.1924@freedom.rsoc.rockwell.com> Message-ID: Sorry: false alarm... I looked at Guido's dumdbm example and saw that it reopens the file before most operations. I tried writing, closeing, reopening for update, writing, closeing, opening and reading the file and it updated properly. I dug up my copy of Plauger's "The Standard C Library", which is much more heavily annotated than the Metrowerks MSL reference, and read up on , and find: can't do write after read without a seek in between; can't do read after write without a flush in between; 'Unix' I/O doesn't have this restriction (and that's what I'ld normally use if I was doing it in C). os.open, os.read, os.write uses those routines (I assume). Standard Python I/O uses stdio. ( Which I know but forget sometimes, since the 'f' is dropped in the python methods: I should just remember that file.write == fwrite, file.seek == fseek ) < I think I'll just fix my program and go back to worrying about who's going to buy Apple next week! :-> ---| Steven D. Majewski (804-982-0831) |--- ---| Department of Molecular Physiology and Biological Physics |--- ---| University of Virginia Health Sciences Center |--- ---| P.O. Box 10011 Charlottesville, VA 22906-0011 |--- All power corrupts and obsolete power corrupts obsoletely." - Ted Nelson _______________ PYTHONMAC-SIG - SIG on Python for the Apple Macintosh send messages to: pythonmac-sig@python.org administrivia to: pythonmac-sig-request@python.org _______________ From guzdial@cc.gatech.edu Mon Jul 14 17:27:17 1997 From: guzdial@cc.gatech.edu (Mark Guzdial) Date: Mon, 14 Jul 1997 12:27:17 -0400 Subject: [PYTHONMAC-SIG] Some Mac-Specific Python Questions Message-ID: One of my summer goals is to read both "Internet Programming with Python" (IPWP) (Watters/Rossum/Ahlstrom) and "Programming Python" (Lutz). Of course, this is getting me playing with and exploring Python on my Mac more than I have in the past, which is, in turn, leading me to a bunch of Mac-specific questions that I'm not finding addressed on-line or in the books: - GRAIL: Anyone know what's needed to get Grail to work successfully on a Mac? It starts for me, opens the local file, but when I try to use an http URL, it just sits there and I have to force an application close. Second and related question: Has anyone successfully applet-ized Grail? (I haven't tried yet -- it seemed useless until I could figure out how to make Grail work well for me, first.) - Threaded CGI: Jack's CGI example is neat -- I can understand it and probably even build one myself. What's unclear to me is how multiple nearly-simultaneous hits will be handled. It seems to be a non-issue on UNIX (from the IPWP book's CGI example). I know that, on the Mac, WebStar is threaded, and I've done Frontier CGIs which are threaded, so that multiple hits just get handled, invisibly to me. Is there a way to do threaded CGI's on Macs? Or is there a technique to get around thread-less MacPython? For example, Joe Strout's POO isn't threaded, but it handles multiple "threads" even on Macs by chopping up tasks into pieces and timeslicing the pieces. Has anyone done something similar to create a sort-of CGI-event-server on a Mac? - Open Transport: As I read through the ReadMe's in the 1.4 distribution (BTW, is it too soon to ask when a Mac 1.5 is going to be available?), I note various places where things aren't supposed to work because of MacTCP oddities (e.g., the reference in Demo:Readme). Does Open Transport make more of those things work (which I can test myself) and/or make them capable of working (which would be nice to know before I start digging)? After looking at the GUI example in IPWP, I'm in no hurry to see WPY on the Mac. Tkinter looks much cleaner and easier to use, ThankYouVeryMuch. Thanks! Mark -------------------------- Mark Guzdial : Georgia Tech : College of Computing : Atlanta, GA 30332-0280 (404) 894-5618 : Fax (404) 894-0673 : guzdial@cc.gatech.edu http://www.cc.gatech.edu/gvu/people/Faculty/Mark.Guzdial.html _______________ PYTHONMAC-SIG - SIG on Python for the Apple Macintosh send messages to: pythonmac-sig@python.org administrivia to: pythonmac-sig-request@python.org _______________ From guido@CNRI.Reston.Va.US Mon Jul 14 18:03:32 1997 From: guido@CNRI.Reston.Va.US (Guido van Rossum) Date: Mon, 14 Jul 1997 13:03:32 -0400 Subject: [PYTHONMAC-SIG] Some Mac-Specific Python Questions In-Reply-To: Your message of "Mon, 14 Jul 1997 12:27:17 EDT." References: Message-ID: <199707141703.NAA28134@eric.CNRI.Reston.Va.US> > - GRAIL: Anyone know what's needed to get Grail to work successfully on a > Mac? It starts for me, opens the local file, but when I try to use an http > URL, it just sits there and I have to force an application close. For me, all that's needed is an already established Internet connection. If your Telnet client works, Grail should work. I have successfully used it on a 68k Mac with MacOS 7.1.1 and on a PPC Mac with MacOS 7.5.5. The latter has Open Transport installed, as far as I can tell (but I'm no expert in MacOS any more). > (BTW, is it too soon to ask when a Mac 1.5 is going to be available?) An alpha was announced for PSA members. --Guido van Rossum (home page: http://www.python.org/~guido/) _______________ PYTHONMAC-SIG - SIG on Python for the Apple Macintosh send messages to: pythonmac-sig@python.org administrivia to: pythonmac-sig-request@python.org _______________ From doug@sonosphere.com Tue Jul 15 01:33:55 1997 From: doug@sonosphere.com (Doug Wyatt) Date: Mon, 14 Jul 1997 20:33:55 -0400 Subject: [PYTHONMAC-SIG] os.rmdir() In-Reply-To: <199707141703.NAA28134@eric.CNRI.Reston.Va.US> References: Your message of "Mon, 14 Jul 1997 12:27:17 EDT." Message-ID: Hello all, I'm trying to delete a directory in a Python program (in preparation for unstuffing a new copy of it...) I find that os.rmdir() fails with an unknown error 16. I tried writing this little function to empty out a folder before deleting it. It half-worked; one large portion of the tree was deleted, including many subdirectories, but still rmdir() refused to delete one directory which the Finder had no trouble trashing (so the directory was not corrupt). def myrmdir(dirpath): #print 'deleting children of',dirpath if dirpath[-1] == os.sep: dirpath = dirpath[:-1] items = os.listdir(dirpath) for f in items: if f == '.' or f == '..': continue path = dirpath + os.sep + f if os.path.isdir(path): myrmdir(path) else: #print 'deleting',path os.unlink(path) print 'deleting',dirpath os.rmdir(dirpath) Any ideas? Shall I dig into the source? Doug --- Doug Wyatt music [,] software doug@sonosphere.com http://www.sonosphere.com/ new streaming audio samples: http://www.sonosphere.com/doug/music.html _______________ PYTHONMAC-SIG - SIG on Python for the Apple Macintosh send messages to: pythonmac-sig@python.org administrivia to: pythonmac-sig-request@python.org _______________ From guido@CNRI.Reston.Va.US Tue Jul 15 03:55:14 1997 From: guido@CNRI.Reston.Va.US (Guido van Rossum) Date: Mon, 14 Jul 1997 22:55:14 -0400 Subject: [PYTHONMAC-SIG] os.rmdir() In-Reply-To: Your message of "Mon, 14 Jul 1997 20:33:55 EDT." References: Your message of "Mon, 14 Jul 1997 12:27:17 EDT." Message-ID: <199707150255.WAA28811@eric.CNRI.Reston.Va.US> > I'm trying to delete a directory in a Python program (in preparation for > unstuffing a new copy of it...) > > I find that os.rmdir() fails with an unknown error 16. > > I tried writing this little function to empty out a folder before deleting > it. It half-worked; one large portion of the tree was deleted, including > many subdirectories, but still rmdir() refused to delete one directory > which the Finder had no trouble trashing (so the directory was not corrupt). Could it be that there is a hidden or locked file in there, or a file that's in use? Which operation fails? The unlink or the rmdir? A few nits on your code: > def myrmdir(dirpath): > #print 'deleting children of',dirpath > if dirpath[-1] == os.sep: dirpath = dirpath[:-1] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Sure you need this? > items = os.listdir(dirpath) > for f in items: > if f == '.' or f == '..': continue ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unnecessary; listdir no longer returns . or .. (and these are unixisms anyway -- on the mac they would be : and :: and would never be returned by listdir) > path = dirpath + os.sep + f Correct is: path = os.path.join(dirpath, f) > if os.path.isdir(path): > myrmdir(path) > else: > #print 'deleting',path > os.unlink(path) > print 'deleting',dirpath > os.rmdir(dirpath) And finally... > Any ideas? Shall I dig into the source? Of what? It's almost certainly an OS issue, not a bug in rmdir. --Guido van Rossum (home page: http://www.python.org/~guido/) _______________ PYTHONMAC-SIG - SIG on Python for the Apple Macintosh send messages to: pythonmac-sig@python.org administrivia to: pythonmac-sig-request@python.org _______________ From doug@sonosphere.com Tue Jul 15 04:17:55 1997 From: doug@sonosphere.com (Doug Wyatt) Date: Mon, 14 Jul 1997 23:17:55 -0400 Subject: [PYTHONMAC-SIG] P.S. os.rmdir() Message-ID: As usual there's nothing like posting a request for help to make one feel silly enough to dig further oneself :) I did a TVB in Macsbug on HDelete and discovered that it's returning -47, and GUSI is looking to see whether the directory's empty, returning 16 if it is (a busy error) or 66 if it's not (directory not empty). I quit Python and restarted it and was able to delete the directory. This tells me that some Python component made a working directory for the folder being deleted. I think this may have been from an earlier action where I was sending AppleEvents to CodeWarrior, telling it to open project files that were in the directory that couldn't be deleted. CWGUSI 1.8 contains no calls to OpenWD. The Python source contains one, in opendir.c's opendir(). In Python's C source, closedir() seems to always get called after opendir(), except in the case of an out-of-memory failure. ... Doug ~~~~~~~~~~~~~~~~~~~~~~~~~~~ Hello all, I'm trying to delete a directory in a Python program (in preparation for unstuffing a new copy of it...) I find that os.rmdir() fails with an unknown error 16. I tried writing this little function to empty out a folder before deleting it. It half-worked; one large portion of the tree was deleted, including many subdirectories, but still rmdir() refused to delete one directory which the Finder had no trouble trashing (so the directory was not corrupt). def myrmdir(dirpath): #print 'deleting children of',dirpath if dirpath[-1] == os.sep: dirpath = dirpath[:-1] items = os.listdir(dirpath) for f in items: if f == '.' or f == '..': continue path = dirpath + os.sep + f if os.path.isdir(path): myrmdir(path) else: #print 'deleting',path os.unlink(path) print 'deleting',dirpath os.rmdir(dirpath) Any ideas? Shall I dig into the source? Doug --- Doug Wyatt music [,] software doug@sonosphere.com http://www.sonosphere.com/ new streaming audio samples: http://www.sonosphere.com/doug/music.html _______________ PYTHONMAC-SIG - SIG on Python for the Apple Macintosh send messages to: pythonmac-sig@python.org administrivia to: pythonmac-sig-request@python.org _______________ From Jack.Jansen@cwi.nl Wed Jul 30 15:05:18 1997 From: Jack.Jansen@cwi.nl (Jack Jansen) Date: Wed, 30 Jul 1997 16:05:18 +0200 Subject: [PYTHONMAC-SIG] Project organization Message-ID: Folks, here's a question for those of you who build MacPython from source. With the arrival of CW Pro and multi-target projects and subprojects I was planning to change the python build structure to more closely match the unix build structure. However, looking at it more closely I'm not sure that it really buys something, so now I'm thinking of more-or-less kepping the current structure, except that the pythoncore, python and pythonapplet projects will build ppc/cfm68k/fat versions. Comments? Would anything be gained by adhering more to the unix structure? -- Jack Jansen | ++++ stop the execution of Mumia Abu-Jamal ++++ Jack.Jansen@cwi.nl | ++++ if you agree copy these lines to your sig ++++ http://www.cwi.nl/~jack | see http://www.xs4all.nl/~tank/spg-l/sigaction.htm ------- End of Forwarded Message _______________ PYTHONMAC-SIG - SIG on Python for the Apple Macintosh send messages to: pythonmac-sig@python.org administrivia to: pythonmac-sig-request@python.org _______________