Browse code

* s3cmd: Verify supplied accesskey and secretkey in interactive configuration path.

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

Michal Ludvig authored on 2007/02/28 13:09:12
Showing 2 changed files
... ...
@@ -1,5 +1,7 @@
1 1
 2007-02-28  Michal Ludvig  <michal@logix.cz>
2 2
 
3
+	* s3cmd: Verify supplied accesskey and secretkey
4
+	  in interactive configuration path.
3 5
 	* S3/Config.py: Hide access key and secret key
4 6
 	  from debug output.
5 7
 	* S3/S3.py: Modify S3Error exception to work
... ...
@@ -188,9 +188,24 @@ def run_configure(config_file):
188 188
 			output("\nNew settings:")
189 189
 			for option in options:
190 190
 				output("  %s: %s" % (option[1], getattr(cfg, option[0])))
191
-			val = raw_input("\nChange any setting? [y/N] ")
192
-			if not val.lower().startswith("y"):
191
+			val = raw_input("\nTest access with supplied credentials? [Y/n] ")
192
+			if val.lower().startswith("y") or val == "":
193
+				try:
194
+					output("Please wait...")
195
+					S3(Config()).bucket_list("", "")
196
+					output("\nSuccess. Your access key and secret key worked fine :-)")
197
+				except S3Error, e:
198
+					error("Test failed: %s" % (e))
199
+					val = raw_input("\nRetry configuration? [Y/n] ")
200
+					if val.lower().startswith("y") or val == "":
201
+						continue
202
+
203
+			val = raw_input("\nSave settings? [y/N] ")
204
+			if val.lower().startswith("y"):
193 205
 				break
206
+			val = raw_input("Retry configuration? [Y/n] ")
207
+			if val.lower().startswith("n"):
208
+				raise EOFError()
194 209
 		f = open(config_file, "w")
195 210
 		cfg.dump_config(f)
196 211
 		f.close()