From bogus@does.not.exist.com Mon Oct 13 17:00:32 2008 From: bogus@does.not.exist.com (Walter) Date: Mon, 13 Oct 2008 17:00:32 --300 Subject: [ftputil] start play Message-ID: <48F39AD0.9010807@codespeak.net> 250pct Willkommen bonus http://www.gigplaysnow.biz From =?koi8-r?B?7sHUwczJ0SA8dG9uaWFAdGV4dGlsZS5ydT4=?= Tue Dec 2 18:24:07 2008 From: =?koi8-r?B?7sHUwczJ0SA8dG9uaWFAdGV4dGlsZS5ydT4=?= (=?koi8-r?B?7sHUwczJ0SA8dG9uaWFAdGV4dGlsZS5ydT4=?=) Date: Tue, 2 Dec 2008 14:24:07 -0300 Subject: [ftputil] =?koi8-r?b?98HbwSDawdHXy8Eg0NLJztHUwS4=?= Message-ID: <01c95489$a59047de$6c822ecf@tonia> ?????? ???????? ?????????? ??????? ??????????????? ? ?????? ?????????, ?????????? ? ???? ? 1 ?????? 2008 ????. ???? ?????????? ???????: P???? d?????? ?????????????????: 1 ???? ?. ?????? ??????? ???????????? ??: ??????????? ?????????? ? ??????????????????????? ????????????????? ??????????? ????????????? ? ??????????? ?????????-????????????? ????? ??????? ?????????? ? ????????: ????????? - ??????????? ????? ???????????????. ????? ?? ????? ????????????? ???? ??? ????????????? ???. ??????? ??????? ???????? ????????. ?????????????? ??????????. ?????????? ?????????? ???.??????????? ?? ?????????? ???: ?? ???? ????????????, ????????? ??????????? ? ????????? ????????, ?? ???????, ?? ????????? ?????????, ?? ??????????? ???????????. ??? ??????? ?????? ???????????????. ??????? ????????? ??????? ?? ?????????? ????????? (???????, ?????, ?????). ?????? ?????????? ?? ???????? ????, ????????, ???????, ?? ????????? ????????? ? ??. ???? ????????????????? ???????: ?????? ?? ????????? ????????????? ?????????;????????? ?????????? ?? ????????? ????????????? ? ????????????? ???????????;?????? ?? ???????? ??????? ? ???????????? ?????? ???????????;?????? ?? ????? ????????? ? ??????; ?????? ?? ??????? ???? ? ???????? ????????;?????? ?? ???????? ?????????????? ???????????;?????? ?? ?????????? ???????; ????????????? ???????? ???????;?????? ??? ??????? ???????;?????? ? ???? ????????? ?? ??????????????? ??????;???????????? ?????? ?? ?????????????? ???????? ?????; ??????, ??????? ?? ??????????? ??? ??????? ??????? ??????. ??????? ????????? ????????. ??????? ?? ???????????? ???????? ??????? ? ?????????????? ???????, ????? ? ??????????, ???????, ?????? ????????? ???????????. ??????? ?? ?????? ?????. ??????? ??????? ?? ????????? ??????????????????, ?? ???????????? ? ?????, ?? ????? ?? ???????? ?? 1,5 ???. ??????? ? ???? ???.??????? ?? ???????????: ?????, ?????? ?? ???????????? ?????????? ???????????, ?????? ?? ?????????? ??????? ?? ???????????? ? ???????????????.???????, ??????? ?? ??????????? ??? ??????? ??????? ??????.?????? ???????: (?? ?????? ????? ?????; ?? ??????; ?? ?????? ?????????? ????????; ?? ?????????? ??????????????; ??????????????? ???????; ?? ??????????? ? ????????????? ??????; ?? ?????????? ?????; ?? ????????? ??? ??? ? ??? ??????; ????????? ???????; ?????? ? ?????; ?? ??????????? ?????? ? ??????????? ????????????; ?? ????????????; ?? ???????? ???????????; ? ??.) ??????? ?? ??? ? ?????? ?????? ???????????????, ? ??????? ??????????????? ???????????, ? ????. ??????? ????????? ??????? ? ???????????? ??? ?????????? ??????? ???????????????.???????????? ? ?????????????? ??????? ? ???. ??????? ????????? ??????? ? ????????.????? ????? ??????? ? ????????. ??????????? ?????????? ? ??????????? ??????. ??????? ???????? ?????????? ? ????? ?????????????? ????? ? ???????????????.??????????? ?????????? ??? ? ????.???????? ?????? ? ??????????? ????????? ???????????.?????? ? ?????? ??????? ?????? ??? ?????? ???????? ???????????????. ??????????? ?????. ??????????? ????????? ??????????. ?????????? ????? ???????? ?? ?????????: (cod ??????) 7/9/2-21 22; ?45-?9 68 2VHMO -------------- next part -------------- An HTML attachment was scrubbed... URL: http://codespeak.net/pipermail/ftputil/attachments/20081202/76bc2ab4/attachment.htm From =?koi8-r?B?5M/Hz9fP0s7PxSDPxs/SzczFzsnFINfOxdvOxdzLz87PzcnexdPLz8og?= Thu Dec 4 16:07:21 2008 From: =?koi8-r?B?5M/Hz9fP0s7PxSDPxs/SzczFzsnFINfOxdvOxdzLz87PzcnexdPLz8og?= (=?koi8-r?B?5M/Hz9fP0s7PxSDPxs/SzczFzsnFINfOxdvOxdzLz87PzcnexdPLz8og?=) Date: Thu, 4 Dec 2008 16:07:21 +0100 Subject: [ftputil] =?koi8-r?b?xMXLzMHSydLP18HOycUgx9LV2s/X?= Message-ID: <01c9562a$6490d1b8$6c822ecf@dzak_market> ?????????? ?????????? ?????????????? ???????????? ???????? ??????????????????? ????? ? ?????? 15-17 ??????? ??? ? ??? ??????????? ? ??????????. ? ???????? ????????? ??????? ??????????? ?? ?????????? ?????????? ????????, ??? ??????, ?????? ?????????? ??????? ???. 1 ????. ?????????? ?????????? ??????????????????? ?????? ?????????????? ????????: ????, ??????????? ? ???????? ?????. ??????????-???????? ????????????? ?????????????? ?????? ???????? ? ??????????? ??????????? ??????????????? ????????? ? ???????????? ? ?? ?? ? ?????????????? ???????. ???????? ??????? ????????. ????????????? ?????????. ?????? ???????? ??????, ??????????? ??????????? ??? ??? ?????????? ? ?????????? ?????????. ???????? ??????? ? ??????????? ??????????? ????????? ?????????. 2 ????. ????????? ? ?????????? ????????? ???????, ???????????? ????? ?????????? ??????? ??????. ??????????? ?????????? ????????? ???????. ????????? ?????????? ????????? ???????. ?????????? ? ????????????? ? ?????????? ???. ????? ?????? ??? ?????? . ???????????? ??????? ?????????? ?????????? ?????????? ?????????. ???????? ?????????? ?????????. ???????? ?????????? ? ?????? ?? ???????? ?????????? ??????? ?????????? ??????????? ?????????? ?????????. ??????? ?????????? ???? ????????????? ?????????? ????????? ? ????????? ??????? ???????????? ??????? . 3 ????. ?????????? ???????? ??????????? ?????????? ????????? ? ?????????? ???????????????? ???????????????? ???? ???????????? ? ??????? ??????????? ???? : ?????????? ??????? ?????????? ???????? ? ?????????? ?????????? ???????; ?????????? ????????; ?????????? ???????????? ?????????? ????????? ??????????? ?????????? ??? ????????? ???. ????? ? ????????? ?????????? ???????. ??????????? ?????????? ?????????? ???????? ? ????????? ?????????? ???????. ????????? ??????? ? ???????? 15 200(? ??? ????? ???) . ?? ????????? ???????? ???????? ??????????. ?????????? ????????: (495) 506-30-78,741-87-05 ??????????? ???????????? ?????????. ?????? ?. ?????? ?. ???????, ???? 4R08CKVXFQAKDP -------------- next part -------------- An HTML attachment was scrubbed... URL: http://codespeak.net/pipermail/ftputil/attachments/20081204/95e87916/attachment-0001.htm From =?koi8-r?B?88zP1s7ZxSDNz83FztTZIMvP0tLFy9TJ0s/Xy8kg1MHNz9bFzs7PyiDT?= Mon Dec 8 09:41:45 2008 From: =?koi8-r?B?88zP1s7ZxSDNz83FztTZIMvP0tLFy9TJ0s/Xy8kg1MHNz9bFzs7PyiDT?= (=?koi8-r?B?88zP1s7ZxSDNz83FztTZIMvP0tLFy9TJ0s/Xy8kg1MHNz9bFzs7PyiDT?=) Date: Mon, 8 Dec 2008 10:41:45 +0200 Subject: [ftputil] =?koi8-r?b?5MzRINXewdPUzsnLz9cg9/zk?= Message-ID: <01c95921$92f9c9aa$6c822ecf@amjak10> ?????????? ?????????? ?????????????? ???????????? ???????? ??????????????????? ????? ? ?????? 15-17 ??????? ??? ? ??? ??????????? ? ??????????. ? ???????? ????????? ??????? ??????????? ?? ?????????? ?????????? ????????, ??? ??????, ?????? ?????????? ??????? ???. 1 ????. ?????????? ?????????? ??????????????????? ?????? ?????????????? ????????: ????, ??????????? ? ???????? ?????. ??????????-???????? ????????????? ?????????????? ?????? ???????? ? ??????????? ??????????? ??????????????? ????????? ? ???????????? ? ?? ?? ? ?????????????? ???????. ???????? ??????? ????????. ????????????? ?????????. ?????? ???????? ??????, ??????????? ??????????? ??? ??? ?????????? ? ?????????? ?????????. ???????? ??????? ? ??????????? ??????????? ????????? ?????????. 2 ????. ????????? ? ?????????? ????????? ???????, ???????????? ????? ?????????? ??????? ??????. ??????????? ?????????? ????????? ???????. ????????? ?????????? ????????? ???????. ?????????? ? ????????????? ? ?????????? ???. ????? ?????? ??? ?????? . ???????????? ??????? ?????????? ?????????? ?????????? ?????????. ???????? ?????????? ?????????. ???????? ?????????? ? ?????? ?? ???????? ?????????? ??????? ?????????? ??????????? ?????????? ?????????. ??????? ?????????? ???? ????????????? ?????????? ????????? ? ????????? ??????? ???????????? ??????? . 3 ????. ?????????? ???????? ??????????? ?????????? ????????? ? ?????????? ???????????????? ???????????????? ???? ???????????? ? ??????? ??????????? ???? : ?????????? ??????? ?????????? ???????? ? ?????????? ?????????? ???????; ?????????? ????????; ?????????? ???????????? ?????????? ????????? ??????????? ?????????? ??? ????????? ???. ????? ? ????????? ?????????? ???????. ??????????? ?????????? ?????????? ???????? ? ????????? ?????????? ???????. ????????? ??????? ? ???????? 15 200(? ??? ????? ???) . ?? ????????? ???????? ???????? ??????????. ?????????? ????????: (495) 506-30-78,741-87-05 ??????????? ???????????? ?????????. ?????? ?. ?????? ?. ???????, ???? 8YZV4121V2F -------------- next part -------------- An HTML attachment was scrubbed... URL: http://codespeak.net/pipermail/ftputil/attachments/20081208/a7c992b8/attachment.htm From =?koi8-r?B?4c7BzMnaINTJ0MneztnIIM/bycLPyyDEz9DV08vBxc3ZyCDV3sHT1M7J?= Fri Dec 12 06:49:12 2008 From: =?koi8-r?B?4c7BzMnaINTJ0MneztnIIM/bycLPyyDEz9DV08vBxc3ZyCDV3sHT1M7J?= (=?koi8-r?B?4c7BzMnaINTJ0MneztnIIM/bycLPyyDEz9DV08vBxc3ZyCDV3sHT1M7J?=) Date: Fri, 12 Dec 2008 02:49:12 -0300 Subject: [ftputil] =?koi8-r?b?8NLB18nMwSDPxs/SzczFzsnRIPf85A==?= Message-ID: <01c95c04$37d8d8b4$6c822ecf@aanpmxoct6> ?????????? ?????????? ?????????????? ???????????? ???????? ??????????????????? ????? ? ?????? 15-17 ??????? ??? ? ??? ??????????? ? ??????????. ? ???????? ????????? ??????? ??????????? ?? ?????????? ?????????? ????????, ??? ??????, ?????? ?????????? ??????? ???. 1 ????. ?????????? ?????????? ??????????????????? ?????? ?????????????? ????????: ????, ??????????? ? ???????? ?????. ??????????-???????? ????????????? ?????????????? ?????? ???????? ? ??????????? ??????????? ??????????????? ????????? ? ???????????? ? ?? ?? ? ?????????????? ???????. ???????? ??????? ????????. ????????????? ?????????. ?????? ???????? ??????, ??????????? ??????????? ??? ??? ?????????? ? ?????????? ?????????. ???????? ??????? ? ??????????? ??????????? ????????? ?????????. 2 ????. ????????? ? ?????????? ????????? ???????, ???????????? ????? ?????????? ??????? ??????. ??????????? ?????????? ????????? ???????. ????????? ?????????? ????????? ???????. ?????????? ? ????????????? ? ?????????? ???. ????? ?????? ??? ?????? . ???????????? ??????? ?????????? ?????????? ?????????? ?????????. ???????? ?????????? ?????????. ???????? ?????????? ? ?????? ?? ???????? ?????????? ??????? ?????????? ??????????? ?????????? ?????????. ??????? ?????????? ???? ????????????? ?????????? ????????? ? ????????? ??????? ???????????? ??????? . 3 ????. ?????????? ???????? ??????????? ?????????? ????????? ? ?????????? ???????????????? ???????????????? ???? ???????????? ? ??????? ??????????? ???? : ?????????? ??????? ?????????? ???????? ? ?????????? ?????????? ???????; ?????????? ????????; ?????????? ???????????? ?????????? ????????? ??????????? ?????????? ??? ????????? ???. ????? ? ????????? ?????????? ???????. ??????????? ?????????? ?????????? ???????? ? ????????? ?????????? ???????. ????????? ??????? ? ???????? 15 200(? ??? ????? ???) . ?? ????????? ???????? ???????? ??????????. ?????????? ????????: (495) 506-30-78,741-87-05 ??????????? ???????????? ?????????. ?????? ?. ?????? ?. ???????, ???? HWY6R9PO5KQ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://codespeak.net/pipermail/ftputil/attachments/20081212/b2e7a38b/attachment.htm From yvan.strahm at gmail.com Fri Dec 12 13:40:02 2008 From: yvan.strahm at gmail.com (Yvan Strahm) Date: Fri, 12 Dec 2008 13:40:02 +0100 Subject: [ftputil] How to correctlry close a ftp connection Message-ID: Hello, I get this error: Traceback (most recent call last): File "./map_taxo.py", line 186, in ? Download_me(ftp,ftp_dir,file,target) File "./map_taxo.py", line 95, in Download_me host=ftputil.FTPHost(ftp,user,password) File "/usr/lib/python2.4/site-packages/ftputil/ftputil.py", line 136, in __init__ self._session = self._make_session() File "/usr/lib/python2.4/site-packages/ftputil/ftputil.py", line 174, in _make_session return ftp_error._try_with_oserror(factory, *args, **kwargs) File "/usr/lib/python2.4/site-packages/ftputil/ftp_error.py", line 86, in _try_with_oserror raise PermanentError(obj) ftputil.ftp_error.PermanentError: 530 Sorry, the maximum number clients (32) from your host are already connected. Debugging info: ftputil 2.2.3, Python 2.4.3 (linux2) I have a list of file s to be downloaded and open/close for every items. Is it the correct way of doing it? def Download_me(ftp,ftp_dir,file,target): user = 'anonymous' password = 'anonymous' try: print "CONNECTING TO "+ ftp + ftp_dir+file+"\n" host=ftputil.FTPHost(ftp,user,password) host.chdir(ftp_dir+file) names=host.listdir(host.curdir) for name in names: if host.path.isfile(name): p="pep" m_pep=re.search(p,name) if m_pep: returned=name host.download_if_newer(name,target,'b') host.close() except: print "could not be dowloaded try KAAS" ftp='ftp.genome.jp' ftp_dir='/pub/kegg/genes/organisms_kaas/' print "CONNECTING TO "+ ftp + ftp_dir+file+"\n" host=ftputil.FTPHost(ftp,user,password) host.chdir(ftp_dir+file) names=host.listdir(host.curdir) for name in names: if host.path.isfile(name): p="pep" m_pep=re.search(p,name) if m_pep: returned=name host.download_if_newer(name,target,'b') host.close() Thanks for your help. yvan -------------- next part -------------- An HTML attachment was scrubbed... URL: http://codespeak.net/pipermail/ftputil/attachments/20081212/f9a432df/attachment-0001.htm From sschwarzer at sschwarzer.net Fri Dec 12 14:47:11 2008 From: sschwarzer at sschwarzer.net (Stefan Schwarzer) Date: Fri, 12 Dec 2008 14:47:11 +0100 Subject: [ftputil] How to correctlry close a ftp connection In-Reply-To: References: Message-ID: <49426B5F.2060307@sschwarzer.net> Hi Yvan, On 2008-12-12 13:40, Yvan Strahm wrote: > I get this error: > > Traceback (most recent call last): > File "./map_taxo.py", line 186, in ? > Download_me(ftp,ftp_dir,file,target) > File "./map_taxo.py", line 95, in Download_me > host=ftputil.FTPHost(ftp,user,password) > File "/usr/lib/python2.4/site-packages/ftputil/ftputil.py", line 136, > in __init__ > self._session = self._make_session() > File "/usr/lib/python2.4/site-packages/ftputil/ftputil.py", line 174, > in _make_session > return ftp_error._try_with_oserror(factory, *args, **kwargs) > File "/usr/lib/python2.4/site-packages/ftputil/ftp_error.py", line 86, > in _try_with_oserror > raise PermanentError(obj) > ftputil.ftp_error.PermanentError: 530 Sorry, the maximum number clients > (32) from your host are already connected. > Debugging info: ftputil 2.2.3, Python 2.4.3 (linux2) Does the FTPHost construction here refer to the first in the try clause or the second in the except clause? > I have a list of file s to be downloaded and open/close for every items. > Is it the correct way of doing it? > > def Download_me(ftp,ftp_dir,file,target): > user = 'anonymous' > password = 'anonymous' > try: > print "CONNECTING TO "+ ftp + ftp_dir+file+"\n" Which actual values did you use for ftp, ftp_dir, file and target which caused the exception, if I may ask? > host=ftputil.FTPHost(ftp,user,password) > host.chdir(ftp_dir+file) Does ftp_dir contain a trailing slash here? I'd recommend to use FTPHost.path.join(ftp_dir, file) and ftp_dir without a trailing slash. > names=host.listdir(host.curdir) > for name in names: > if host.path.isfile(name): > p="pep" > m_pep=re.search(p,name) > if m_pep: > returned=name > host.download_if_newer(name,target,'b') > host.close() > except: I suggest you avoid a bare "except"; use "except ftp_error.PermanentError" (or rather the exceptions you actually expect). In your current code, _any_ exception would trigger the except clause, thus catching exceptions you perhaps don't want to be caught. > print "could not be dowloaded try KAAS" > ftp='ftp.genome.jp ' If you use this for the host argument of the FTPHost constructor, it will probably fail. Use just the full name of the FTP server (ftp.genome.jp), without the part in angle brackets. > ftp_dir='/pub/kegg/genes/organisms_kaas/' > print "CONNECTING TO "+ ftp + ftp_dir+file+"\n" > host=ftputil.FTPHost(ftp,user,password) > host.chdir(ftp_dir+file) > names=host.listdir(host.curdir) > for name in names: > if host.path.isfile(name): > p="pep" > m_pep=re.search(p,name) > if m_pep: > returned=name > host.download_if_newer(name,target,'b') > host.close() Possibly you should put the common parts of the try and except clauses into a function. Regarding the symmetry of the FTPHost construction and calling the close method, at first sight this looks well. However, if the constructor fails, the close method won't be called, so that may be the reason why you exhaust the possible number of connections. (On the other hand, this could be a genuine error message if enough people are logged into the FTP server at the same time.) I think you should use a try ... finally construct: try: print "CONNECTING TO "+ ftp + ftp_dir+file+"\n" host=ftputil.FTPHost(ftp,user,password) try: host.chdir(ftp_dir+file) names=host.listdir(host.curdir) for name in names: if host.path.isfile(name): p="pep" m_pep=re.search(p,name) if m_pep: returned=name host.download_if_newer(name,target,'b') finally: host.close() except: ... In this way, the connection will be closed, whether there's an exception or not. Does that help? Best regards, Stefan From yvan.strahm at gmail.com Fri Dec 12 15:24:11 2008 From: yvan.strahm at gmail.com (Yvan Strahm) Date: Fri, 12 Dec 2008 15:24:11 +0100 Subject: [ftputil] How to correctlry close a ftp connection In-Reply-To: <49426B5F.2060307@sschwarzer.net> References: <49426B5F.2060307@sschwarzer.net> Message-ID: On Fri, Dec 12, 2008 at 2:47 PM, Stefan Schwarzer wrote: > Hi Yvan, > > On 2008-12-12 13:40, Yvan Strahm wrote: > > I get this error: > > > > Traceback (most recent call last): > > File "./map_taxo.py", line 186, in ? > > Download_me(ftp,ftp_dir,file,target) > > File "./map_taxo.py", line 95, in Download_me > > host=ftputil.FTPHost(ftp,user,password) > > File "/usr/lib/python2.4/site-packages/ftputil/ftputil.py", line 136, > > in __init__ > > self._session = self._make_session() > > File "/usr/lib/python2.4/site-packages/ftputil/ftputil.py", line 174, > > in _make_session > > return ftp_error._try_with_oserror(factory, *args, **kwargs) > > File "/usr/lib/python2.4/site-packages/ftputil/ftp_error.py", line 86, > > in _try_with_oserror > > raise PermanentError(obj) > > ftputil.ftp_error.PermanentError: 530 Sorry, the maximum number clients > > (32) from your host are already connected. > > Debugging info: ftputil 2.2.3, Python 2.4.3 (linux2) > > Does the FTPHost construction here refer to the first in the try > clause or the second in the except clause? the second one in the except > > > > I have a list of file s to be downloaded and open/close for every items. > > Is it the correct way of doing it? > > > > def Download_me(ftp,ftp_dir,file,target): > > user = 'anonymous' > > password = 'anonymous' > > try: > > print "CONNECTING TO "+ ftp + ftp_dir+file+"\n" > > Which actual values did you use for ftp, ftp_dir, file and > target which caused the exception, if I may ask? > ftp='ftp.genome.jp' ftp_dir='/pub/kegg/genes/organisms_kaas/' file='dola/' tartget=./eukaryotes/vertebrates/fishes/oryzias_latipes_japanese_medaka_/o.latipes.pep > > > host=ftputil.FTPHost(ftp,user,password) > > host.chdir(ftp_dir+file) > > Does ftp_dir contain a trailing slash here? I'd recommend to use > FTPHost.path.join(ftp_dir, file) and ftp_dir without a trailing > slash. > sorry I don't use the path.join.function, I should have read the documentation more seriously ... > > names=host.listdir(host.curdir) > > for name in names: > > if host.path.isfile(name): > > p="pep" > > m_pep=re.search(p,name) > > if m_pep: > > returned=name > > host.download_if_newer(name,target,'b') > > host.close() > > except: > > I suggest you avoid a bare "except"; use "except > ftp_error.PermanentError" (or rather the exceptions you actually > expect). In your current code, _any_ exception would trigger the > except clause, thus catching exceptions you perhaps don't want to > be caught. > > > print "could not be dowloaded try KAAS" > > ftp='ftp.genome.jp ' > > If you use this for the host argument of the FTPHost constructor, > it will probably fail. Use just the full name of the FTP server > (ftp.genome.jp), without the part in angle brackets. > > > ftp_dir='/pub/kegg/genes/organisms_kaas/' > > print "CONNECTING TO "+ ftp + ftp_dir+file+"\n" > > host=ftputil.FTPHost(ftp,user,password) > > host.chdir(ftp_dir+file) > > names=host.listdir(host.curdir) > > for name in names: > > if host.path.isfile(name): > > p="pep" > > m_pep=re.search(p,name) > > if m_pep: > > returned=name > > host.download_if_newer(name,target,'b') > > host.close() > > Possibly you should put the common parts of the try and except > clauses into a function. > > Regarding the symmetry of the FTPHost construction and calling > the close method, at first sight this looks well. However, if the > constructor fails, the close method won't be called, so that may > be the reason why you exhaust the possible number of connections. > (On the other hand, this could be a genuine error message if > enough people are logged into the FTP server at the same time.) > I think you should use a try ... finally construct: > > try: > print "CONNECTING TO "+ ftp + ftp_dir+file+"\n" > host=ftputil.FTPHost(ftp,user,password) > try: > host.chdir(ftp_dir+file) > names=host.listdir(host.curdir) > for name in names: > if host.path.isfile(name): > p="pep" > m_pep=re.search(p,name) > if m_pep: > returned=name > host.download_if_newer(name,target,'b') > finally: > host.close() > except: > ... > > In this way, the connection will be closed, whether there's an > exception or not. > Thanks I will try to change the code with all your recommendations. Thanks a lot for your help and tips > > Does that help? > yes a lot. > > Best regards, > Stefan > _______________________________________________ > ftputil mailing list > ftputil at codespeak.net > http://codespeak.net/mailman/listinfo/ftputil > Have a nice week end Best Regards, yvan -------------- next part -------------- An HTML attachment was scrubbed... URL: http://codespeak.net/pipermail/ftputil/attachments/20081212/10c04b1d/attachment.htm From sschwarzer at sschwarzer.net Sun Dec 14 10:48:32 2008 From: sschwarzer at sschwarzer.net (Stefan Schwarzer) Date: Sun, 14 Dec 2008 10:48:32 +0100 Subject: [ftputil] How to correctlry close a ftp connection In-Reply-To: <49426B5F.2060307@sschwarzer.net> References: <49426B5F.2060307@sschwarzer.net> Message-ID: <4944D670.6030704@sschwarzer.net> Hello, On 2008-12-12 14:47, Stefan Schwarzer wrote: > Regarding the symmetry of the FTPHost construction and calling > the close method, at first sight this looks well. However, if the > constructor fails, the close method won't be called, so that may > be the reason why you exhaust the possible number of connections. It seems I was a bit hasty here. If the _constructor_ fails, the connection wouldn't have been established in the first place, so it's not necessary to close it. "Closing" a connection which actually isn't there may rather cause an exception _in the "close" call_. More important, thus, usually are exceptions which happen after the construction. > I think you should use a try ... finally construct: > > try: > print "CONNECTING TO "+ ftp + ftp_dir+file+"\n" > host=ftputil.FTPHost(ftp,user,password) > try: That's why the "try" comes _after_ calling the constructor. If the connection wasn't opened, it doesn't need to be closed. It's similar in the Python idiom fobj = open(...) try: ... finally: fobj.close() > host.chdir(ftp_dir+file) > names=host.listdir(host.curdir) > for name in names: > if host.path.isfile(name): > p="pep" > m_pep=re.search(p,name) > if m_pep: > returned=name > host.download_if_newer(name,target,'b') Besides: Behind the scenes download_if_newer opens a new connection to the FTP server in order to make a file object. So not only explicit constructor calls generate connections. (There shouldn't be connection leaks because of that because unused file objects are reused, and they are closed when the FTPHost object is closed.) > finally: > host.close() > except: > ... The curious thing is that your problem comes from the code which is executed _before_ you call the constructor that fails with an exception. :-) Best regards, Stefan From yvan.strahm at gmail.com Mon Dec 15 20:28:24 2008 From: yvan.strahm at gmail.com (Yvan Strahm) Date: Mon, 15 Dec 2008 20:28:24 +0100 Subject: [ftputil] How to correctlry close a ftp connection In-Reply-To: <4944D670.6030704@sschwarzer.net> References: <49426B5F.2060307@sschwarzer.net> <4944D670.6030704@sschwarzer.net> Message-ID: On Sun, Dec 14, 2008 at 10:48 AM, Stefan Schwarzer < sschwarzer at sschwarzer.net> wrote: > Hello, > > On 2008-12-12 14:47, Stefan Schwarzer wrote: > > Regarding the symmetry of the FTPHost construction and calling > > the close method, at first sight this looks well. However, if the > > constructor fails, the close method won't be called, so that may > > be the reason why you exhaust the possible number of connections. > > It seems I was a bit hasty here. If the _constructor_ fails, the > connection wouldn't have been established in the first place, so > it's not necessary to close it. "Closing" a connection which > actually isn't there may rather cause an exception _in the > "close" call_. > > More important, thus, usually are exceptions which happen after > the construction. > > > I think you should use a try ... finally construct: > > > > try: > > print "CONNECTING TO "+ ftp + ftp_dir+file+"\n" > > host=ftputil.FTPHost(ftp,user,password) > > try: > > That's why the "try" comes _after_ calling the constructor. If > the connection wasn't opened, it doesn't need to be closed. > > It's similar in the Python idiom > > fobj = open(...) > try: > ... > finally: > fobj.close() > > > host.chdir(ftp_dir+file) > > names=host.listdir(host.curdir) > > for name in names: > > if host.path.isfile(name): > > p="pep" > > m_pep=re.search(p,name) > > if m_pep: > > returned=name > > host.download_if_newer(name,target,'b') > > Besides: Behind the scenes download_if_newer opens a new > connection to the FTP server in order to make a file object. So > not only explicit constructor calls generate connections. (There > shouldn't be connection leaks because of that because unused file > objects are reused, and they are closed when the FTPHost object > is closed.) > > > finally: > > host.close() > > except: > > ... > > The curious thing is that your problem comes from the code which > is executed _before_ you call the constructor that fails with an > exception. :-) > > Best regards, > Stefan > Hello Stefan, Thanks! the nested try:try:finally:except is doing the trick. I didn't count how many time in my original script the first try was " tried " without success but I suspect that this was the cause of all these not closed connection, as you pointed out in your first reply. Thanks a lot for your help Best regards yvan -------------- next part -------------- An HTML attachment was scrubbed... URL: http://codespeak.net/pipermail/ftputil/attachments/20081215/84a9ef81/attachment-0001.htm From rholden at movenetworks.com Mon Dec 15 22:19:09 2008 From: rholden at movenetworks.com (Richard Holden) Date: Mon, 15 Dec 2008 14:19:09 -0700 Subject: [ftputil] How to correctlry close a ftp connection In-Reply-To: Message-ID: On 12/15/08 12:28 PM, "Yvan Strahm" wrote: On Sun, Dec 14, 2008 at 10:48 AM, Stefan Schwarzer wrote: Hello, On 2008-12-12 14:47, Stefan Schwarzer wrote: > Regarding the symmetry of the FTPHost construction and calling > the close method, at first sight this looks well. However, if the > constructor fails, the close method won't be called, so that may > be the reason why you exhaust the possible number of connections. It seems I was a bit hasty here. If the _constructor_ fails, the connection wouldn't have been established in the first place, so it's not necessary to close it. "Closing" a connection which actually isn't there may rather cause an exception _in the "close" call_. More important, thus, usually are exceptions which happen after the construction. > I think you should use a try ... finally construct: > > try: > print "CONNECTING TO "+ ftp + ftp_dir+file+"\n" > host=ftputil.FTPHost(ftp,user,password) > try: That's why the "try" comes _after_ calling the constructor. If the connection wasn't opened, it doesn't need to be closed. It's similar in the Python idiom fobj = open(...) try: ... finally: fobj.close() > host.chdir(ftp_dir+file) > names=host.listdir(host.curdir) > for name in names: > if host.path.isfile(name): > p="pep" > m_pep=re.search(p,name) > if m_pep: > returned=name > host.download_if_newer(name,target,'b') Besides: Behind the scenes download_if_newer opens a new connection to the FTP server in order to make a file object. So not only explicit constructor calls generate connections. (There shouldn't be connection leaks because of that because unused file objects are reused, and they are closed when the FTPHost object is closed.) > finally: > host.close() > except: > ... The curious thing is that your problem comes from the code which is executed _before_ you call the constructor that fails with an exception. :-) Best regards, Stefan Hello Stefan, Thanks! the nested try:try:finally:except is doing the trick. I didn't count how many time in my original script the first try was " tried " without success but I suspect that this was the cause of all these not closed connection, as you pointed out in your first reply. Thanks a lot for your help Best regards yvan I haven't looked into this yet, but this looks like you could use the with syntax if you've got the right version of python, basically it would do most of the work of the try catch blocks and it looks a little cleaner. -Richard -------------- next part -------------- An HTML attachment was scrubbed... URL: http://codespeak.net/pipermail/ftputil/attachments/20081215/3f956609/attachment.htm From sschwarzer at sschwarzer.net Sun Dec 28 14:58:31 2008 From: sschwarzer at sschwarzer.net (Stefan Schwarzer) Date: Sun, 28 Dec 2008 14:58:31 +0100 Subject: [ftputil] [ANN] ftputil 2.4b released Message-ID: <49578607.8090909@sschwarzer.net> ftputil 2.4b is now available from http://ftputil.sschwarzer.net/download . Changes since version 2.3 ------------------------- The ``FTPHost`` class got a new method ``chmod``, similar to ``os.chmod``, to act on remote files. Thanks go to Tom Parker for the review. A warning is issued through Python's warning framework if the deprecated ``xreadlines`` method of FTP file objects is used. Incompatibility notice ---------------------- The `xreadlines` method will be removed in ftputil *2.5* as well as the direct access of exception classes via the ftputil module (e. g. `ftputil.PermanentError`). However, the deprecated access causes no warning because that seems to be rather difficult to implement. The distribution contains a small tool find_deprecated_code.py to scan a directory tree for the deprecated uses. Invoke the program with the ``--help`` option to see a description. What is ftputil? ---------------- ftputil is a high-level FTP client library for the Python programming language. ftputil implements a virtual file system for accessing FTP servers, that is, it can generate file-like objects for remote files. The library supports many functions similar to those in the os, os.path and shutil modules. ftputil has convenience functions for conditional uploads and downloads, and handles FTP clients and servers in different timezones. Read the documentation at http://ftputil.sschwarzer.net/documentation . License ------- ftputil is Open Source software, released under the revised BSD license (see http://www.opensource.org/licenses/bsd-license.php ). Stefan