Python & CuteFTP TE COM Object Anyone?!

Brian Lenihan brian_l at yahoo.com
Fri May 17 22:14:58 EDT 2002


"Peter F. Ferris" <pferris at pferris.com> wrote in message news:<mailman.1021637848.20175.python-list at python.org>...
> : > Does anybody on the list have any experience with the Windows GUI app
> : > "CuteFTP" (Pro or not) and scripting with Python.
> :
> : I'm afraid not.  What advantages would it have over just using the
> : standard Python FTP support directly?
> 
> It allows pretty painless scheduling of transfers, synchronizing of
> directories, fairly sophisticated rules with easy interface, etc. Point &
> click for the most part.

Unfortunately, few of the features you mention were available via the
COM interface in CuteFTP Pro 1.0.  The CuteConnection object referred
to in some of the sample scripts appears to have been replaced by the
TEConnection object, which had little in the way of features and did
not provide any way to detect or handle errors.

I use CuteFTP Pro to help keep a Web site updated for a friend who is
off sailing around the World.  I use it for exactly the same reasons
you mention. I was disappointed to find out I couldn't automate the
entire process. Or, more precisely, I couldn't automate the process
and know that any error conditions were going to be handled correctly.

I ended up with a semi-automated 3-step process which requires that
I manually validate the results of each step before continuing on to
the next step. In reality, I'm probably stuck anyway, unless anyone
can tell me where to get a perfect spell-checker which includes all
known place names (complete with local spelling variations).

After seeing your request, I decided to revist the COM interface in
Cute FTP Pro 2.0. The interface seems to have expanded quite a
bit, although it still has some problems with error conditions.

Here is sample.vbs converted to Python.

-----------
import sys
import win32com.client

MySite = win32com.client.Dispatch('CuteFTPPro.TEConnection')

MySite.Protocol = 'FTP'
MySite.Host = 'ftp.cuteftp.com'
MySite.Login = 'anonymous'
MySite.Password = 'user at user.com'
MySite.UseProxy = 'BOTH'
MySite.Connect()

if not MySite.IsConnected:
    print 'Could not connect to: %s Aborting!' % MySite.Host
    sys.exit(1)
else:
    print 'You are now connected to: %s' % MySite.Host

if not MySite.LocalExists('c:/temp1'):
    MySite.CreateLocalFolder('c:/temp1')
MySite.LocalFolder = 'c:/temp1'

if not MySite.RemoteExists('Pub'):
    print 'Remote folder not found!. Please make sure that the Pub
folder exists on the remote site.'
    sys.exit(1)

MySite.Download('Pub/cuteftp/index.txt')
print 'index.txt was successfully downloaded to c:/temp1/index.txt'

if MySite.LocalExists('TOC.txt'):
    MySite.LocalRemove('TOC.txt')
    print 'Previous version of TOC.txt deleted'

MySite.LocalRename('index.txt','TOC.txt')
print 'File renamed, Sample script completed.'

MySite.Disconnect()
MySite.TECommand('exit')
print MySite.Status
----------

The API is documented in the TEsdk help file.



More information about the Python-list mailing list