From listsin at integrateddevcorp.com Tue Apr 6 01:45:37 2010 From: listsin at integrateddevcorp.com (Steve Steiner (listsin)) Date: Mon, 5 Apr 2010 19:45:37 -0400 Subject: [ftputil] Updating/modernizing ftpsync Message-ID: <300DCC58-A6A7-4088-84C8-BF6895B3C176@integrateddevcorp.com> Hey! I'm updating the ftpsync program, which has been included as "ftpsync0.1" in ftputil. I've added a setup.py with a modern entry point, and am just generally giving it a once-over while I'm getting ready to use it as part of a project. Since this is really a separate project from ftputil, though it's been included as a demo, I've made a new repository on BitBucket: http://bitbucket.org/ssteinerx/ftpsync/ Once checked out, install with: # python setup.py develop Then you can update from the BitBucket repository whenever you want an updated version without reinstalling. You should also be able to run: # ftpsync from the command line and get the same "ftpsync.py" functionality as the original version. It should work exactly same as the original; I haven't done anything to the code other than to move it around and add the setup stuff. I'll be updating the wiki and ticket system with any improvements I plan to make, so feel free to join in. I'd be happy to incorporate any improvements anyone's made through the years for their own use into this "new" project. Hopefully, after a couple of go-rounds, it can either be added back to ftputil, or the old version can be pulled out and this referenced as an external demo. Thanks, S From listsin at integrateddevcorp.com Tue Apr 6 23:15:03 2010 From: listsin at integrateddevcorp.com (Steve Steiner (listsin)) Date: Tue, 6 Apr 2010 17:15:03 -0400 Subject: [ftputil] Updating/modernizing ftpsync Message-ID: Hey! I'm updating the ftpsync, which has been included as "ftpsync0.1" in ftputil. I've added a setup.py with a modern entry point, and am just generally giving it a once-over while I'm getting ready to use it as part of a project. Since this is really a separate project from ftputil, though it's been included as a demo, I've made a new repository on BitBucket: http://bitbucket.org/ssteinerx/ftpsync/ It's not ready for prime-time, but I'd be happy to have any improvements anyone's made through the years for their own use, so I can incorporate them into this "new" project. Thanks, S From sschwarzer at sschwarzer.net Wed Apr 7 00:22:30 2010 From: sschwarzer at sschwarzer.net (Stefan Schwarzer) Date: Wed, 07 Apr 2010 00:22:30 +0200 Subject: [ftputil] Updating/modernizing ftpsync In-Reply-To: <300DCC58-A6A7-4088-84C8-BF6895B3C176@integrateddevcorp.com> References: <300DCC58-A6A7-4088-84C8-BF6895B3C176@integrateddevcorp.com> Message-ID: <4BBBB426.9040900@sschwarzer.net> Hi Steve, Thanks for your work on the sync code! :) (You also implicitly remind me that I should continue to work on ftputil 2.5. ;-) ) On 2010-04-06 01:45, Steve Steiner (listsin) wrote: > I'm updating the ftpsync program, which has been > included as "ftpsync0.1" in ftputil. Just for the record I'd like to mention that the code in the ftpsync-0.1 subdirectory has been contributed by Martin Wilck. > I've added a setup.py with a modern entry point, and am > just generally giving it a once-over while I'm getting > ready to use it as part of a project. > > Since this is really a separate project from ftputil, > though it's been included as a demo, I've made a new > repository on BitBucket: > http://bitbucket.org/ssteinerx/ftpsync/ > [...] By the way, have you had a look at the sync code in the ftputil main directory, ftp_sync.py [1] ? Maybe you can borrow additional ideas from there. I personally like the simple design which allows any combination of local and remote directories for source and target. Do you plan to write automated tests? > Hopefully, after a couple of go-rounds, it can either be > added back to ftputil, or the old version can be pulled > out and this referenced as an external demo. If the syncing was to be made an integral part of ftputil, I'd very much prefer to let the code use ftputil's caching infrastructure instead of its own. The code is from a time when caching in ftputil was still in the works. I think it should be possible to consolidate a few other things as well. [1] http://ftputil.sschwarzer.net/trac/browser/ftp_sync.py Stefan From listsin at integrateddevcorp.com Wed Apr 7 00:45:44 2010 From: listsin at integrateddevcorp.com (Steve Steiner (listsin)) Date: Tue, 6 Apr 2010 18:45:44 -0400 Subject: [ftputil] Updating/modernizing ftpsync In-Reply-To: <4BBBB426.9040900@sschwarzer.net> References: <300DCC58-A6A7-4088-84C8-BF6895B3C176@integrateddevcorp.com> <4BBBB426.9040900@sschwarzer.net> Message-ID: On Apr 6, 2010, at 6:22 PM, Stefan Schwarzer wrote: > Hi Steve, > > Thanks for your work on the sync code! :) > > (You also implicitly remind me that I should continue > to work on ftputil 2.5. ;-) ) No problem -- i needed it for a project anyway, might as well dress it up! > On 2010-04-06 01:45, Steve Steiner (listsin) wrote: >> I'm updating the ftpsync program, which has been >> included as "ftpsync0.1" in ftputil. > > Just for the record I'd like to mention that the code in > the ftpsync-0.1 subdirectory has been contributed by Martin > Wilck. I haven't removed any of his copyright notices or anything and I e-mailed to ask his permission and to ask whether there was any contact info he wanted added. >> I've added a setup.py with a modern entry point, and am >> just generally giving it a once-over while I'm getting >> ready to use it as part of a project. >> >> Since this is really a separate project from ftputil, >> though it's been included as a demo, I've made a new >> repository on BitBucket: >> http://bitbucket.org/ssteinerx/ftpsync/ >> [...] > > By the way, have you had a look at the sync code in the > ftputil main directory, ftp_sync.py [1] ? Maybe you can > borrow additional ideas from there. I personally like the > simple design which allows any combination of local and > remote directories for source and target. I'm looking at it as I get into this project. Frankly, I can't get ftpsync, in its curent form, to do anything, now that I've got it all moved...there doesn't seem to be any argument for adding a password and it doesn't prompt, for example. Maybe I just broke something when I moved it, but I doubt it. > Do you plan to write automated tests? I saw there's some sort of mock class used in the sandbox, but I haven't looked at it. I'd like to get it working at all first; one thing at a time! Right now, it just raises an exception without comment trying to connect... >> Hopefully, after a couple of go-rounds, it can either be >> added back to ftputil, or the old version can be pulled >> out and this referenced as an external demo. > > If the syncing was to be made an integral part of ftputil, > I'd very much prefer to let the code use ftputil's caching > infrastructure instead of its own. The code is from a time > when caching in ftputil was still in the works. I think it > should be possible to consolidate a few other things as > well. Yes, there's no point to add caching code on top -- that just leads to errors and duplicate code is nobody's friend. I'll post an update when I've got it working at all... S From listsin at integrateddevcorp.com Wed Apr 7 04:07:02 2010 From: listsin at integrateddevcorp.com (Steve Steiner (listsin)) Date: Tue, 6 Apr 2010 22:07:02 -0400 Subject: [ftputil] Moving tests out of the main directory Message-ID: <0ED322B3-73AE-4362-B032-A298DADDE672@integrateddevcorp.com> Stefan, Would you have any objection to my moving the tests and ftputil code down into separate subdirectories? More to the point, would you pull the changes over? Most projects, these days, are like this: ftputil: setup.py setup.cfg TODO, README etc. (sometimes README.html built into doc directory) ftputil: where the code actually goes test(s): where all the tests go (callable by # python setup.py test) doc: all the docs (mostly built by Sphinx, these days) It's a little deeper, but makes things much easier to find. ftputil's currently a little "flat" and there's just too many files to hunt through for my poor tired brain. Thanks, S aka/Steve Steiner aka/steinerX at gmail.com From sschwarzer at sschwarzer.net Wed Apr 7 10:16:23 2010 From: sschwarzer at sschwarzer.net (Stefan Schwarzer) Date: Wed, 07 Apr 2010 10:16:23 +0200 Subject: [ftputil] Updating/modernizing ftpsync In-Reply-To: References: <300DCC58-A6A7-4088-84C8-BF6895B3C176@integrateddevcorp.com> <4BBBB426.9040900@sschwarzer.net> Message-ID: <4BBC3F57.6060001@sschwarzer.net> Hi Steve, On 2010-04-07 00:45, Steve Steiner (listsin) wrote: > On Apr 6, 2010, at 6:22 PM, Stefan Schwarzer wrote: >> On 2010-04-06 01:45, Steve Steiner (listsin) wrote: >>> I'm updating the ftpsync program, which has been >>> included as "ftpsync0.1" in ftputil. >> Just for the record I'd like to mention that the code in >> the ftpsync-0.1 subdirectory has been contributed by Martin >> Wilck. > > I haven't removed any of his copyright notices or anything > and I e-mailed to ask his permission and to ask whether > there was any contact info he wanted added. Sorry, I didn't want to say you had done anything wrong. My intention rather was to say I hadn't written the code and wanted to credit Martin explicitly. > Frankly, I can't get ftpsync, in its curent form, to do > anything, now that I've got it all moved...there doesn't > seem to be any argument for adding a password and it > doesn't prompt, for example. > [...] > Right now, it just raises an exception without comment > trying to connect... What kind of exception? (Um, don't mind my asking. If you like, you can of course make it work on your own first, without letting you get distracted by my list posts. ;) ) > I'll post an update when I've got it working at all... Thanks! :-) Stefan From sschwarzer at sschwarzer.net Wed Apr 7 10:52:53 2010 From: sschwarzer at sschwarzer.net (Stefan Schwarzer) Date: Wed, 07 Apr 2010 10:52:53 +0200 Subject: [ftputil] Moving tests out of the main directory In-Reply-To: <0ED322B3-73AE-4362-B032-A298DADDE672@integrateddevcorp.com> References: <0ED322B3-73AE-4362-B032-A298DADDE672@integrateddevcorp.com> Message-ID: <4BBC47E5.8000904@sschwarzer.net> Hi Steve, On 2010-04-07 04:07, Steve Steiner (listsin) wrote: > Would you have any objection to my moving the tests and > ftputil code down into separate subdirectories? > > More to the point, would you pull the changes over? > > Most projects, these days, are like this: > > ftputil: > setup.py > setup.cfg > TODO, README etc. (sometimes README.html built into doc directory) > ftputil: > where the code actually goes I wasn't so sure about that one, but just checked recent additions/updates on the Python package index and examined the current distutils documentation [1]. - You're right. > test(s): > where all the tests go (callable by # python setup.py test) That has indeed be common for quite some time, but I haven't changed it so far. > doc: > all the docs (mostly built by Sphinx, these days) Probably it's not necessary to change the docs generation to Sphinx, given the documentation is one file. On the other hand, it might make sense to split the documentation into several files. Apart from that, I don't object to putting the documentation in its own directory. > It's a little deeper, but makes things much easier to find. > > ftputil's currently a little "flat" and there's just too > many files to hunt through for my poor tired brain. *grin* To ease this burden on my part, I came up with prepending the tests with "_test_" instead of the more common "test_", so they don't show up in-between the other files but rather a bit separated at the start of a directory listing. (Ironically, meanwhile the `ls` command in my Linux distribution is "smart" enough to ignore the leading underscore. On the plus side, this puts the test files very much near the end of the listing because there are only a few files starting with t and "above". ;-) ) All that said, I think it would be great if you changed the layout in the way you described and I would include these changes, possibly with small variations. If possible, make sure that you use the current ftputil repository as the basis for the changes. Additionally, all tests should run and pass. Where do you think the `Makefile` should go? It's not part of the source distribution and if it's used in a cloned repository for development it's IMHO most practical to leave it in the root directory because it works not only on files in the package directory. > Thanks, I thank _you_. :) [1] http://docs.python.org/distutils/examples.html#pure-python-distribution-by-package Stefan From listsin at integrateddevcorp.com Wed Apr 7 13:52:23 2010 From: listsin at integrateddevcorp.com (Steve Steiner (listsin)) Date: Wed, 7 Apr 2010 07:52:23 -0400 Subject: [ftputil] Updating/modernizing ftpsync In-Reply-To: <4BBC3F57.6060001@sschwarzer.net> References: <300DCC58-A6A7-4088-84C8-BF6895B3C176@integrateddevcorp.com> <4BBBB426.9040900@sschwarzer.net> <4BBC3F57.6060001@sschwarzer.net> Message-ID: <5D3F8D84-5D00-451B-B4F4-6A6FE479261C@integrateddevcorp.com> On Apr 7, 2010, at 4:16 AM, Stefan Schwarzer wrote: >> Frankly, I can't get ftpsync, in its curent form, to do >> anything, now that I've got it all moved...there doesn't >> seem to be any argument for adding a password and it >> doesn't prompt, for example. >> [...] >> Right now, it just raises an exception without comment >> trying to connect... > > What kind of exception? (Um, don't mind my asking. If you > like, you can of course make it work on your own first, > without letting you get distracted by my list posts. ;) ) > >> I'll post an update when I've got it working at all... > > Thanks! :-) I got it working (and ripped out some code, too!) S From listsin at integrateddevcorp.com Wed Apr 7 14:09:16 2010 From: listsin at integrateddevcorp.com (Steve Steiner (listsin)) Date: Wed, 7 Apr 2010 08:09:16 -0400 Subject: [ftputil] Big hangup, not sure what is the solution Message-ID: <358C8C5F-BB76-4BE5-A1C6-37A2B24CB9C6@integrateddevcorp.com> I'm working on ftpsync. One of the first things it does is call synchronixe_times, which, when there's an error (i.e. the login dir is not writable) raises an error trying to delete the file that it couldn't create instead of raising TimeShiftError, as documented. Unfortunately, I'm trying to sync a subdirectory of a server and I do *not* have write access to the root. Since it's a file-level error, the raise could be from any number of actual problems (theoretically) so handling the general file-level error seems like a bad idea. Any chance of getting TimeShiftError raised properly (see bug #46) before I do my file reorganization? I see where to do it, as noted in the bug, but I want my big reorg change to be only that so we don't get a mixed metaphor merging the structural change in with a code change. Unless you want some practice doing Mercurial merges ;-) ...don't worry, they're FUN compared to svn. Thanks, S From listsin at integrateddevcorp.com Fri Apr 9 02:24:49 2010 From: listsin at integrateddevcorp.com (Steve Steiner (listsin)) Date: Thu, 8 Apr 2010 20:24:49 -0400 Subject: [ftputil] Passthroughs to make conversion easier Message-ID: I'm converting some code from regular Python FTP to ftputil. While I find ftputil's convenience functions useful, it seems counter-intuitive to have to change over a whole collection of simple functions to make the conversion. Here's an example of how I just quickly did this in my code, though it'd be much nicer if it were built-in: f = ftputil.FTPHost(host, login, passwd) f.pwd = f.getcwd f.cwd = f.chdir Any reason these simple passthroughs couldn't just be added to the main FTPHost class? It sure would make converting over to ftputil incrementally much easier. S From sschwarzer at sschwarzer.net Fri Apr 9 07:35:46 2010 From: sschwarzer at sschwarzer.net (Stefan Schwarzer) Date: Fri, 09 Apr 2010 07:35:46 +0200 Subject: [ftputil] Passthroughs to make conversion easier In-Reply-To: References: Message-ID: <4BBEBCB2.7080902@sschwarzer.net> Hi Steve, On 2010-04-09 02:24, Steve Steiner (listsin) wrote: > I'm converting some code from regular Python FTP to ftputil. > > While I find ftputil's convenience functions useful, it > seems counter-intuitive to have to change over a whole > collection of simple functions to make the conversion. > > Here's an example of how I just quickly did this in my > code, though it'd be much nicer if it were built-in: > > f = ftputil.FTPHost(host, login, passwd) > f.pwd = f.getcwd > f.cwd = f.chdir > > Any reason these simple passthroughs couldn't just be > added to the main FTPHost class? The main point in the design of FTPHost's interface(s) is the similarity to the filesystem functions in the os and shutil modules: os.getcwd -> FTPHost.getcwd os.listdir -> FTPHost.listdir shutil.copyfileobj -> FTPHost.copyfileobj etc. In the same spirit, the exceptions FTPOSError and FTPIOError inherit from OSError and IOError, respectively. This allows you to write generic code like def make_dir_tree(root_name, os_api=os): try: os_api.mkdir(root_name) os_api.chdir(root_name) for subdir in ("bin", "test", "doc"): os_api.mkdir(subdir) except OSError: # handle it and then make_dir_tree(local_name) or host = ftputil.FTPHost(hostname, userid, password) make_dir_tree(remote_name, os_api=host) That's the reason for the current interface. Regarding adding an interface similar to that of ftplib.FTP, I wouldn't want to put that _also_ into FTPHost. Moreover, even if aliases as above would be added, this would be misleading since that doesn't make FTPHost.cwd stand in for ftplib.FTP.cwd. The former may throw an ftp_error.PermanentError, the latter an ftplib.error_perm, so you would have to change the exception handling anyway. An example: If "ftp" were either an ftplib.FTP or ftputil.FTPHost object, ftp.cwd(new_dir) would give you no clue how the code would behave in case of an error. For all these reasons I think the attributes with names like those in ftplib.FTP should _not_ be added to FTPHost. > It sure would make converting over to ftputil > incrementally much easier. If you still want the alternative attribute names, you could use code like class MyFTPHost(ftputil.FTPHost): pwd = ftputil.FTPHost.getcwd cwd = ftputil.FTPHost.chdir ... host = MyFTPHost(hostname, userid, password) my_dir = host.pwd() or def decorate_ftp_object(host): host.pwd = host.getcwd host.cwd = host.chdir ... host = ftputil.FTPHost(hostname, userid, password) decorate_ftp_object(host) my_dir = host.pwd() It might be worthwhile to show us some of your code. Maybe a different approach will work better for you. Stefan From sschwarzer at sschwarzer.net Fri Apr 9 07:55:39 2010 From: sschwarzer at sschwarzer.net (Stefan Schwarzer) Date: Fri, 09 Apr 2010 07:55:39 +0200 Subject: [ftputil] Big hangup, not sure what is the solution In-Reply-To: <358C8C5F-BB76-4BE5-A1C6-37A2B24CB9C6@integrateddevcorp.com> References: <358C8C5F-BB76-4BE5-A1C6-37A2B24CB9C6@integrateddevcorp.com> Message-ID: <4BBEC15B.3080305@sschwarzer.net> Hi Steve, On 2010-04-07 14:09, Steve Steiner (listsin) wrote: > One of the first things it does is call synchronixe_times, > which, when there's an error (i.e. the login dir is not > writable) raises an error trying to delete the file that > it couldn't create instead of raising TimeShiftError, as > documented. There's now a fix in the repository which should ensure that the correct exception is raised. Note that synchronize_times is _not_ called automatically. You can call it anytime in any directory (but possibly have to live with a TimeShiftError if that directory isnt' writable). If you can't write in any way, you may still set the time shift with set_time_shift though this requires to know the value by other means. > I see where to do it, as noted in the bug, but I want my > big reorg change to be only that so we don't get a mixed > metaphor merging the structural change in with a code > change. Unless you want some practice doing Mercurial > merges ;-) ...don't worry, they're FUN compared to svn. I know. I have some practice with both Subversion and Mercurial merges. :-) Stefan From listsin at integrateddevcorp.com Fri Apr 9 11:58:04 2010 From: listsin at integrateddevcorp.com (Steve Steiner (listsin)) Date: Fri, 9 Apr 2010 05:58:04 -0400 Subject: [ftputil] Passthroughs to make conversion easier In-Reply-To: <4BBEBCB2.7080902@sschwarzer.net> References: <4BBEBCB2.7080902@sschwarzer.net> Message-ID: On Apr 9, 2010, at 1:35 AM, Stefan Schwarzer wrote: > Hi Steve, > > On 2010-04-09 02:24, Steve Steiner (listsin) wrote: >> I'm converting some code from regular Python FTP to ftputil. >> >> While I find ftputil's convenience functions useful, it >> seems counter-intuitive to have to change over a whole >> collection of simple functions to make the conversion. >> >> Here's an example of how I just quickly did this in my >> code, though it'd be much nicer if it were built-in: >> >> f = ftputil.FTPHost(host, login, passwd) >> f.pwd = f.getcwd >> f.cwd = f.chdir >> >> Any reason these simple passthroughs couldn't just be >> added to the main FTPHost class? > > def decorate_ftp_object(host): > host.pwd = host.getcwd > host.cwd = host.chdir > > It might be worthwhile to show us some of your code. Maybe a > different approach will work better for you. Uh...the example code you gave is virtually identical to what I wrote earlier in the message. Point well taken about the differing exceptions, they would have to be more thoroughly wrapped to do a good job of this; I'll just kludge it in per-project. S From sschwarzer at sschwarzer.net Fri Apr 9 12:10:25 2010 From: sschwarzer at sschwarzer.net (Stefan Schwarzer) Date: Fri, 09 Apr 2010 12:10:25 +0200 Subject: [ftputil] Passthroughs to make conversion easier In-Reply-To: References: <4BBEBCB2.7080902@sschwarzer.net> Message-ID: <4BBEFD11.4020400@sschwarzer.net> On 2010-04-09 11:58, Steve Steiner (listsin) wrote: > On Apr 9, 2010, at 1:35 AM, Stefan Schwarzer wrote: >> On 2010-04-09 02:24, Steve Steiner (listsin) wrote: >>> I'm converting some code from regular Python FTP to ftputil. >>> >>> While I find ftputil's convenience functions useful, it >>> seems counter-intuitive to have to change over a whole >>> collection of simple functions to make the conversion. >>> >>> Here's an example of how I just quickly did this in my >>> code, though it'd be much nicer if it were built-in: >>> >>> f = ftputil.FTPHost(host, login, passwd) >>> f.pwd = f.getcwd >>> f.cwd = f.chdir >>> >>> Any reason these simple passthroughs couldn't just be >>> added to the main FTPHost class? >> def decorate_ftp_object(host): >> host.pwd = host.getcwd >> host.cwd = host.chdir >> >> It might be worthwhile to show us some of your code. Maybe a >> different approach will work better for you. > > Uh...the example code you gave is virtually identical to > what I wrote earlier in the message. That was intentional. It seemed as if you did something like that over and over (though I can't really believe you would do it :) ), and I tried to show that you can easily refactor those attribute re-assignments ... up to the point that having the assignments in FTPHost itself would be almost no advantage overall. Stefan From sschwarzer at sschwarzer.net Tue Apr 13 10:11:19 2010 From: sschwarzer at sschwarzer.net (Stefan Schwarzer) Date: Tue, 13 Apr 2010 10:11:19 +0200 Subject: [ftputil] Raising the minimum Python version Message-ID: <4BC42727.8020909@sschwarzer.net> Hi everyone, some time ago we discussed a minimum Python version for ftputil [1] and finally settled on 2.3. However, that was almost four years ago, so I guess we can raise the minimum version now. Issues that were mentioned during the past discussion and should be considered: - default versions of Python in current Linux/Unix distributions - Python versions dictated by IT departments - use of Python as extension language in third-party products [2] So I think the question is if we can go straight to Python 2.5 as minimum requirement or stick to 2.4 to be on the safe side. What do you think? [1] http://codespeak.net/pipermail/ftputil/2006q3/thread.html#96 [2] http://codespeak.net/pipermail/ftputil/2006q3/000104.html Stefan From listsin at integrateddevcorp.com Tue Apr 13 13:52:03 2010 From: listsin at integrateddevcorp.com (Steve Steiner (listsin)) Date: Tue, 13 Apr 2010 07:52:03 -0400 Subject: [ftputil] Raising the minimum Python version In-Reply-To: <4BC42727.8020909@sschwarzer.net> References: <4BC42727.8020909@sschwarzer.net> Message-ID: On Apr 13, 2010, at 4:11 AM, Stefan Schwarzer wrote: > So I think the question is if we can go straight to Python > 2.5 as minimum requirement or stick to 2.4 to be on the safe > side. > > What do you think? My vote is to go direct to 2.5, as you know. Conditional expressions, partial functions, unified try/except/finally, new generator features (pass value *into* generator), and new style class Exceptions. The biggies, for ftputil, the 'with' statement and unified try/except/finally which can smooth out use considerably. Each of the improvements (especially 'with' and the unified try/except/finally) adds something to the language that seems 'missing' after using it for even a little while. Anyone using 2.3 or 2.4 can, of course, still use the 2.4.x series of ftputil and it's not like it's buggy; just older ;-) +1 for 2.5. S From roger.demetrescu at gmail.com Tue Apr 13 16:09:41 2010 From: roger.demetrescu at gmail.com (Roger Demetrescu) Date: Tue, 13 Apr 2010 11:09:41 -0300 Subject: [ftputil] Raising the minimum Python version In-Reply-To: <4BC42727.8020909@sschwarzer.net> References: <4BC42727.8020909@sschwarzer.net> Message-ID: On Tue, Apr 13, 2010 at 05:11, Stefan Schwarzer wrote: > Hi everyone, Hi Stefan, > So I think the question is if we can go straight to Python > 2.5 as minimum requirement or stick to 2.4 to be on the safe > side. > > What do you think? +1 from me Cheers From roger.demetrescu at gmail.com Tue Apr 13 18:26:35 2010 From: roger.demetrescu at gmail.com (Roger Demetrescu) Date: Tue, 13 Apr 2010 13:26:35 -0300 Subject: [ftputil] Raising the minimum Python version In-Reply-To: References: <4BC42727.8020909@sschwarzer.net> Message-ID: On Tue, Apr 13, 2010 at 11:09, Roger Demetrescu wrote: > On Tue, Apr 13, 2010 at 05:11, Stefan Schwarzer > wrote: >> Hi everyone, > > Hi Stefan, > >> So I think the question is if we can go straight to Python >> 2.5 as minimum requirement or stick to 2.4 to be on the safe >> side. >> >> What do you think? > > +1 from me Ooops.. +1 from me regarding Python >= 2.5 :) From markus.falb at fasel.at Tue Apr 13 19:04:57 2010 From: markus.falb at fasel.at (Markus Falb) Date: Tue, 13 Apr 2010 19:04:57 +0200 Subject: [ftputil] Raising the minimum Python version In-Reply-To: <4BC42727.8020909@sschwarzer.net> References: <4BC42727.8020909@sschwarzer.net> Message-ID: <2940C0D9-58A7-47BA-B568-BE1A2156F957@fasel.at> On 13 Apr 2010, at 10:11, Stefan Schwarzer wrote: > > So I think the question is if we can go straight to Python > 2.5 as minimum requirement or stick to 2.4 to be on the safe > side. > I am using Redhat Enterprise or clones mostly and that ships with 2.4 Therefore i suggest sticking with 2.4 for now. -- best regards, markus -------------- next part -------------- A non-text attachment was scrubbed... Name: PGP.sig Type: application/pgp-signature Size: 195 bytes Desc: This is a digitally signed message part Url : http://codespeak.net/pipermail/ftputil/attachments/20100413/721047ee/attachment.pgp From sschwarzer at sschwarzer.net Sat Apr 17 12:02:09 2010 From: sschwarzer at sschwarzer.net (Stefan Schwarzer) Date: Sat, 17 Apr 2010 12:02:09 +0200 Subject: [ftputil] Raising the minimum Python version In-Reply-To: <4BC42727.8020909@sschwarzer.net> References: <4BC42727.8020909@sschwarzer.net> Message-ID: <4BC98721.90204@sschwarzer.net> Hello, Thanks for your input. :-) On 2010-04-13 10:11, Stefan Schwarzer wrote: > Issues that were mentioned during the past discussion and > should be considered: > > - default versions of Python in current Linux/Unix > distributions >From what I've seen in this thread, it seems wisest to stick to Python 2.4 for now, as several distributions ship that as default Python version and I don't want to make it unnecessarily complicated for their users ... > - Python versions dictated by IT departments ... especially in this light. I've thought about following Steve's suggestion and use Python 2.5 for the upcoming ftputil 2.5 and above and maintain compatibility with Python 2.4 in the ftputil 2.4.x series. However, the resources spent on developing ftputil are already quite limited, and I think it's better to spend these resources on new features instead of maintaining an additional branch. I don't think that the benefits of Python 2.5 over 2.4 outweigh this. A note regarding the `with` statement: Whereas we can't use `with` in ftputil itself because of now sticking to Python 2.4, it's already possible to use the `with` statement in code that _uses_ ftputil [1]. (This is because you don't need `with` to implement `with` support, but instead just add special methods `__enter__` and `__exit__`.) [1] http://ftputil.sschwarzer.net/trac/wiki/Documentation#support-for-the-with-statement http://ftputil.sschwarzer.net/trac/wiki/Documentation#id5 Stefan From Thomas.Fischer at statkraft.de Tue May 25 11:06:01 2010 From: Thomas.Fischer at statkraft.de (Fischer Thomas Hans) Date: Tue, 25 May 2010 11:06:01 +0200 Subject: [ftputil] How to delete files with a Python script from a FTP server which are older than 7 days (with FTP Util)? Message-ID: <3179AEEED2105848A0418C4B7D8D83B203321E32BD@de-exch-01.eur.energycorp.com> Hello everyone, I would like to write a Python script (with FTP Util) which allows me to delete files from a FTP Server after they have reached a certain age. I prepared a script using regular FTP which is unfortunately not working. Probably someone have an idea how to resolve this task with ftpuil? I am very new to Python programming. Thank you in advance! import os, time from ftplib import FTP ftp = FTP('127.0.0.1') print "Automated FTP Maintainance" print 'Logging in.' ftp.login('admin', 'admin') # This is the directory that we want to go to path = 'test123' print 'Changing to:' + path ftp.cwd(path) files = ftp.retrlines('LIST') print 'List of Files:' + files #--everything works fine until here!... #--The Logic which shall delete the files after they are 7 days old-- now = time.time() for f in os.listdir(path): if os.stat(f).st_mtime < now - 7 * 86400: if os.path.isfile(f): os.remove(os.path.join(path, f)) except: exit ("Cannot delete files") print 'Closing FTP connection' ftp.close() With kind regards, Mit freundlichem Gru?, Thomas Fischer -------------- next part -------------- An HTML attachment was scrubbed... URL: http://codespeak.net/pipermail/ftputil/attachments/20100525/88177516/attachment.htm From sschwarzer at sschwarzer.net Tue May 25 12:13:54 2010 From: sschwarzer at sschwarzer.net (Stefan Schwarzer) Date: Tue, 25 May 2010 12:13:54 +0200 Subject: [ftputil] How to delete files with a Python script from a FTP server which are older than 7 days (with FTP Util)? In-Reply-To: <3179AEEED2105848A0418C4B7D8D83B203321E32BD@de-exch-01.eur.energycorp.com> References: <3179AEEED2105848A0418C4B7D8D83B203321E32BD@de-exch-01.eur.energycorp.com> Message-ID: <4BFBA2E2.1090908@sschwarzer.net> Hello Thomas, On 2010-05-25 11:06, Fischer Thomas Hans wrote: > I would like to write a Python script (with FTP Util) > which allows me to delete files from a FTP Server after > they have reached a certain age. I prepared a script using > regular FTP which is unfortunately not working. Probably > someone have an idea how to resolve this task with > ftpuil? I am very new to Python programming. It's good you supplied the code. > import os, time > from ftplib import FTP > > ftp = FTP('127.0.0.1') > print "Automated FTP Maintainance" > print 'Logging in.' > ftp.login('admin', 'admin') You get the FTP directory listing from the server ... > # This is the directory that we want to go to > path = 'test123' > print 'Changing to:' + path > ftp.cwd(path) > files = ftp.retrlines('LIST') > print 'List of Files:' + files > #--everything works fine until here!... ... but below you work on the local file system only. If I understood your task correctly you instead wanted the files to be deleted on the FTP server. > #--The Logic which shall delete the files after they are 7 days old-- > now = time.time() > for f in os.listdir(path): > if os.stat(f).st_mtime < now - 7 * 86400: > if os.path.isfile(f): > os.remove(os.path.join(path, f)) It's not easily possible to get the timestamp of the last modification of a directory or file with Python's `ftplib` module. You would have to write a parser to extract the timestamps from a directory listing. Fortunately, ftputil has implemented this already. :) I suggest you look at the documentation at http://ftputil.sschwarzer.net/trac/wiki/Documentation and try to come up with a solution using ftputil. If you still have problems with that feel free to ask on the mailing list. :-) > except: I recommend you never use a bare `except:` clause because it can shadow other problems (`NameError`s, `AttributeError`s because of misspelled identifiers etc.). > exit ("Cannot delete files") I guess you either used `from sys import exit` or have a function `exit` which calls `sys.exit`. > print 'Closing FTP connection' > ftp.close() Best regards, Stefan