| 27 | |
| 28 | ### Proxy setting |
| 29 | def get_proxy_settings(): |
| 30 | http_proxy = os.environ.get('HTTP_PROXY') or os.environ.get('http_proxy') |
| 31 | https_proxy = os.environ.get('HTTPS_PROXY') or os.environ.get('https_proxy') |
| 32 | |
| 33 | proxies = {} |
| 34 | if http_proxy: |
| 35 | proxies['http'] = http_proxy |
| 36 | if https_proxy: |
| 37 | proxies['https'] = https_proxy |
| 38 | |
| 39 | # Try to obtain environ proxies |
| 40 | if not proxies: |
| 41 | try: |
| 42 | system_proxies = requests.utils.get_environ_proxies("") |
| 43 | if system_proxies: |
| 44 | proxies = system_proxies |
| 45 | except Exception as e: |
| 46 | logger.warning(f"Cannot obtain environ proxies: {e}") |
| 47 | |
| 48 | return proxies |
| 49 | |
| 50 | PROXY = get_proxy_settings() # get proxy if exist |
| 51 | |