From a9613d82f0f5b1cfb84bff9e91de37fc70cb9f91 Mon Sep 17 00:00:00 2001 From: Heberto Mayorquin Date: Mon, 12 Feb 2024 17:41:53 -0600 Subject: [PATCH 1/4] avoid running plexon tests --- .gitignore | 2 ++ neo/rawio/plexon2rawio/pypl2/pypl2lib.py | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 5f70fb3d7..84710b91b 100644 --- a/.gitignore +++ b/.gitignore @@ -15,6 +15,8 @@ .idea *.swp *.swo +.vscode + # Compiled source # ################### diff --git a/neo/rawio/plexon2rawio/pypl2/pypl2lib.py b/neo/rawio/plexon2rawio/pypl2/pypl2lib.py index 59ba26967..45fee8882 100644 --- a/neo/rawio/plexon2rawio/pypl2/pypl2lib.py +++ b/neo/rawio/plexon2rawio/pypl2/pypl2lib.py @@ -9,15 +9,21 @@ # copyright notice is kept intact. from sys import platform -import os +import subprocess import pathlib import warnings if any(platform.startswith(name) for name in ("linux", "darwin", "freebsd")): + try: + result_wine = subprocess.run(["dpkg", "-l", "wine"], stdout=subprocess.PIPE, stderr=subprocess.PIPE, check=True) + except subprocess.CalledProcessError: + raise ImportError("Wine is not installed. Please install wine to use the PL2FileReader.dll") + from zugbruecke import CtypesSession ctypes = CtypesSession(log_level=100) + elif platform.startswith("win"): import ctypes else: From 5c5784bef8becca2abff7d5a45de6aff7bc2bad3 Mon Sep 17 00:00:00 2001 From: Heberto Mayorquin Date: Tue, 13 Feb 2024 13:13:53 -0600 Subject: [PATCH 2/4] fix for mac --- neo/rawio/plexon2rawio/pypl2/pypl2lib.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/neo/rawio/plexon2rawio/pypl2/pypl2lib.py b/neo/rawio/plexon2rawio/pypl2/pypl2lib.py index 45fee8882..be071d931 100644 --- a/neo/rawio/plexon2rawio/pypl2/pypl2lib.py +++ b/neo/rawio/plexon2rawio/pypl2/pypl2lib.py @@ -12,10 +12,18 @@ import subprocess import pathlib import warnings +import numpy as np + +plataform_is_windows = platform.system() == "Windows" + +if plataform_is_windows: + import ctypes +else: -if any(platform.startswith(name) for name in ("linux", "darwin", "freebsd")): try: - result_wine = subprocess.run(["dpkg", "-l", "wine"], stdout=subprocess.PIPE, stderr=subprocess.PIPE, check=True) + is_wine_available = subprocess.run( + ["wine", "--version"], stdout=subprocess.PIPE, stderr=subprocess.PIPE, check=False + ) except subprocess.CalledProcessError: raise ImportError("Wine is not installed. Please install wine to use the PL2FileReader.dll") @@ -24,14 +32,6 @@ ctypes = CtypesSession(log_level=100) -elif platform.startswith("win"): - import ctypes -else: - raise SystemError("unsupported platform") - -import numpy as np - - class tm(ctypes.Structure): _fields_ = [ ("tm_sec", ctypes.c_int), From 60a66049d2ebf67145bc8e81c94c41016a66ded7 Mon Sep 17 00:00:00 2001 From: Heberto Mayorquin Date: Tue, 13 Feb 2024 13:41:57 -0600 Subject: [PATCH 3/4] restrict to linux --- neo/rawio/plexon2rawio/pypl2/pypl2lib.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/neo/rawio/plexon2rawio/pypl2/pypl2lib.py b/neo/rawio/plexon2rawio/pypl2/pypl2lib.py index be071d931..c561fa781 100644 --- a/neo/rawio/plexon2rawio/pypl2/pypl2lib.py +++ b/neo/rawio/plexon2rawio/pypl2/pypl2lib.py @@ -19,13 +19,14 @@ if plataform_is_windows: import ctypes else: - - try: - is_wine_available = subprocess.run( - ["wine", "--version"], stdout=subprocess.PIPE, stderr=subprocess.PIPE, check=False - ) - except subprocess.CalledProcessError: - raise ImportError("Wine is not installed. Please install wine to use the PL2FileReader.dll") + pltaform_is_linux = platform.system() == "Linux" + if pltaform_is_linux: + try: + is_wine_available = subprocess.run( + ["wine", "--version"], stdout=subprocess.PIPE, stderr=subprocess.PIPE, check=False + ) + except subprocess.CalledProcessError: + raise ImportError("Wine is not installed. Please install wine to use the PL2FileReader.dll") from zugbruecke import CtypesSession From cf651e1169abcd743d7047050daae471a08cc0e6 Mon Sep 17 00:00:00 2001 From: zm711 <92116279+zm711@users.noreply.github.com> Date: Tue, 13 Feb 2024 14:51:15 -0500 Subject: [PATCH 4/4] switch strategy --- neo/rawio/plexon2rawio/pypl2/pypl2lib.py | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/neo/rawio/plexon2rawio/pypl2/pypl2lib.py b/neo/rawio/plexon2rawio/pypl2/pypl2lib.py index c561fa781..ae35aac7c 100644 --- a/neo/rawio/plexon2rawio/pypl2/pypl2lib.py +++ b/neo/rawio/plexon2rawio/pypl2/pypl2lib.py @@ -8,25 +8,22 @@ # You are free to modify or share this file, provided that the above # copyright notice is kept intact. -from sys import platform +import platform import subprocess import pathlib import warnings import numpy as np -plataform_is_windows = platform.system() == "Windows" +platform_is_windows = platform.system() == "Windows" -if plataform_is_windows: +if platform_is_windows: import ctypes else: - pltaform_is_linux = platform.system() == "Linux" - if pltaform_is_linux: - try: - is_wine_available = subprocess.run( - ["wine", "--version"], stdout=subprocess.PIPE, stderr=subprocess.PIPE, check=False + is_wine_available = subprocess.run( + ["which", "wine"], stdout=subprocess.PIPE, stderr=subprocess.PIPE, check=False ) - except subprocess.CalledProcessError: - raise ImportError("Wine is not installed. Please install wine to use the PL2FileReader.dll") + if is_wine_available.returncode != 0: + raise ImportError("Wine is not installed. Please install wine to use the PL2FileReader.dll") from zugbruecke import CtypesSession