# $Id$ ############################################################################# # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################## from s3sync import S3Sync import s3syncconfig class S3SyncConsole(S3Sync): def sync_one(self, info, out): print >>out, info.key, '...', if info.is_local_exist(): response = self.upload_item(info) print >>out, 'upload...', else: response = self.download_item(info) print >>out, 'download...', print >>out, response.reason, if response.status == 200: size = response.size elapse = response.elapse print >>out, '(%d bytes, %.2f sec, %.2f KB/s)' % (size, elapse, size/elapse/1024), print >>out, '' def main(out=None, errout=None): if not out: import sys out = sys.stdout if not errout: import sys errout = sys.stderr confs = s3syncconfig.loadSettings() if not confs: print >>errout, 'Setup your config.ini!!' print >>errout, s3syncconfig.filepath() import sys sys.exit() for conf in confs: print >>out, '** make info for', conf.bucket_name, '...' sync = S3SyncConsole(conf.s3_access_key, conf.s3_secret_key, conf.sync_base_dir, conf.s3_access_key + '-' + conf.bucket_name, ) sync.sync(out) print >>out if __name__ == '__main__': main()