Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Download correct ddl for 64 system on windows with Plexon #1350

Merged
merged 9 commits into from
Dec 6, 2023
22 changes: 17 additions & 5 deletions neo/rawio/plexon2rawio/plexon2rawio.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
"""
import pathlib
import warnings
import platform

from collections import namedtuple
from urllib.request import urlopen
from datetime import datetime
Expand Down Expand Up @@ -74,14 +76,24 @@ def __init__(self, filename, pl2_dll_file_path=None):

# download default PL2 dll once if not yet available
if pl2_dll_file_path is None:
pl2_dll_folder = pathlib.Path .home() / '.plexon_dlls_for_neo'
architecture = platform.architecture()[0]
if architecture == '64bit':
file_name = "PL2FileReader64.dll"
else:
file_name = "PL2FileReader.dll"

h-mayorquin marked this conversation as resolved.
Show resolved Hide resolved
pl2_dll_folder = pathlib.Path.home() / '.plexon_dlls_for_neo'
pl2_dll_folder.mkdir(exist_ok=True)
pl2_dll_file_path = pl2_dll_folder / 'PL2FileReader.dll'
pl2_dll_file_path = pl2_dll_folder / file_name

if pl2_dll_file_path.exists():
warnings.warn(f'Using cached plexon dll at {pl2_dll_file_path}')
if not pl2_dll_file_path.exists():
h-mayorquin marked this conversation as resolved.
Show resolved Hide resolved
h-mayorquin marked this conversation as resolved.
Show resolved Hide resolved
# I think this warning should be removed
# Warnings should provide a solution but this is just a reminder to the user of normal behavior
# Nothing to do
warnings.warn(f'Using cached plexon dll at {pl2_dll_file_path}')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Super fair point. I don't think this warning is doing anything!

h-mayorquin marked this conversation as resolved.
Show resolved Hide resolved
else:
dist = urlopen('https://raw.githubusercontent.com/Neuralensemble/pypl2/master/bin/PL2FileReader.dll')
dist = urlopen(f'https://raw.githubusercontent.com/Neuralensemble/pypl2/master/bin/{file_name}')

with open(pl2_dll_file_path, 'wb') as f:
print(f'Downloading plexon dll to {pl2_dll_file_path}')
f.write(dist.read())
Expand Down
Loading