* s3cmd: --configure support for Proxy
git-svn-id: https://s3tools.svn.sourceforge.net/svnroot/s3tools/s3cmd/trunk@129 830e0280-6d2a-0410-9c65-932aecc39d9d
... | ... |
@@ -8,6 +8,8 @@ |
8 | 8 |
import sys |
9 | 9 |
import logging |
10 | 10 |
import time |
11 |
+import os |
|
12 |
+import re |
|
11 | 13 |
|
12 | 14 |
from copy import copy |
13 | 15 |
from optparse import OptionParser, Option, OptionValueError, IndentedHelpFormatter |
... | ... |
@@ -276,10 +278,19 @@ def run_configure(config_file): |
276 | 276 |
("secret_key", "Secret Key"), |
277 | 277 |
("gpg_passphrase", "Encryption password", "Encryption password is used to protect your files from reading\nby unauthorized persons while in transfer to S3"), |
278 | 278 |
("gpg_command", "Path to GPG program"), |
279 |
+ ("proxy_host", "HTTP Proxy server name", "On some networks all internet access must go through a HTTP proxy.\nTry setting it here if you can't conect to S3 directly"), |
|
280 |
+ ("proxy_port", "HTTP Proxy server port"), |
|
279 | 281 |
] |
282 |
+ ## Option-specfic defaults |
|
280 | 283 |
if getattr(cfg, "gpg_command") == "": |
281 | 284 |
setattr(cfg, "gpg_command", find_executable("gpg")) |
282 | 285 |
|
286 |
+ if getattr(cfg, "proxy_host") == "" and os.getenv("http_proxy"): |
|
287 |
+ re_match=re.match("(http://)?([^:]+):(\d+)", os.getenv("http_proxy")) |
|
288 |
+ if re_match: |
|
289 |
+ setattr(cfg, "proxy_host", re_match.groups()[1]) |
|
290 |
+ setattr(cfg, "proxy_port", re_match.groups()[2]) |
|
291 |
+ |
|
283 | 292 |
try: |
284 | 293 |
while 1: |
285 | 294 |
output("\nEnter new values or accept defaults in brackets with Enter.") |