[Pythonmac-SIG] FTPing a mac file - loosing resource fork?

Sean Hummel seanh@unforgettable.com
Fri, 23 Apr 1999 05:21:46 -0700


The majority of the problem you are having is likely due to the fact 
that the file on the server was uploaded as a binary file.  Not using 
one of the Macintosh flat file formats.    (i.e.  HQX or MacBinary)  
Thus the file on the server doesn't have a resource fork.  

When you upload the file, upload it as an "HQX" file, and use the 
Python "binhex" module to turn it back into a Macintosh file, after it 
is downloaded.

As far as automatically "Unstuffing" the file, there are many routes, 
you could create an Applescript and tell "Stuffit Expander" to 
decompress the file.  

Or you could use the AE module to send appleevents directly to the 
Stuffit Expander module.  




On Fri, 23 Apr 1999 07:56:53 -0400 "Chris,Mann" <cmann@pobox.com> wrote:

> Hello -
>     I've just started using python, and the first thing I'm trying to do is
> write a little script that retrieves a mac file from an FTP site (it's
> actually a .sea file).
>     Just when I thought I had everything working, I ran into a bit of a
> snag.  I'm using the provided ftplib and everything seems to work fine,
> except that the file looses it's resource fork.  Any ideas what I'm doing
> wrong?
> 
> Here's the code (ftp_site is a dictionary of values that I pass in):
> 
> def get_remote(self, ftp_site):
>   # open a local file so we have something to write the ftp data to
>   fileID = open(ftp_site['localdir'] + ftp_site['file'] , 'wb')
> 
>   from ftplib import FTP
> 
>   print 'Retrieving ' + ftp_site['file'] + ' to ' + ftp_site['localdir']
> 
>   # open the site, set pasv transfer mode, and login
>   ftp = FTP(ftp_site['host'])
>   ftp.set_pasv(ftp_site['pasv'])
>   ftp.login(ftp_site['user'], ftp_site['password'])
>   # change to correct dir, check size, and retrieve
>   ftp.cwd(ftp_site['remotedir'])
>   if ftp.size(ftp_site['file']) <= 1000: # know file is always greater then
> a meg
>    print  'The file appears to be corrupted'
>   ftp.retrbinary('RETR ' + ftp_site['file'], fileID.write, 1024)
>   # cleanup
>   fileID.close()
>   ftp.close()
> 
> Also, is there a module to decode stuffit compressed files?  I had thought
> about wrapping the stuffit expander OSAX into a module, but that seems a bit
> roundabout.
> 
> thanks
> -chris
> 
> _______________________________________________
> Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
> http://www.python.org/mailman/listinfo/pythonmac-sig
> 

----------------------
Sean Hummel
seanh@unforgettable.com