Skip to content

Commit

Permalink
Merge pull request #6 from ecmwf/develop
Browse files Browse the repository at this point in the history
Release 0.7.3
  • Loading branch information
jameshawkes authored Feb 21, 2024
2 parents 7429d50 + 066d291 commit a93a5ea
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 11 deletions.
26 changes: 17 additions & 9 deletions polytope/api/Auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,17 +148,25 @@ def fetch_key(self, login=True):
email = self.read_email
self._logger.info("Polytope user key found in session cache for user " + config["username"])
else:
key_file = Path(config["key_path"]) / config["username"]
key_file = Path(config["key_path"])
try:
with open(str(key_file), "r") as infile:
info = json.load(infile)
key = info["key"]
email = info["email"]
key = info["user_key"]
email = info["user_email"]

# TODO: this is messy
except FileNotFoundError:
key = None
email = None
if login:
key, email = self.login(persist=False)
try:
with open(str(Path.home() / ".ecmwfapirc"), "r") as infile:
info = json.load(infile)
key = info["key"]
email = info["email"]
except FileNotFoundError:
key = None
email = None
if login:
key, email = self.login(persist=False)
else:
self.read_key = key
self.read_email = email
Expand Down Expand Up @@ -188,7 +196,7 @@ def persist(self, key, email, username=None):
if not username:
username = config["username"]
os.makedirs(config["key_path"], exist_ok=True)
key_file = Path(config["key_path"]) / username
key_file = Path(config["key_path"])
with open(str(key_file), "w", encoding="utf8") as outfile:
json.dump({"key": key, "email": email}, outfile)
self.read_key = key
Expand All @@ -212,7 +220,7 @@ def erase(self, username=None):
config = self.config.get()
if not username:
username = config["username"]
key_path = Path(config["key_path"]) / username
key_path = Path(config["key_path"])
try:
os.remove(str(key_path))
self._logger.info("Credentials removed for " + username)
Expand Down
2 changes: 1 addition & 1 deletion polytope/api/Config.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def __init__(
self.config_path = config_path
else:
self.config_path = Path.home() / ".polytope-client"
self.default_config["key_path"] = str(self.config_path / "keys")
self.default_config["key_path"] = Path.home() / ".polytopeapirc"
self.file_config = helpers.read_config(self.config_path)

# Reading env var configuration
Expand Down
1 change: 1 addition & 0 deletions polytope/api/RequestManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@ def retrieve(
situation = "trying to submit a retrieval request"

# replaced_level = helpers.lower_stream_handler_level(self._logger)
# helpers.lower_stream_handler_level(self._logger)
# colls = self.coll_visitor.list()
# helpers.recover_stream_handler_level(self._logger, replaced_level)
# if name not in colls:
Expand Down
2 changes: 1 addition & 1 deletion polytope/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.7.2"
__version__ = "0.7.3"
3 changes: 3 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ extend-ignore = E203
[isort]
profile=black
skip_glob=.*
[tool.ruff]
line-length = 120
lint.extend-select = ["I"]

0 comments on commit a93a5ea

Please sign in to comment.