[Zope] using python ftplib with zope

Tuttle, Gene cetuttle at rottlundhomes.com
Fri Jul 9 12:07:52 EDT 2004


I am having problems using ftp to down load objects from zope using python
ftplib module.
I appear to get authorized ok but then keep getting the message 530
Unauthorized when any ftp command is used.
I can login as the same user using interactive ftp and download the same
object.

Thanks in advance for any advice/help.  Gene Tuttle


here is the debug information:

Downloading Request.2004-07-08.0254375768
*get* '220 mplssrv2.rottlundhomes.com FTP server (Medusa Async V1.23
[experiment
al]) ready.\r\n'
*resp* '220 mplssrv2.rottlundhomes.com FTP server (Medusa Async V1.23
[experimen
tal]) ready.'
*cmd* 'USER cettuttle'
*put* 'USER cettuttle\r\n'
*get* '331 Password required.\r\n'
*resp* '331 Password required.'
*cmd* 'PASS ********'
*put* 'PASS ********\r\n'
*get* '230 Login successful.\r\n'
*resp* '230 Login successful.'
*cmd* 'CWD .'
*put* 'CWD .\r\n'
*get* '530 Unauthorized.\r\n'
*resp* '530 Unauthorized.'
Traceback (most recent call last):
  File "M:\Projects\PythonScripts\getfile.py", line 43, in ?
    if __name__ == '__main__': getfile()
  File "M:\Projects\PythonScripts\getfile.py", line 36, in getfile
    remote.cwd(dire)
  File "C:\Python23\lib\ftplib.py", line 494, in cwd
    return self.voidcmd(cmd)
  File "C:\Python23\lib\ftplib.py", line 246, in voidcmd
    return self.voidresp()
  File "C:\Python23\lib\ftplib.py", line 221, in voidresp
    resp = self.getresp()
  File "C:\Python23\lib\ftplib.py", line 214, in getresp
    raise error_perm, resp
ftplib.error_perm: 530 Unauthorized.




The script I am using:


#!/usr/local/bin/python
######################################################################
#
# Script to download all of the requests form web sites
#
######################################################################


import os
from ftplib import FTP
from os.path import exists

file = 'Request.2004-07-08.0254375768'
site = 'mplssrv2'
port = 8321
dire = ''
user = ('cettuttle', '********')


def getfile(file=file, site=site, dire=dire, user=user, verbose=1, force=0):
	"""
	fetch a file by ftp for a site/directory
	anonymous or real login, binary transfer
	"""
	if exists(file) and not force:
		if verbose: print file, 'already fetched'
	else:
		if verbose: print 'Downloading', file
		local = open(file, 'wb')
		try:
			remote = FTP()
			remote.set_debuglevel(2)
			remote.connect(site, port)
			apply(remote.login, user)
			remote.cwd(dire)
<---line 36
			remote.retrbinary('RETR ' + file, local.write, 1024)
			remote.quit()
		finally:
			local.close()
		if verbose: print 'Download done. '

if __name__ == '__main__': getfile()


More information about the Zope mailing list