From trac at ftputil.sschwarzer.net Sun Jul 5 10:16:27 2009 From: trac at ftputil.sschwarzer.net (ftputil) Date: Sun, 05 Jul 2009 08:16:27 -0000 Subject: [ftputil] #33: FTPHost.listdir fails for some servers if the path contains slashes In-Reply-To: <052.77e459a3c512522aea2e27ad81011eb2@ftputil.sschwarzer.net> References: <052.77e459a3c512522aea2e27ad81011eb2@ftputil.sschwarzer.net> Message-ID: <061.71c406d0fed0facd26f2894c7e86de72@ftputil.sschwarzer.net> #33: FTPHost.listdir fails for some servers if the path contains slashes --------------------------+------------------------------------------------- Reporter: ftputiluser | Owner: schwa Type: defect | Status: assigned Priority: major | Milestone: Component: Library | Version: 2.4 Resolution: | Keywords: listdir, change directory, special_case --------------------------+------------------------------------------------- Comment (by ftputiluser): Hi Stefan, sorry for the late response I see only now your response, here is the code: standard ftputil special_case is not ever applied {{{ In [1]: import ftputil In [2]: conn=ftputil.FTPHost('ftp.gnome.org','anonymous','pippo at pippo.com') In [3]: conn.listdir('/') Out[3]: ['pub'] In [4]: conn=ftputil.FTPHost('ftp.sunfreeware.com','anonymous','pippo at pippo.com') In [5]: conn.listdir('/') Out[5]: ['bin', 'dev', 'etc', 'pub', 'usr'] }}} patched ftputil special_case is always True: {{{ import ftputil In [2]: conn=ftputil.FTPHost('ftp.gnome.org','anonymous','pippo at pippo.com') In [3]: conn.listdir('/') Out[3]: ['HEADER.html', 'Public', 'about', 'cdimage', 'conspiracy', 'debian', 'debian-cd', 'debian-non-US', 'favicon.ico', 'mirror', 'pub', 'releases', 'robots.txt', 'ubuntu', 'welcome.msg', 'welcome2.msg'] In [4]: conn=ftputil.FTPHost('ftp.sunfreeware.com','anonymous','pippo at pippo.com') In [5]: In [6]: In [7]: conn.listdir('/') --------------------------------------------------------------------------- ParserError Traceback (most recent call last) /home/nicola/workspace/FtpManager/ /home/nicola/workspace/FtpManager/extlib/ftputil/ftputil.py in listdir(self, path) 806 any of the available parsers raise a `ParserError`. 807 """ --> 808 return self._stat.listdir(path) 809 810 def lstat(self, path, _exception_for_missing_path=True): /home/nicola/workspace/FtpManager/extlib/ftputil/ftp_stat.pyc in listdir(self, path) 563 the server (e. g. timeout). 564 """ --> 565 return self.__call_with_parser_retry(self._real_listdir, path) 566 567 def lstat(self, path, _exception_for_missing_path=True): /home/nicola/workspace/FtpManager/extlib/ftputil/ftp_stat.pyc in __call_with_parser_retry(self, method, *args, **kwargs) 551 self._allow_parser_switching = False 552 self._parser = MSParser() --> 553 return method(*args, **kwargs) 554 else: 555 raise /home/nicola/workspace/FtpManager/extlib/ftputil/ftp_stat.pyc in _real_listdir(self, path) 418 # correct timestamp values in the cache 419 stat_result = self._parser.parse_line(line, --> 420 self._host.time_shift()) 421 loop_path = self._path.join(path, stat_result._st_name) 422 self._lstat_cache[loop_path] = stat_result /home/nicola/workspace/FtpManager/extlib/ftputil/ftp_stat.pyc in parse_line(self, line, time_shift) 349 st_size = int(dir_or_size) 350 except ValueError: --> 351 raise ftp_error.ParserError("invalid size %s" % dir_or_size) 352 else: 353 st_size = None ParserError: invalid size staff Debugging info: ftputil 2.4.1, Python 2.4.3 (linux2) }}} Nicola -- Ticket URL: ftputil Python FTP client library From trac at ftputil.sschwarzer.net Wed Jul 8 16:14:24 2009 From: trac at ftputil.sschwarzer.net (ftputil) Date: Wed, 08 Jul 2009 14:14:24 -0000 Subject: [ftputil] #33: FTPHost.listdir fails for some servers if the path contains slashes In-Reply-To: <052.77e459a3c512522aea2e27ad81011eb2@ftputil.sschwarzer.net> References: <052.77e459a3c512522aea2e27ad81011eb2@ftputil.sschwarzer.net> Message-ID: <061.bf92844b72db53d526b61ccc5a2f4370@ftputil.sschwarzer.net> #33: FTPHost.listdir fails for some servers if the path contains slashes --------------------------+------------------------------------------------- Reporter: ftputiluser | Owner: schwa Type: defect | Status: assigned Priority: major | Milestone: Component: Library | Version: 2.4 Resolution: | Keywords: listdir, change directory, special_case --------------------------+------------------------------------------------- Comment (by schwa): Hi Nicola, thanks for following up. :-) I tracked the problem down to this: {{{ >>> import ftplib >>> f = ftplib.FTP("ftp.sunfreeware.com", "anonymous", "sschwarzer at sschwarzer.net") >>> f.dir("/") total 10 lrwxrwxrwx 1 staff 7 Aug 13 2003 bin -> usr/bin d--x--x--x 2 staff 512 Sep 24 2000 dev d--x--x--x 3 staff 512 Sep 25 2000 etc dr-xr-xr-x 3 staff 512 Oct 3 2000 pub d--x--x--x 5 staff 512 Oct 3 2000 usr >>> f.dir(".") lrwxrwxrwx 1 staff 7 Aug 13 2003 bin -> usr/bin dev: total 10 etc: total 10 pub: total 4 -rw-r--r-- 1 staff 74 Sep 25 2000 .message ---------- 1 staff 0 Aug 16 2003 .notar drwxr-xr-x 12 ftp 512 Nov 23 2008 freeware usr: total 4 >>> }}} With the absolute path "/" as argument, the listing is retrieved as expected. With the relative path "." the server recurses down the current directory. I'll see if I can find a clean way to deal with this. Stefan -- Ticket URL: ftputil Python FTP client library From trac at ftputil.sschwarzer.net Wed Jul 8 16:48:24 2009 From: trac at ftputil.sschwarzer.net (ftputil) Date: Wed, 08 Jul 2009 14:48:24 -0000 Subject: [ftputil] #33: FTPHost.listdir fails for some servers if the path contains slashes In-Reply-To: <052.77e459a3c512522aea2e27ad81011eb2@ftputil.sschwarzer.net> References: <052.77e459a3c512522aea2e27ad81011eb2@ftputil.sschwarzer.net> Message-ID: <061.c98e7f1fbe307b601e3adda7c563d175@ftputil.sschwarzer.net> #33: FTPHost.listdir fails for some servers if the path contains slashes --------------------------+------------------------------------------------- Reporter: ftputiluser | Owner: schwa Type: defect | Status: assigned Priority: major | Milestone: Component: Library | Version: 2.4 Resolution: | Keywords: listdir, change directory, special_case --------------------------+------------------------------------------------- Comment (by schwa): Seen from a slightly more low-level perspective: {{{ $ ftp -d ftp.sunfreeware.com ... ftp> dir / ftp: setsockopt (ignored): Permission denied ---> PORT 192,168,178,128,195,19 200 PORT command successful. ---> LIST / 150 Opening ASCII mode data connection for /bin/ls. total 10 lrwxrwxrwx 1 staff 7 Aug 13 2003 bin -> usr/bin d--x--x--x 2 staff 512 Sep 24 2000 dev d--x--x--x 3 staff 512 Sep 25 2000 etc dr-xr-xr-x 3 staff 512 Oct 3 2000 pub d--x--x--x 5 staff 512 Oct 3 2000 usr 226 Transfer complete. ftp> dir . ftp: setsockopt (ignored): Permission denied ---> PORT 192,168,178,128,198,136 200 PORT command successful. ---> LIST . 150 Opening ASCII mode data connection for /bin/ls. lrwxrwxrwx 1 staff 7 Aug 13 2003 bin -> usr/bin dev: total 10 etc: total 10 pub: total 4 -rw-r--r-- 1 staff 74 Sep 25 2000 .message ---------- 1 staff 0 Aug 16 2003 .notar drwxr-xr-x 12 ftp 512 Nov 23 2008 freeware usr: total 4 226 Transfer complete. ftp> dir ftp: setsockopt (ignored): Permission denied ---> PORT 192,168,178,128,228,219 200 PORT command successful. ---> LIST 150 Opening ASCII mode data connection for /bin/ls. total 10 lrwxrwxrwx 1 staff 7 Aug 13 2003 bin -> usr/bin d--x--x--x 2 staff 512 Sep 24 2000 dev d--x--x--x 3 staff 512 Sep 25 2000 etc dr-xr-xr-x 3 staff 512 Oct 3 2000 pub d--x--x--x 5 staff 512 Oct 3 2000 usr 226 Transfer complete. }}} Using no arguments after {{{dir}}} gives the same output as with "/" as argument whereas using "." as argument triggers the recursion. -- Ticket URL: ftputil Python FTP client library From trac at ftputil.sschwarzer.net Wed Jul 8 21:18:49 2009 From: trac at ftputil.sschwarzer.net (ftputil) Date: Wed, 08 Jul 2009 19:18:49 -0000 Subject: [ftputil] #33: FTPHost.listdir fails for some servers if the path contains slashes In-Reply-To: <052.77e459a3c512522aea2e27ad81011eb2@ftputil.sschwarzer.net> References: <052.77e459a3c512522aea2e27ad81011eb2@ftputil.sschwarzer.net> Message-ID: <061.72fc4f49e9c2f8fa2fc3009df25d0431@ftputil.sschwarzer.net> #33: FTPHost.listdir fails for some servers if the path contains slashes --------------------------+------------------------------------------------- Reporter: ftputiluser | Owner: schwa Type: defect | Status: assigned Priority: major | Milestone: Component: Library | Version: 2.4 Resolution: | Keywords: listdir, change directory, special_case --------------------------+------------------------------------------------- Comment (by schwa): Hi Nicola, I committed a changeset [changeset:876] which should fix the problem. The former "special case" is now the default as you had originally suggested; {{{FTPHost._robust_ftp_command}}} is simplified a bit. Please get the [browser:trunk/ftputil.py at 876 corresponding version] of {{{ftputil.py}}}, test it and give feedback. Note: You only need {{{ftputil.py}}}; the other changes are only to test code. Thanks for your help! :o) Stefan -- Ticket URL: ftputil Python FTP client library From trac at ftputil.sschwarzer.net Wed Jul 8 21:21:12 2009 From: trac at ftputil.sschwarzer.net (ftputil) Date: Wed, 08 Jul 2009 19:21:12 -0000 Subject: [ftputil] #33: FTPHost.listdir fails for some servers if the path contains slashes In-Reply-To: <052.77e459a3c512522aea2e27ad81011eb2@ftputil.sschwarzer.net> References: <052.77e459a3c512522aea2e27ad81011eb2@ftputil.sschwarzer.net> Message-ID: <061.e2610da83356bbd6a5c0c646b26405f7@ftputil.sschwarzer.net> #33: FTPHost.listdir fails for some servers if the path contains slashes --------------------------+------------------------------------------------- Reporter: ftputiluser | Owner: schwa Type: defect | Status: assigned Priority: major | Milestone: Component: Library | Version: 2.4 Resolution: | Keywords: listdir, change directory, special_case --------------------------+------------------------------------------------- Comment (by schwa): Note: The patch should fix both problems, ''both'' ftp.gnome.org ''and'' ftp.sunfreeware.com should now behave as expected. -- Ticket URL: ftputil Python FTP client library From trac at ftputil.sschwarzer.net Fri Jul 10 21:35:55 2009 From: trac at ftputil.sschwarzer.net (ftputil) Date: Fri, 10 Jul 2009 19:35:55 -0000 Subject: [ftputil] #33: FTPHost.listdir fails for some servers if the path contains slashes In-Reply-To: <052.77e459a3c512522aea2e27ad81011eb2@ftputil.sschwarzer.net> References: <052.77e459a3c512522aea2e27ad81011eb2@ftputil.sschwarzer.net> Message-ID: <061.6f84093b34a3c07b23c2eb53ab303afb@ftputil.sschwarzer.net> #33: FTPHost.listdir fails for some servers if the path contains slashes --------------------------+------------------------------------------------- Reporter: ftputiluser | Owner: schwa Type: defect | Status: closed Priority: major | Milestone: Component: Library | Version: 2.4 Resolution: fixed | Keywords: listdir, change directory, special_case --------------------------+------------------------------------------------- Changes (by ftputiluser): * status: assigned => closed * resolution: => fixed Comment: Thanks Stefan, the fix seems fine, Nicola -- Ticket URL: ftputil Python FTP client library From trac at ftputil.sschwarzer.net Mon Jul 13 15:03:52 2009 From: trac at ftputil.sschwarzer.net (ftputil) Date: Mon, 13 Jul 2009 13:03:52 -0000 Subject: [ftputil] #35: Ftputil broken with some links In-Reply-To: <052.62b04054176d28acac22a3af65d17632@ftputil.sschwarzer.net> References: <052.62b04054176d28acac22a3af65d17632@ftputil.sschwarzer.net> Message-ID: <061.b4ce05205485f5fa8ee2109c334e512e@ftputil.sschwarzer.net> #35: Ftputil broken with some links --------------------------+------------------------------------------------- Reporter: ftputiluser | Owner: schwa Type: defect | Status: closed Priority: major | Milestone: 2.4.2 Component: Library | Version: 2.4 Resolution: fixed | Keywords: listdir, link, ./ --------------------------+------------------------------------------------- Changes (by schwa): * status: assigned => closed * resolution: => fixed * milestone: => 2.4.2 Comment: It seems this bug is implicitly fixed by the change which already fixed bug #33. :-) -- Ticket URL: ftputil Python FTP client library From trac at ftputil.sschwarzer.net Mon Jul 13 15:07:09 2009 From: trac at ftputil.sschwarzer.net (ftputil) Date: Mon, 13 Jul 2009 13:07:09 -0000 Subject: [ftputil] #33: FTPHost.listdir fails for some servers if the path contains slashes In-Reply-To: <052.77e459a3c512522aea2e27ad81011eb2@ftputil.sschwarzer.net> References: <052.77e459a3c512522aea2e27ad81011eb2@ftputil.sschwarzer.net> Message-ID: <061.7b61cd43182e49555390ffefc72337f0@ftputil.sschwarzer.net> #33: FTPHost.listdir fails for some servers if the path contains slashes --------------------------+------------------------------------------------- Reporter: ftputiluser | Owner: schwa Type: defect | Status: closed Priority: major | Milestone: 2.4.2 Component: Library | Version: 2.4 Resolution: fixed | Keywords: listdir, change directory, special_case --------------------------+------------------------------------------------- Changes (by schwa): * milestone: => 2.4.2 -- Ticket URL: ftputil Python FTP client library From trac at ftputil.sschwarzer.net Mon Jul 20 11:38:54 2009 From: trac at ftputil.sschwarzer.net (ftputil) Date: Mon, 20 Jul 2009 09:38:54 -0000 Subject: [ftputil] #38: If cache size is zero, FTPHost.listdir causes an IndexError Message-ID: <046.a895107faa36162a3070c91517bab32b@ftputil.sschwarzer.net> #38: If cache size is zero, FTPHost.listdir causes an IndexError ---------------------------------------+------------------------------------ Reporter: schwa | Owner: schwa Type: defect | Status: new Priority: minor | Milestone: 2.4.2 Component: Library | Version: 2.4.2b Keywords: cache, resize, IndexError | ---------------------------------------+------------------------------------ If the cache size for an {{{FTPHost}}} instance is explicitly set to zero, a following {{{listdir}}} call raises an {{{IndexError}}}: {{{ >>> import ftputil >>> host = ftputil.FTPHost("ftp.debian.org", "anonymous", "foo at example.com") >>> host.stat_cache.resize(0) >>> host.listdir(host.curdir) Traceback (most recent call last): File "", line 1, in File "ftputil.py", line 795, in listdir return self._stat.listdir(path) File "ftp_stat.py", line 565, in listdir return self.__call_with_parser_retry(self._real_listdir, path) File "ftp_stat.py", line 543, in __call_with_parser_retry result = method(*args, **kwargs) File "ftp_stat.py", line 422, in _real_listdir self._lstat_cache[loop_path] = stat_result File "ftp_stat_cache.py", line 168, in __setitem__ self._cache[path] = stat_result File "lrucache.py", line 164, in __setitem__ lru = heappop(self.__heap) IndexError: index out of range }}} On the other hand, disabling the cache explicitly doesn't raise an exception: {{{ >>> host.stat_cache.disable() >>> host.listdir(host.curdir) ['debian'] }}} -- Ticket URL: ftputil Python FTP client library From trac at ftputil.sschwarzer.net Mon Jul 20 12:01:12 2009 From: trac at ftputil.sschwarzer.net (ftputil) Date: Mon, 20 Jul 2009 10:01:12 -0000 Subject: [ftputil] #38: If cache size is zero, FTPHost.listdir causes an IndexError In-Reply-To: <046.a895107faa36162a3070c91517bab32b@ftputil.sschwarzer.net> References: <046.a895107faa36162a3070c91517bab32b@ftputil.sschwarzer.net> Message-ID: <055.34bbf6a2700b18e16cce735cf7c326dc@ftputil.sschwarzer.net> #38: If cache size is zero, FTPHost.listdir causes an IndexError ----------------------+----------------------------------------------------- Reporter: schwa | Owner: schwa Type: defect | Status: assigned Priority: minor | Milestone: 2.4.2 Component: Library | Version: 2.4.2b Resolution: | Keywords: cache, resize, IndexError ----------------------+----------------------------------------------------- Changes (by schwa): * status: new => assigned Comment: One can notice a corresponding behavior in the lrucache module itself: {{{ >>> import lrucache >>> c = lrucache.LRUCache() >>> c.size = 0 >>> c[1] = 2 Traceback (most recent call last): File "", line 1, in File "lrucache.py", line 164, in __setitem__ lru = heappop(self.__heap) IndexError: index out of range }}} I guess, it's a question of philosophy if trying to store an item in a ''zero-sized'' cache should be considered a bug. In my opinion, this should be handled transparently, as if the cache was full. It shouldn't raise an exception, but perhaps effectively discard the to-be cache entry (in the same way older entries are discarded from the cache when it's full and new entries arrive). -- Ticket URL: ftputil Python FTP client library From trac at ftputil.sschwarzer.net Mon Jul 20 13:15:21 2009 From: trac at ftputil.sschwarzer.net (ftputil) Date: Mon, 20 Jul 2009 11:15:21 -0000 Subject: [ftputil] #38: If cache size is zero, FTPHost.listdir causes an IndexError In-Reply-To: <046.a895107faa36162a3070c91517bab32b@ftputil.sschwarzer.net> References: <046.a895107faa36162a3070c91517bab32b@ftputil.sschwarzer.net> Message-ID: <055.211049235b171994e43c2d60040bec77@ftputil.sschwarzer.net> #38: If cache size is zero, FTPHost.listdir causes an IndexError ----------------------+----------------------------------------------------- Reporter: schwa | Owner: schwa Type: defect | Status: closed Priority: minor | Milestone: 2.4.2 Component: Library | Version: 2.4.2b Resolution: fixed | Keywords: cache, resize, IndexError ----------------------+----------------------------------------------------- Changes (by schwa): * status: assigned => closed * resolution: => fixed Comment: Fixed in changeset [changeset:882]. -- Ticket URL: ftputil Python FTP client library From trac at ftputil.sschwarzer.net Mon Jul 20 17:07:40 2009 From: trac at ftputil.sschwarzer.net (ftputil) Date: Mon, 20 Jul 2009 15:07:40 -0000 Subject: [ftputil] #35: Ftputil broken with some links In-Reply-To: <052.62b04054176d28acac22a3af65d17632@ftputil.sschwarzer.net> References: <052.62b04054176d28acac22a3af65d17632@ftputil.sschwarzer.net> Message-ID: <061.7c8fbafcb98fbcce4610f1119804c74d@ftputil.sschwarzer.net> #35: Ftputil broken with some links --------------------------+------------------------------------------------- Reporter: ftputiluser | Owner: schwa Type: defect | Status: reopened Priority: major | Milestone: 2.4.2 Component: Library | Version: 2.4 Resolution: | Keywords: listdir, link, ./ --------------------------+------------------------------------------------- Changes (by ftputiluser): * status: closed => reopened * resolution: fixed => Comment: Link to link are not yet correctly managed :-) {{{ conn=ftputil.FTPHost('mirror3.mirror.garr.it','anonymous','p at p.com') conn.path.isdir('/mirrors/zebra/') --------------------------------------------------------------------------- PermanentError Traceback (most recent call last) /home/nicola/workspace/FtpManager/ /home/nicola/workspace/FtpManager/extlib/ftputil/ftp_path.pyc in isdir(self, path) 142 return True 143 try: --> 144 stat_result = self._host.stat( 145 path, _exception_for_missing_path=False) 146 if stat_result is None: /home/nicola/workspace/FtpManager/extlib/ftputil/ftputil.pyc in stat(self, path, _exception_for_missing_path) 822 _not_ intended for use by ftputil clients.) 823 """ --> 824 return self._stat.stat(path, _exception_for_missing_path) 825 826 def walk(self, top, topdown=True, onerror=None): /home/nicola/workspace/FtpManager/extlib/ftputil/ftp_stat.pyc in stat(self, path, _exception_for_missing_path) 584 the server (e. g. timeout). 585 """ 586 return self.__call_with_parser_retry(self._real_stat, path, --> 587 _exception_for_missing_path) 588 /home/nicola/workspace/FtpManager/extlib/ftputil/ftp_stat.pyc in __call_with_parser_retry(self, method, *args, **kwargs) 541 # parser - which is wrong. 542 try: --> 543 result = method(*args, **kwargs) 544 # if a `listdir` call didn't find anything, we can't 545 # say anything about the usefulness of the parser /home/nicola/workspace/FtpManager/extlib/ftputil/ftp_stat.pyc in _real_stat(self, path, _exception_for_missing_path) 506 while True: 507 # stat the link if it is one, else the file/directory --> 508 lstat_result = self._real_lstat(path, _exception_for_missing_path) 509 if lstat_result is None: 510 return None /home/nicola/workspace/FtpManager/extlib/ftputil/ftp_stat.pyc in _real_lstat(self, path, _exception_for_missing_path) 458 # we want to collect as many stat results in the cache as 459 # possible --> 460 lines = self._host_dir(dirname) 461 for line in lines: 462 if self._parser.ignores_line(line): /home/nicola/workspace/FtpManager/extlib/ftputil/ftp_stat.pyc in _host_dir(self, path) 388 when applied to `path`. 389 """ --> 390 return self._host._dir(path) 391 392 def _real_listdir(self, path): /home/nicola/workspace/FtpManager/extlib/ftputil/ftputil.pyc in _dir(self, path) 779 return lines 780 lines = self._robust_ftp_command(_FTPHost_dir_command, path, --> 781 descend_deeply=True) 782 return lines 783 /home/nicola/workspace/FtpManager/extlib/ftputil/ftputil.pyc in _robust_ftp_command(self, command, path, descend_deeply) 562 if descend_deeply: 563 # invoke the command in (not: on) the deepest directory --> 564 self.chdir(path) 565 # workaround for some servers that give recursive 566 # listings when called with a dot as path; see issue #33, /home/nicola/workspace/FtpManager/extlib/ftputil/ftputil.pyc in chdir(self, path) 585 def chdir(self, path): 586 """Change the directory on the host.""" --> 587 ftp_error._try_with_oserror(self._session.cwd, path) 588 self._current_dir = self.path.normpath(self.path.join( 589 # use "old" current dir /home/nicola/workspace/FtpManager/extlib/ftputil/ftp_error.pyc in _try_with_oserror(callee, *args, **kwargs) 150 raise CommandNotImplementedError(*exc.args) 151 else: --> 152 raise PermanentError(*exc.args) 153 except ftplib.all_errors: 154 exc = sys.exc_info()[1] PermanentError: 550 /mirrors/1: No such file or directory Debugging info: ftputil 2.4.2b, Python 2.4.3 (linux2) }}} regards Nicola -- Ticket URL: ftputil Python FTP client library From trac at ftputil.sschwarzer.net Wed Jul 22 08:37:49 2009 From: trac at ftputil.sschwarzer.net (ftputil) Date: Wed, 22 Jul 2009 06:37:49 -0000 Subject: [ftputil] #39: isdir and isfile fail if they are applied to a link without existing target Message-ID: <046.151cda9261bb255dbb89643da68a69de@ftputil.sschwarzer.net> #39: isdir and isfile fail if they are applied to a link without existing target ------------------------------------------------------+--------------------- Reporter: schwa | Owner: schwa Type: defect | Status: new Priority: minor | Milestone: Component: Library | Version: 2.4.2b Keywords: islink, isdir, isfile, link, broken link | ------------------------------------------------------+--------------------- If isdir and isfile are used on a link whose target doesn't exist, they raise a !PermanentError though they should return False, similar to os.path.isdir/isfile. Example: {{{ >>> conn=ftputil.FTPHost('mirror3.mirror.garr.it','anonymous','p at p.com') >>> conn.path.islink("/mirrors/zebra") True >>> conn.lstat("/mirrors/zebra")._st_target '../1/zebra' >>> conn.path.exists("/mirrors/1") False >>> conn.path.isdir("/mirrors/zebra") Traceback (most recent call last): File "", line 1, in File "ftp_path.py", line 145, in isdir path, _exception_for_missing_path=False) File "ftputil.py", line 824, in stat return self._stat.stat(path, _exception_for_missing_path) File "ftp_stat.py", line 587, in stat _exception_for_missing_path) File "ftp_stat.py", line 543, in __call_with_parser_retry result = method(*args, **kwargs) File "ftp_stat.py", line 508, in _real_stat lstat_result = self._real_lstat(path, _exception_for_missing_path) File "ftp_stat.py", line 460, in _real_lstat lines = self._host_dir(dirname) File "ftp_stat.py", line 390, in _host_dir return self._host._dir(path) File "ftputil.py", line 781, in _dir descend_deeply=True) File "ftputil.py", line 564, in _robust_ftp_command self.chdir(path) File "ftputil.py", line 587, in chdir ftp_error._try_with_oserror(self._session.cwd, path) File "ftp_error.py", line 152, in _try_with_oserror raise PermanentError(*exc.args) ftp_error.PermanentError: 550 /1: No such file or directory Debugging info: ftputil 2.4.2b, Python 2.6.2 (linux2) }}} One might think that FTPHost.path.exists is broken, but Nautilus 2.26.2 (Gnone file manager) also denotes the link as "(broken)". -- Ticket URL: ftputil Python FTP client library From trac at ftputil.sschwarzer.net Wed Jul 22 08:42:32 2009 From: trac at ftputil.sschwarzer.net (ftputil) Date: Wed, 22 Jul 2009 06:42:32 -0000 Subject: [ftputil] #39: isdir and isfile fail if they are applied to a link without existing target In-Reply-To: <046.151cda9261bb255dbb89643da68a69de@ftputil.sschwarzer.net> References: <046.151cda9261bb255dbb89643da68a69de@ftputil.sschwarzer.net> Message-ID: <055.5ed62ceb4fbdb9fa4f219f6484b93f06@ftputil.sschwarzer.net> #39: isdir and isfile fail if they are applied to a link without existing target ----------------------+----------------------------------------------------- Reporter: schwa | Owner: schwa Type: defect | Status: assigned Priority: minor | Milestone: Component: Library | Version: 2.4.2b Resolution: | Keywords: islink, isdir, isfile, link, broken link ----------------------+----------------------------------------------------- Changes (by schwa): * status: new => assigned -- Ticket URL: ftputil Python FTP client library From trac at ftputil.sschwarzer.net Wed Jul 22 08:46:49 2009 From: trac at ftputil.sschwarzer.net (ftputil) Date: Wed, 22 Jul 2009 06:46:49 -0000 Subject: [ftputil] #35: Ftputil broken with some links In-Reply-To: <052.62b04054176d28acac22a3af65d17632@ftputil.sschwarzer.net> References: <052.62b04054176d28acac22a3af65d17632@ftputil.sschwarzer.net> Message-ID: <061.25119598932a9a51ef4ec57554abc17f@ftputil.sschwarzer.net> #35: Ftputil broken with some links --------------------------+------------------------------------------------- Reporter: ftputiluser | Owner: schwa Type: defect | Status: closed Priority: major | Milestone: 2.4.2 Component: Library | Version: 2.4 Resolution: fixed | Keywords: listdir, link, ./ --------------------------+------------------------------------------------- Changes (by schwa): * status: reopened => closed * resolution: => fixed Comment: Hi Nicola, I can reproduce the traceback. However, its background is different from the original description. The target of the link /mirrors/zebra doesn't exist at all, so isdir should return False instead of causing a traceback. The behavior of FTPHost.listdir to cause a !PermanentError on the other hand would be correct. In contrast, the example in the original description shows a traceback even upon a listdir call on an existing target. I've added another ticket, #39, which is more specific and "reclose" ''this'' bug for now. :-) Stefan -- Ticket URL: ftputil Python FTP client library From trac at ftputil.sschwarzer.net Wed Jul 22 08:57:41 2009 From: trac at ftputil.sschwarzer.net (ftputil) Date: Wed, 22 Jul 2009 06:57:41 -0000 Subject: [ftputil] #39: isdir and isfile on a broken link cause a PermanentError In-Reply-To: <046.151cda9261bb255dbb89643da68a69de@ftputil.sschwarzer.net> References: <046.151cda9261bb255dbb89643da68a69de@ftputil.sschwarzer.net> Message-ID: <055.8584a530e7389a0885420d2490b7d168@ftputil.sschwarzer.net> #39: isdir and isfile on a broken link cause a PermanentError ----------------------+----------------------------------------------------- Reporter: schwa | Owner: schwa Type: defect | Status: assigned Priority: minor | Milestone: Component: Library | Version: 2.4.2b Resolution: | Keywords: islink, isdir, isfile, link, broken link ----------------------+----------------------------------------------------- Changes (by schwa): * summary: isdir and isfile fail if they are applied to a link without existing target => isdir and isfile on a broken link cause a PermanentError -- Ticket URL: ftputil Python FTP client library From trac at ftputil.sschwarzer.net Wed Jul 22 08:58:16 2009 From: trac at ftputil.sschwarzer.net (ftputil) Date: Wed, 22 Jul 2009 06:58:16 -0000 Subject: [ftputil] #39: isdir and isfile on a broken link cause a PermanentError In-Reply-To: <046.151cda9261bb255dbb89643da68a69de@ftputil.sschwarzer.net> References: <046.151cda9261bb255dbb89643da68a69de@ftputil.sschwarzer.net> Message-ID: <055.b961135991df26a7a000e0365d3e6a4d@ftputil.sschwarzer.net> #39: isdir and isfile on a broken link cause a PermanentError ----------------------+----------------------------------------------------- Reporter: schwa | Owner: schwa Type: defect | Status: assigned Priority: minor | Milestone: Component: Library | Version: 2.4.2b Resolution: | Keywords: islink, isdir, isfile, link, broken link, exception, PermanentError ----------------------+----------------------------------------------------- Changes (by schwa): * keywords: islink, isdir, isfile, link, broken link => islink, isdir, isfile, link, broken link, exception, PermanentError -- Ticket URL: ftputil Python FTP client library From trac at ftputil.sschwarzer.net Wed Jul 22 10:04:20 2009 From: trac at ftputil.sschwarzer.net (ftputil) Date: Wed, 22 Jul 2009 08:04:20 -0000 Subject: [ftputil] #39: isdir and isfile on broken links with special targets cause a PermanentError In-Reply-To: <046.151cda9261bb255dbb89643da68a69de@ftputil.sschwarzer.net> References: <046.151cda9261bb255dbb89643da68a69de@ftputil.sschwarzer.net> Message-ID: <055.68a74fa1666339130793ed412cbe9b60@ftputil.sschwarzer.net> #39: isdir and isfile on broken links with special targets cause a PermanentError ----------------------+----------------------------------------------------- Reporter: schwa | Owner: schwa Type: defect | Status: assigned Priority: minor | Milestone: Component: Library | Version: 2.4.2b Resolution: | Keywords: islink, isdir, isfile, link, broken link, exception, PermanentError ----------------------+----------------------------------------------------- Changes (by schwa): * summary: isdir and isfile on a broken link cause a PermanentError => isdir and isfile on broken links with special targets cause a PermanentError Comment: I've just checked in a test case, changeset [changeset:884]. This tests the path "dir_with_broken_link/nonexistent" (without a directory change beforehand). Seemingly the whole thing is even a bit more involved. The bug isn't triggered by a mere broken link but only by special ones. For example, these link targets cause tracebacks: * nonexistent/nonexistent * ../nonexistent/nonexistent * /nonexistent/nonexistent * ./nonexistent But these don't: * nonexistent * ../nonexistent * /nonexistent -- Ticket URL: ftputil Python FTP client library From trac at ftputil.sschwarzer.net Tue Aug 25 07:11:49 2009 From: trac at ftputil.sschwarzer.net (ftputil) Date: Tue, 25 Aug 2009 05:11:49 -0000 Subject: [ftputil] #40: ftp_sync directory Message-ID: <052.dc42011419624f4e3fe45d974d1bd111@ftputil.sschwarzer.net> #40: ftp_sync directory -------------------------+-------------------------------------------------- Reporter: ftputiluser | Owner: schwa Type: defect | Status: new Priority: minor | Milestone: Component: Library | Version: Keywords: | -------------------------+-------------------------------------------------- {{{ target_directory = "/home/user/new" target = ftp_sync.LocalHost() source = ftputil.FTPHost(hostname, username, password) syncer = ftp_sync.Syncer(source, target) syncer.sync(source_directory, target_directory) # this should have created /home/user/new/files # instead it created /home/user/newfiles }}} Solution:[[BR]] {{{ #change line 168 in ftp_sync.py self._sync_tree(source_path, target_path + "/") }}} thanks,[[BR]] jeram -- Ticket URL: ftputil Python FTP client library From trac at ftputil.sschwarzer.net Tue Sep 1 22:17:31 2009 From: trac at ftputil.sschwarzer.net (ftputil) Date: Tue, 01 Sep 2009 20:17:31 -0000 Subject: [ftputil] #40: ftp_sync misses path separator from target directory (was: ftp_sync directory) In-Reply-To: <052.dc42011419624f4e3fe45d974d1bd111@ftputil.sschwarzer.net> References: <052.dc42011419624f4e3fe45d974d1bd111@ftputil.sschwarzer.net> Message-ID: <061.8a5dd073195d88709d962c432c702d36@ftputil.sschwarzer.net> #40: ftp_sync misses path separator from target directory --------------------------+------------------------------------------------- Reporter: ftputiluser | Owner: schwa Type: defect | Status: assigned Priority: minor | Milestone: Component: Library | Version: Resolution: | Keywords: sync, target directory, path separator --------------------------+------------------------------------------------- Changes (by schwa): * keywords: => sync, target directory, path separator * status: new => assigned -- Ticket URL: ftputil Python FTP client library From trac at ftputil.sschwarzer.net Tue Sep 1 22:48:39 2009 From: trac at ftputil.sschwarzer.net (ftputil) Date: Tue, 01 Sep 2009 20:48:39 -0000 Subject: [ftputil] #40: ftp_sync misses path separator from target directory In-Reply-To: <052.dc42011419624f4e3fe45d974d1bd111@ftputil.sschwarzer.net> References: <052.dc42011419624f4e3fe45d974d1bd111@ftputil.sschwarzer.net> Message-ID: <061.4324a4238a83e8fa82c1f458d56ccb8e@ftputil.sschwarzer.net> #40: ftp_sync misses path separator from target directory --------------------------+------------------------------------------------- Reporter: ftputiluser | Owner: schwa Type: defect | Status: assigned Priority: minor | Milestone: Component: Library | Version: Resolution: | Keywords: sync, target directory, path separator --------------------------+------------------------------------------------- Comment(by schwa): Jeram, thanks a lot for your report and the suggested fix. I was very busy with another project and so hadn't found the time to deal with your report. Sorry. I'm looking into the sync code right now and wonder if applying your suggested fix might make the code break in other situations. Looking at the code I guess the problem you describe will occur if the given source directory has a slash appended but the target directory (as in your case) not. I tried to reproduce the problem but was unable to do so. Thus, it would be very helpful if you could supply a small self-contained working example I could run to reproduce the error. Please attach it to the ticket. Thanks in advance. (I hope you're still "listening".) -- Ticket URL: ftputil Python FTP client library From trac at ftputil.sschwarzer.net Sat Sep 12 22:24:27 2009 From: trac at ftputil.sschwarzer.net (ftputil) Date: Sat, 12 Sep 2009 20:24:27 -0000 Subject: [ftputil] #41: setup.py's --user option does not get evaluated Message-ID: <052.d1e36a7e9045bbe08a2bdcee32b88dad@ftputil.sschwarzer.net> #41: setup.py's --user option does not get evaluated ---------------------------+------------------------------------------------ Reporter: ftputiluser | Owner: schwa Type: defect | Status: new Priority: minor | Milestone: Component: Library | Version: 2.4.2 Keywords: installscript | ---------------------------+------------------------------------------------ Installing with the option --user (which should put the library into the local users home) get's ignored. There's something wrong with the distutil-usage, sorry I can't provide a patch at the moment. -- Ticket URL: ftputil Python FTP client library From trac at ftputil.sschwarzer.net Sun Sep 13 20:43:57 2009 From: trac at ftputil.sschwarzer.net (ftputil) Date: Sun, 13 Sep 2009 18:43:57 -0000 Subject: [ftputil] #41: setup.py's --user option does not get evaluated In-Reply-To: <052.d1e36a7e9045bbe08a2bdcee32b88dad@ftputil.sschwarzer.net> References: <052.d1e36a7e9045bbe08a2bdcee32b88dad@ftputil.sschwarzer.net> Message-ID: <061.cd041bb9a75b0dd2f49ee0d3be62d1b4@ftputil.sschwarzer.net> #41: setup.py's --user option does not get evaluated --------------------------+------------------------------------------------- Reporter: ftputiluser | Owner: schwa Type: defect | Status: assigned Priority: minor | Milestone: Component: Library | Version: 2.4.2 Resolution: | Keywords: installation script, setup.py, --user --------------------------+------------------------------------------------- Changes (by schwa): * keywords: installscript => installation script, setup.py, --user * status: new => assigned Comment: Thanks for the report! I ''try'' to look into that during the next week. By the way: a report without a patch is usually better than no report at all. :-) Stefan -- Ticket URL: ftputil Python FTP client library