2
2
import shutil
3
3
import subprocess as sp
4
4
from pathlib import Path
5
- import platform
6
5
7
6
from omv .common .inout import inform , trim_path , is_verbose , check_output
8
7
from omv .engines .engine import OMVEngine , EngineExecutionError
9
8
10
9
11
10
class JNeuroMLEngine (OMVEngine ):
12
11
name = "jNeuroML"
12
+ e_name = "jnml"
13
13
14
14
@staticmethod
15
15
def get_environment ():
16
16
if "JNML_HOME" in os .environ :
17
17
jnmlhome = os .environ ["JNML_HOME" ]
18
- elif shutil .which ("jnml" ) is not None :
19
- jnmlhome = Path (shutil .which ("jnml" )).parent
20
- else :
21
- osname = platform .system ()
22
- if osname == "Linux" :
23
- try :
24
- jnmlhome = os .path .join (
25
- os .environ ["XDG_DATA_HOME" ], "jnml/jNeuroMLJar"
26
- )
27
- except KeyError :
28
- localsharepath = os .path .join (os .environ ["HOME" ], ".local/share" )
29
- if os .path .isdir (localsharepath ):
30
- jnmlhome = os .path .join (
31
- os .environ ["HOME" ], ".local/share/jnml/jNeuroMLJar"
32
- )
33
- else :
34
- jnmlhome = os .path .join (os .environ ["HOME" ], "jnml/jNeuroMLJar" )
35
-
36
- elif osname == "Darwin" :
37
- jnmlhome = os .path .join (os .environ ["HOME" ], "Library/jnml/jNeuroMLJar" )
38
- else :
39
- jnmlhome = os .path .join (os .environ ["HOME" ], "jnml/jNeuroMLJar" )
18
+ elif shutil .which (JNeuroMLEngine .e_name ) is not None :
19
+ jnmlhome = Path (shutil .which (JNeuroMLEngine .e_name )).parent
40
20
41
21
environment_vars = {"JNML_HOME" : jnmlhome }
42
22
@@ -46,7 +26,7 @@ def get_environment():
46
26
def get_executable ():
47
27
environment_vars = JNeuroMLEngine .get_environment ()
48
28
jnml = os .path .join (
49
- environment_vars ["JNML_HOME" ], "jnml" if os .name != "nt" else "jnml.bat"
29
+ environment_vars ["JNML_HOME" ], JNeuroMLEngine . e_name if os .name != "nt" else "jnml.bat"
50
30
)
51
31
return jnml
52
32
@@ -59,7 +39,6 @@ def is_installed():
59
39
"Checking whether %s is installed..." % JNeuroMLEngine .name ,
60
40
indent = 1 ,
61
41
)
62
- FNULL = open (os .devnull , "w" )
63
42
jnml = JNeuroMLEngine .get_executable ()
64
43
r = check_output (
65
44
[jnml , "-v" ], verbosity = 2 , env = JNeuroMLEngine .get_environment ()
@@ -76,10 +55,10 @@ def is_installed():
76
55
77
56
@staticmethod
78
57
def install (version ):
79
- from omv .engines .getjnml import install_jnml
58
+ from omv .engines .getpyneuroml import install_pynml
80
59
81
- inform ("Will fetch and install jNeuroML jar " , indent = 2 )
82
- install_jnml (version )
60
+ inform ("Will install PyNeuroML for jnml " , indent = 2 )
61
+ install_pynml (version )
83
62
84
63
if not JNeuroMLEngine .is_installed ():
85
64
inform ("Failure to install, exiting" , indent = 1 )
0 commit comments