-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fall back to mirror if helioviewer.org is offline (fixes #5)
- Loading branch information
1 parent
33a57b9
commit 10b962f
Showing
2 changed files
with
21 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from sunpy.net.helioviewer import HelioviewerClient | ||
|
||
|
||
def get_helioviewer_client(): | ||
hv = HelioviewerClient() | ||
if not _is_online(hv): | ||
# fall back to mirror server | ||
print("https://www.helioviewer.org/ seems to be offline," | ||
"switching to mirror at https://helioviewer.ias.u-psud.fr/") | ||
hv = HelioviewerClient("https://helioviewer-api.ias.u-psud.fr/") | ||
return hv | ||
|
||
|
||
def _is_online(hv: HelioviewerClient): | ||
try: | ||
return hv.is_online() | ||
except: | ||
return False |