Skip to content

Commit 30e1d63

Browse files
committed
[Plexon2] Use cached dll if present
1 parent 0f38d32 commit 30e1d63

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

neo/rawio/plexon2rawio/plexon2rawio.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
Author: Julia Sprenger
2121
"""
2222
import pathlib
23+
import warnings
2324
from collections import namedtuple
2425
from urllib.request import urlopen
2526
from datetime import datetime
@@ -75,10 +76,13 @@ def __init__(self, filename, pl2_dll_file_path=None):
7576
pl2_dll_folder.mkdir(exist_ok=True)
7677
pl2_dll_file_path = pl2_dll_folder / 'PL2FileReader.dll'
7778

78-
dist = urlopen('https://github.com/Neuralensemble/pypl2/blob/master/bin/PL2FileReader.dll?raw=true')
79-
with open(pl2_dll_file_path, 'wb') as f:
80-
print(f'Downloading plexon dll to {pl2_dll_file_path}')
81-
f.write(dist.read())
79+
if pl2_dll_file_path.exists():
80+
warnings.warn(f'Using cached plexon dll at {pl2_dll_file_path}')
81+
else:
82+
dist = urlopen('https://github.com/Neuralensemble/pypl2/blob/master/bin/PL2FileReader.dll?raw=true')
83+
with open(pl2_dll_file_path, 'wb') as f:
84+
print(f'Downloading plexon dll to {pl2_dll_file_path}')
85+
f.write(dist.read())
8286

8387
# Instantiate wrapper for Windows DLL
8488
from neo.rawio.plexon2rawio.pypl2.pypl2lib import PyPL2FileReader

0 commit comments

Comments
 (0)