Skip to content

Commit

Permalink
fix(user): overriding api token bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Zhaoyilunnn committed Aug 13, 2024
1 parent e95e9b4 commit f6f6b7e
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions quafu/users/userapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ def save_apitoken(self, apitoken=None):
Save the api-token of your Quafu account.
"""
if apitoken is not None:
import warnings

warnings.warn(
"The argument 'apitoken' in this function will be deprecated "
Expand All @@ -98,7 +97,11 @@ def save_apitoken(self, apitoken=None):
# if the configuration file exists
# only update api token
with open(file_path, "r") as f:
data = json.load(f)
try:
data = json.load(f)
except Exception as e:
warnings.warn(f"Jsonfy api file failed due to {type(e)}:{e}. overriding...")
data = {"url": self.url}
data["token"] = self.api_token
else:
# if the configuration file does not exist
Expand Down

0 comments on commit f6f6b7e

Please sign in to comment.