Skip to content

Commit

Permalink
* s3cmd, S3/CloudFront.py: Both [accesslog] and [cfmodify]
Browse files Browse the repository at this point in the history
  access logging can now be disabled with --no-access-logging


git-svn-id: https://s3tools.svn.sourceforge.net/svnroot/s3tools/s3cmd/trunk@417 830e0280-6d2a-0410-9c65-932aecc39d9d
  • Loading branch information
ludvigm committed Jun 12, 2010
1 parent 2434c10 commit 7bc0fc6
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
5 changes: 5 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2010-06-13 Michal Ludvig <mludvig@logix.net.nz>

* s3cmd, S3/CloudFront.py: Both [accesslog] and [cfmodify]
access logging can now be disabled with --no-access-logging

2010-06-13 Michal Ludvig <mludvig@logix.net.nz>

* S3/CloudFront.py: Allow s3:// URI as well as cf:// URI
Expand Down
7 changes: 5 additions & 2 deletions S3/CloudFront.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ def CreateDistribution(self, uri, cnames_add = [], comment = None, logging = Non
for cname in cnames_add:
if dist_config.info['CNAME'].count(cname) == 0:
dist_config.info['CNAME'].append(cname)
if logging != None:
if logging:
dist_config.info['Logging'] = S3UriS3(logging)
request_body = str(dist_config)
debug("CreateDistribution(): request_body: %s" % request_body)
Expand All @@ -240,7 +240,10 @@ def ModifyDistribution(self, cfuri, cnames_add = [], cnames_remove = [],
while dc.info['CNAME'].count(cname) > 0:
dc.info['CNAME'].remove(cname)
if logging != None:
dc.info['Logging'] = S3UriS3(logging)
if logging == False:
dc.info['Logging'] = False
else:
dc.info['Logging'] = S3UriS3(logging)
response = self.SetDistConfig(cfuri, dc, response['headers']['etag'])
return response

Expand Down
15 changes: 8 additions & 7 deletions s3cmd
Original file line number Diff line number Diff line change
Expand Up @@ -1167,14 +1167,14 @@ def cmd_accesslog(args):
bucket_uri = S3Uri(args.pop())
if bucket_uri.object():
raise ParameterError("Only bucket name is required for [accesslog] command")
if cfg.enable == True:
if cfg.log_target_prefix == False:
accesslog, response = s3.set_accesslog(bucket_uri, enable = False)
elif cfg.log_target_prefix:
log_target_prefix_uri = S3Uri(cfg.log_target_prefix)
if log_target_prefix_uri.type != "s3":
raise ParameterError("--log-target-prefix must be a S3 URI")
accesslog, response = s3.set_accesslog(bucket_uri, enable = True, log_target_prefix_uri = log_target_prefix_uri, acl_public = cfg.acl_public)
elif cfg.enable == False:
accesslog, response = s3.set_accesslog(bucket_uri, enable = False)
else: # cfg.enable == None
else: # cfg.log_target_prefix == None
accesslog = s3.get_accesslog(bucket_uri)

output(u"Access logging for: %s" % bucket_uri.uri())
Expand Down Expand Up @@ -1599,7 +1599,8 @@ def main():
optparser.add_option( "--bucket-location", dest="bucket_location", help="Datacentre to create bucket in. As of now the datacenters are: US (default), EU, us-west-1, and ap-southeast-1")
optparser.add_option( "--reduced-redundancy", "--rr", dest="reduced_redundancy", action="store_true", help="Store object with 'Reduced redundancy'. Lower per-GB price. [put, cp, mv]")

optparser.add_option( "--log-target-prefix", dest="log_target_prefix", help="Target prefix for access logs (S3 URI) (for [cfmodify] and [accesslog] commands)")
optparser.add_option( "--access-logging-target-prefix", dest="log_target_prefix", help="Target prefix for access logs (S3 URI) (for [cfmodify] and [accesslog] commands)")
optparser.add_option( "--no-access-logging", dest="log_target_prefix", action="store_false", help="Disable access logging (for [cfmodify] and [accesslog] commands)")

optparser.add_option("-m", "--mime-type", dest="default_mime_type", type="mimetype", metavar="MIME/TYPE", help="Default MIME-type to be set for objects stored.")
optparser.add_option("-M", "--guess-mime-type", dest="guess_mime_type", action="store_true", help="Guess MIME-type of files by their extension. Falls back to default MIME-Type as specified by --mime-type option")
Expand All @@ -1614,8 +1615,8 @@ def main():

optparser.add_option( "--progress", dest="progress_meter", action="store_true", help="Display progress meter (default on TTY).")
optparser.add_option( "--no-progress", dest="progress_meter", action="store_false", help="Don't display progress meter (default on non-TTY).")
optparser.add_option( "--enable", dest="enable", action="store_true", help="Enable given CloudFront distribution (for [cfmodify] command) or access logging (for [accesslog] command)")
optparser.add_option( "--disable", dest="enable", action="store_false", help="Enable given CloudFront distribution (only for [cfmodify] command) or access logging (for [accesslog] command)")
optparser.add_option( "--enable", dest="enable", action="store_true", help="Enable given CloudFront distribution (only for [cfmodify] command)")
optparser.add_option( "--disable", dest="enable", action="store_false", help="Enable given CloudFront distribution (only for [cfmodify] command)")
optparser.add_option( "--cf-add-cname", dest="cf_cnames_add", action="append", metavar="CNAME", help="Add given CNAME to a CloudFront distribution (only for [cfcreate] and [cfmodify] commands)")
optparser.add_option( "--cf-remove-cname", dest="cf_cnames_remove", action="append", metavar="CNAME", help="Remove given CNAME from a CloudFront distribution (only for [cfmodify] command)")
optparser.add_option( "--cf-comment", dest="cf_comment", action="store", metavar="COMMENT", help="Set COMMENT for a given CloudFront distribution (only for [cfcreate] and [cfmodify] commands)")
Expand Down

0 comments on commit 7bc0fc6

Please sign in to comment.