All,
Just wanted to share some information that might save many of you a lot of headache researching issues like this... Stefan, you may think of ways of fixing this in 'ftputil' as well...
On way too many occasions I saw following situation:
Many FTP servers are configured in such a way that LOGIN directory is completely different from "root" user directory. In fact, I found that many servers "drop" you into system ROOT ('/') directory upon login. When this is the case (when current working directory is the one to which user does not have sufficient access) - many ftputil calls (like listdir(), getcwd(), etc.) fail with ftputil.ftp_error.PermanentError (either "550 Permission denied" or "550 <EXISTING PATH>: no such directory"). This completely prevents any attempts to get or put file(s).
One possible solution to this is to explicitly STEP ("cd") into any directory that belongs to current user's account (where user has sufficient permissions) and work from there.
Hope this help.
Valeriy Pogrebitskiy
E-Mail: vpogrebi at iname.com
Work: (908) 608-3137
Alexander Michael <lxander.m at gmail.com>
Sent by: ftputil-bounces at codespeak.net
To
ftputil at codespeak.net
10/20/2005 02:56 PM cc
Subject
[ftputil] Issue with Hidden Directories
I am attempting to use ftputil (version 2.0.3) with Python 2.4.1 to pull files from a data vendor's server [331-(220 pawn Microsoft FTP Service (Version 5.0).)], but ran into a small issue. Here's what the failure looks like:
Traceback (most recent call last):
File "updatefiles.py", line 210, in cli
outgoingdir=ostools.nativepath(opts.outgoing_dir))
File "updatefiles.py", line 128, in update
ftp_update(basedir, host, proxy, outgoingdir)
File "updatefiles.py", line 91, in ftp_update
filenames = host.listdir('')
File "C:\Python24\Lib\site-packages\ftputil\ftputil.py", line 634, in listdir
return self._stat.listdir(path)
File "C:\Python24\Lib\site-packages\ftputil\ftp_stat.py", line 115, in listdir
raise ftp_error.PermanentError("550 %s: no such directory" % path)
PermanentError: 550 /johndoe: no such directory
Looking around "C:\Python24\Lib\site-packages\ftputil\ftp_stat.py", line 115, I see:
path = self._path.abspath(path)
if not self._path.isdir(path):
raise ftp_error.PermanentError("550 %s: no such directory" % path)
I think the issue revolves around the fact the vendor has the FTP account setup so that I get dropped into a subdirectory (with the same name as my username), but the directory isn't visible one level up. As result, the lstat method fails to determine that path is a directory. After changing the above to be:
path = self._path.abspath(path)
if path != self._host.getcwd() and not self._path.isdir(path):
raise ftp_error.PermanentError("550 %s: no such directory" % path)
so that it doesn't fail for the current working directory, everything works great. I'm not sure if there is a better or more efficient way to be robust to this situation, but this worked for me. I am not sure if I can rest assured that the current working directory is in fact a directory, but it seems to make some sense.
Thanks for making this useful module available (and under a nice license).
Regards,
Alex_______________________________________________
ftputil mailing list
ftputil at codespeak.net
http://codespeak.net/mailman/listinfo/ftputil
--
This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden.