Skip to content

Commit 26ce204

Browse files
committed
don't use env vars
1 parent 4d9d711 commit 26ce204

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

erddapy/core/url.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,21 @@ def _sort_url(url):
4343
def _urlopen(url: str, auth: tuple | None = None, **kwargs: dict) -> BinaryIO:
4444
if "timeout" not in kwargs.keys():
4545
kwargs["timeout"] = 60
46+
user = kwargs.pop("user", None)
47+
password = kwargs.pop("password", None)
4648
with httpx.Client() as client:
4749
p = parse.urlparse(url)
4850
protocol = "tabledap" if "tabledap" in p.path else "griddap"
4951
base = p.path.split(f"/{protocol}/")[0]
50-
login_page = f"{p.scheme}://{p.netloc}{base}/login.html"
51-
client.post(
52-
login_page,
53-
data={
54-
"user": os.getenv("ERDDAP_USERNAME"),
55-
"password": os.getenv("ERDDAP_PASSWORD"),
56-
},
57-
)
52+
if user is not None and password is not None:
53+
login_page = f"{p.scheme}://{p.netloc}{base}/login.html"
54+
client.post(
55+
login_page,
56+
data={
57+
"user": f"{user}",
58+
"password": f"{password}",
59+
},
60+
)
5861
response = client.get(url, follow_redirects=True, auth=auth, **kwargs)
5962

6063
try:

erddapy/erddapy.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,7 @@ def to_pandas(
362362
response = kw.pop("response", "csvp")
363363
distinct = kw.pop("distinct", False)
364364
url = self.get_download_url(response=response, distinct=distinct)
365+
requests_kwargs = requests_kwargs if requests_kwargs else self.requests_kwargs
365366
return to_pandas(url, requests_kwargs=requests_kwargs, pandas_kwargs=dict(**kw))
366367

367368
def to_ncCF(self, protocol: str = None, **kw):

0 commit comments

Comments
 (0)