* s3cmd: Small tweaks to --configure workflow.
git-svn-id: https://s3tools.svn.sourceforge.net/svnroot/s3tools/s3cmd/trunk@146 830e0280-6d2a-0410-9c65-932aecc39d9d
... | ... |
@@ -110,7 +110,8 @@ class S3(object): |
110 | 110 |
response = self.send_request(request) |
111 | 111 |
#debug(response) |
112 | 112 |
response["list"] = getListFromXml(response["data"], "Contents") |
113 |
- if getTextFromXml(response['data'], ".//IsTruncated").lower() != "false": |
|
113 |
+ is_truncated = getTextFromXml(response['data'], ".//IsTruncated") |
|
114 |
+ if is_truncated and is_truncated.lower() != "false": |
|
114 | 115 |
raise Exception("Listing truncated. Please notify s3cmd developers.") |
115 | 116 |
return response |
116 | 117 |
|
... | ... |
@@ -458,28 +458,31 @@ def run_configure(config_file): |
458 | 458 |
output("Success. Your access key and secret key worked fine :-)") |
459 | 459 |
|
460 | 460 |
output("\nNow verifying that encryption works...") |
461 |
- if not getattr(cfg, "gpg_command"): |
|
462 |
- raise Exception("Path to GPG program not set") |
|
463 |
- if not os.path.isfile(getattr(cfg, "gpg_command")): |
|
464 |
- raise Exception("GPG program not found") |
|
465 |
- filename = Utils.mktmpfile() |
|
466 |
- f = open(filename, "w") |
|
467 |
- f.write(os.sys.copyright) |
|
468 |
- f.close() |
|
469 |
- ret_enc = gpg_encrypt(filename) |
|
470 |
- ret_dec = gpg_decrypt(ret_enc[1], ret_enc[2], False) |
|
471 |
- hash = [ |
|
472 |
- Utils.hash_file_md5(filename), |
|
473 |
- Utils.hash_file_md5(ret_enc[1]), |
|
474 |
- Utils.hash_file_md5(ret_dec[1]), |
|
475 |
- ] |
|
476 |
- os.unlink(filename) |
|
477 |
- os.unlink(ret_enc[1]) |
|
478 |
- os.unlink(ret_dec[1]) |
|
479 |
- if hash[0] == hash[2] and hash[0] != hash[1]: |
|
480 |
- output ("Success. Encryption and decryption worked fine :-)") |
|
461 |
+ if not getattr(cfg, "gpg_command") or not getattr(cfg, "gpg_passphrase"): |
|
462 |
+ output("Not configured. Never mind.") |
|
481 | 463 |
else: |
482 |
- raise Exception("Encryption verification error.") |
|
464 |
+ if not getattr(cfg, "gpg_command"): |
|
465 |
+ raise Exception("Path to GPG program not set") |
|
466 |
+ if not os.path.isfile(getattr(cfg, "gpg_command")): |
|
467 |
+ raise Exception("GPG program not found") |
|
468 |
+ filename = Utils.mktmpfile() |
|
469 |
+ f = open(filename, "w") |
|
470 |
+ f.write(os.sys.copyright) |
|
471 |
+ f.close() |
|
472 |
+ ret_enc = gpg_encrypt(filename) |
|
473 |
+ ret_dec = gpg_decrypt(ret_enc[1], ret_enc[2], False) |
|
474 |
+ hash = [ |
|
475 |
+ Utils.hash_file_md5(filename), |
|
476 |
+ Utils.hash_file_md5(ret_enc[1]), |
|
477 |
+ Utils.hash_file_md5(ret_dec[1]), |
|
478 |
+ ] |
|
479 |
+ os.unlink(filename) |
|
480 |
+ os.unlink(ret_enc[1]) |
|
481 |
+ os.unlink(ret_dec[1]) |
|
482 |
+ if hash[0] == hash[2] and hash[0] != hash[1]: |
|
483 |
+ output ("Success. Encryption and decryption worked fine :-)") |
|
484 |
+ else: |
|
485 |
+ raise Exception("Encryption verification error.") |
|
483 | 486 |
|
484 | 487 |
except Exception, e: |
485 | 488 |
error("Test failed: %s" % (e)) |