File tree 2 files changed +12
-8
lines changed
2 files changed +12
-8
lines changed Original file line number Diff line number Diff line change @@ -43,18 +43,21 @@ def _sort_url(url):
43
43
def _urlopen (url : str , auth : tuple | None = None , ** kwargs : dict ) -> BinaryIO :
44
44
if "timeout" not in kwargs .keys ():
45
45
kwargs ["timeout" ] = 60
46
+ user = kwargs .pop ("user" , None )
47
+ password = kwargs .pop ("password" , None )
46
48
with httpx .Client () as client :
47
49
p = parse .urlparse (url )
48
50
protocol = "tabledap" if "tabledap" in p .path else "griddap"
49
51
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
+ )
58
61
response = client .get (url , follow_redirects = True , auth = auth , ** kwargs )
59
62
60
63
try :
Original file line number Diff line number Diff line change @@ -362,6 +362,7 @@ def to_pandas(
362
362
response = kw .pop ("response" , "csvp" )
363
363
distinct = kw .pop ("distinct" , False )
364
364
url = self .get_download_url (response = response , distinct = distinct )
365
+ requests_kwargs = requests_kwargs if requests_kwargs else self .requests_kwargs
365
366
return to_pandas (url , requests_kwargs = requests_kwargs , pandas_kwargs = dict (** kw ))
366
367
367
368
def to_ncCF (self , protocol : str = None , ** kw ):
You can’t perform that action at this time.
0 commit comments