Skip to content

Commit

Permalink
fix: avoid a bug when the token is saved in an rdt environment (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
12rambau authored Nov 14, 2024
2 parents c7b87e8 + ed634d5 commit 688d4f6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ test = [
"coverage",
]
doc = [
"sphinx>=6.2.1",
"sphinx>=6.2.1,<8",
"pydata-sphinx-theme",
"sphinx-copybutton",
"sphinx-design",
Expand Down
11 changes: 10 additions & 1 deletion pytest_gee/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import json
import os
import re
import tempfile
from pathlib import Path
from typing import Union
Expand Down Expand Up @@ -32,8 +33,16 @@ def init_ee_from_token():
"""
if "EARTHENGINE_TOKEN" in os.environ:

# write the token to the appropriate folder
# read the ee_token from the environment variable
ee_token = os.environ["EARTHENGINE_TOKEN"]

# small workaround to remove the quotes around the token
# related to a very specific issue with readthedocs interface
# https://github.com/readthedocs/readthedocs.org/issues/10553
pattern = re.compile(r"^'[^']*'$")
ee_token = ee_token[1:-1] if pattern.match(ee_token) else ee_token

# write the token to the appropriate folder
credential_folder_path = Path.home() / ".config" / "earthengine"
credential_folder_path.mkdir(parents=True, exist_ok=True)
credential_file_path = credential_folder_path / "credentials"
Expand Down

0 comments on commit 688d4f6

Please sign in to comment.