Browse code

* s3cmd: Added --list-md5 for 'ls' command. * S3/Config.py: New setting list_md5

git-svn-id: https://s3tools.svn.sourceforge.net/svnroot/s3tools/s3cmd/trunk@371 830e0280-6d2a-0410-9c65-932aecc39d9d

Michal Ludvig authored on 2009/02/12 09:00:12
Showing 4 changed files
... ...
@@ -1,5 +1,10 @@
1 1
 2009-02-12  Michal Ludvig  <michal@logix.cz>
2 2
 
3
+	* s3cmd: Added --list-md5 for 'ls' command.
4
+	* S3/Config.py: New setting list_md5
5
+
6
+2009-02-12  Michal Ludvig  <michal@logix.cz>
7
+
3 8
 	* s3cmd: Set Content-Length header for requests with 'body'.
4 9
 	* s3cmd: And send it for requests with no body as well...
5 10
 
... ...
@@ -1,3 +1,8 @@
1
+s3cmd 0.9.9
2
+===========
3
+* Added --list-md5 option for [ls].
4
+* Always send Content-Length header to satisfy some http proxies.
5
+
1 6
 s3cmd 0.9.9-rc3  - 2009-02-02
2 7
 ===============
3 8
 * Fixed crash in S3Error().__str__() (typically Amazon's Internal
... ...
@@ -24,6 +24,7 @@ class Config(object):
24 24
 	progress_class = Progress.ProgressCR
25 25
 	send_chunk = 4096
26 26
 	recv_chunk = 4096
27
+	list_md5 = False
27 28
 	human_readable_sizes = False
28 29
 	force = False
29 30
 	get_continue = False
... ...
@@ -118,18 +118,28 @@ def subcmd_bucket_list(s3, uri):
118 118
 		else:
119 119
 			raise
120 120
 
121
+	if cfg.list_md5:
122
+		format_string = u"%(timestamp)16s %(size)9s%(coeff)1s  %(md5)32s  %(uri)s"
123
+	else:
124
+		format_string = u"%(timestamp)16s %(size)9s%(coeff)1s  %(uri)s"
125
+
121 126
 	for prefix in response['common_prefixes']:
122
-		output(u"%s   %s" % (
123
-			"DIR".rjust(26),
124
-			uri.compose_uri(bucket, prefix["Prefix"])))
127
+		output(format_string % {
128
+			"timestamp": "",
129
+			"size": "DIR",
130
+			"coeff": "",
131
+			"md5": "",
132
+			"uri": uri.compose_uri(bucket, prefix["Prefix"])})
125 133
 
126 134
 	for object in response["list"]:
127 135
 		size, size_coeff = formatSize(object["Size"], Config().human_readable_sizes)
128
-		output(u"%s  %s%s  %s" % (
129
-			formatDateTime(object["LastModified"]),
130
-			str(size).rjust(8), size_coeff.ljust(1),
131
-			uri.compose_uri(bucket, object["Key"]),
132
-			))
136
+		output(format_string % {
137
+			"timestamp": formatDateTime(object["LastModified"]),
138
+			"size" : str(size), 
139
+			"coeff": size_coeff,
140
+			"md5" : object['ETag'].strip('"'),
141
+			"uri": uri.compose_uri(bucket, object["Key"]),
142
+			})
133 143
 
134 144
 def cmd_bucket_create(args):
135 145
 	s3 = S3(Config())
... ...
@@ -1367,6 +1377,7 @@ def main():
1367 1367
 
1368 1368
 	optparser.add_option(      "--encoding", dest="encoding", metavar="ENCODING", help="Override autodetected terminal and filesystem encoding (character set). Autodetected: %s" % preferred_encoding)
1369 1369
 
1370
+	optparser.add_option(      "--list-md5", dest="list_md5", action="store_true", help="Include MD5 sums in bucket listings (only for 'ls' command).")
1370 1371
 	optparser.add_option("-H", "--human-readable-sizes", dest="human_readable_sizes", action="store_true", help="Print sizes in human readable form.")
1371 1372
 
1372 1373
 	optparser.add_option(      "--progress", dest="progress_meter", action="store_true", help="Display progress meter (default on TTY).")