Skip to content

Commit 7a6620d

Browse files
Merge pull request #1 from tom832/fix/colorbrewer-offline-fallback
fix: add graceful fallback when ColorBrewer palette loading fails offline
2 parents 742d0bd + ceb31d0 commit 7a6620d

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

configs/.pymolrc.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,11 @@ def should_check() -> bool:
7979
def _load_colorbrewer():
8080
"""Load ColorBrewer palettes into PyMOL."""
8181
url = "https://gist.githubusercontent.com/frankrowe/9007567/raw/colorbrewer.js"
82-
js_text = urllib.request.urlopen(url).read().decode("utf-8")
82+
try:
83+
js_text = urllib.request.urlopen(url, timeout=5).read().decode("utf-8")
84+
except Exception as exc:
85+
print(f"Warning: unable to load ColorBrewer palettes ({exc}). Skipping.")
86+
return
8387

8488
# Extract the JavaScript object containing the ColorBrewer palettes
8589
obj_text = re.search(r"var\s+colorbrewer\s*=\s*(\{.*\});", js_text, flags=re.DOTALL).group(1)

0 commit comments

Comments
 (0)