Hi Jon, > I see that the s3cmd > script has a cmd_object_put(args) function which I want to call. > However, I'm having problems importing > the s3cmd script in order to use this function. Could somebody please > provide some guidance?
to be honest s3cmd wasn't designed to be used this way. I have later changed my mind and some new features are actually importable into other python scripts (CloudFront module for example) but the core of s3cmd may require some amount of work to be used that way. So it's not reasonably possible to import stuff directly from s3cmd. However you can import all the low-level functions from S3.* modules and more or less copy and paste whatever you need from s3cmd to your program. In most cases the s3cmd functions only do argument parsing and output formatting and may not be directly usable from within your application anyway. Here's a quick re-implementation of 's3cmd ls' in a standalone script. It only needs the S3.* modules but not the main script s3cmd: $ cat s3-ls.py #!/usr/bin/env python import os from S3.Exceptions import * from S3.S3 import S3 from S3.Config import Config from S3.Utils import formatDateTime def buckets_list_all(s3): response = s3.list_all_buckets() for bucket in response["list"]: print(u"%s s3://%s" % ( formatDateTime(bucket["CreationDate"]), bucket["Name"], )) if __name__ == "__main__": config_file = os.path.join(os.getenv("HOME"), ".s3cfg") cfg = Config(config_file) s3 = S3(cfg) buckets_list_all(s3) This way you can probably integrate cmd_object_put to your application. Or simply call s3cmd from os.system(): import os ret = os.system("/usr/bin/s3cmd ls") There's no need for a bash wrapper. HTH, Michal ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ S3tools-general mailing list S3tools-general@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/s3tools-general