-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: do not trust env while being able to use proxy (#33)
And change COPERNICUS_MARINE_SERVICE_{} to COPERNICUSMARINE_SERVICE_{} for USERNAME and PASSWORD
- Loading branch information
1 parent
f8a25a1
commit ee23e8c
Showing
17 changed files
with
146 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -66,11 +66,26 @@ Cachier library is used for caching part of the requests (as result of `describe | |
- on **UNIX** platforms: `export COPERNICUSMARINE_CACHE_DIRECTORY=<PATH>` | ||
- on **Windows** platforms: `set COPERNICUSMARINE_CACHE_DIRECTORY=<PATH>` | ||
|
||
### Network configuration | ||
|
||
#### Disable SSL | ||
|
||
A global SSL context is used when making HTTP calls using the `copernicusmarine` Toolbox. For some reason, it can lead to unexpected behavior depending on your network configuration. You can set the `COPERNICUSMARINE_DISABLE_SSL_CONTEXT` environment variable to any value to globally disable the usage of SSL in the toolbox: | ||
|
||
- on **UNIX** platforms: `export COPERNICUSMARINE_DISABLE_SSL_CONTEXT=True` | ||
- on **Windows** platforms: `set COPERNICUSMARINE_DISABLE_SSL_CONTEXT=True` | ||
|
||
#### Trust Env for python libraries | ||
|
||
To do HTTP calls, the Copernicus Marine Toolbox uses two python libraries: requests and aiohttp. By default, those libraries will have `trust_env` values set to `True`. If you want to deactivate this, you can set `COPERNICUSMARINE_TRUST_ENV=False` (default `True`). This can be useful for example if you don't want those libraries to read your `.netrc` file as it has been reported that having a `.netrc` with a line: "default login anonymous password user@site" is incompatible with S3 connection required by the toolbox. | ||
|
||
#### Proxy | ||
|
||
To use proxies, as describe in the [aiohttp documentation](https://docs.aiohttp.org/en/stable/client_advanced.html#proxy-support) you can use two options: | ||
|
||
- set the `HTTPS_PROXY` variable. For eg: `HTTPS_PROXY="http://user:[email protected]"`. It should work even with `COPERNICUSMARINE_TRUST_ENV=False`. | ||
- use a `.netrc` file but be aware that having a line: "default login anonymous password user@site" is incompatible with S3 connection required by the toolbox. Also note that if you have `COPERNICUSMARINE_TRUST_ENV=True` (the default value) then if `NETRC` environment variable is set with a specified location, the `.netrc` file will be read from the specified location there rather than from `~/.netrc`. | ||
|
||
## Command Line Interface (CLI) | ||
|
||
### The `--help` option | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import logging | ||
import os | ||
|
||
logger = logging.getLogger("copernicus_marine_root_logger") | ||
|
||
COPERNICUSMARINE_SERVICE_USERNAME = os.getenv( | ||
"COPERNICUSMARINE_SERVICE_USERNAME" | ||
) or os.getenv("COPERNICUS_MARINE_SERVICE_USERNAME") | ||
if os.getenv("COPERNICUS_MARINE_SERVICE_USERNAME"): | ||
logger.warning( | ||
"COPERNICUS_MARINE_SERVICE_USERNAME is deprecated. " | ||
"Please use COPERNICUSMARINE_SERVICE_USERNAME instead." | ||
) | ||
COPERNICUSMARINE_SERVICE_PASSWORD = os.getenv( | ||
"COPERNICUSMARINE_SERVICE_PASSWORD" | ||
) or os.getenv("COPERNICUS_MARINE_SERVICE_PASSWORD") | ||
if os.getenv("COPERNICUS_MARINE_SERVICE_PASSWORD"): | ||
logger.warning( | ||
"COPERNICUS_MARINE_SERVICE_PASSWORD is deprecated. " | ||
"Please use COPERNICUSMARINE_SERVICE_PASSWORD instead." | ||
) | ||
|
||
COPERNICUSMARINE_CACHE_DIRECTORY = os.getenv( | ||
"COPERNICUSMARINE_CACHE_DIRECTORY", "" | ||
) | ||
|
||
COPERNICUSMARINE_MAX_CONCURRENT_REQUESTS = os.getenv( | ||
"COPERNICUSMARINE_MAX_CONCURRENT_REQUESTS", "15" | ||
) | ||
|
||
COPERNICUSMARINE_DISABLE_SSL_CONTEXT = os.getenv( | ||
"COPERNICUSMARINE_DISABLE_SSL_CONTEXT" | ||
) | ||
COPERNICUSMARINE_TRUST_ENV = os.getenv("COPERNICUSMARINE_TRUST_ENV", "True") | ||
|
||
PROXY_HTTPS = os.getenv("HTTPS_PROXY", "") | ||
PROXY_HTTP = os.getenv("HTTP_PROXY", "") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.