@@ -101,38 +101,6 @@ def wait(self, timeout):
101101 return self .process .wait (timeout = timeout )
102102
103103
104- class OMCSessionHelper :
105- def __init__ (self , omhome : str = None ):
106- self .omhome = None
107-
108- # use the provided path
109- if omhome is not None :
110- self .omhome = omhome
111- return
112-
113- # check the environment variable
114- omhome = os .environ .get ('OPENMODELICAHOME' )
115- if omhome is not None :
116- self .omhome = omhome
117- return
118-
119- # Get the path to the OMC executable, if not installed this will be None
120- path_to_omc = shutil .which ("omc" )
121- if path_to_omc is not None :
122- self .omhome = os .path .dirname (os .path .dirname (path_to_omc ))
123- return
124-
125- raise ValueError ("Cannot find OpenModelica executable, please install from openmodelica.org" )
126-
127- def _get_omc_path (self ):
128- try :
129- return os .path .join (self .omhome , 'bin' , 'omc' )
130- except BaseException :
131- logger .error ("The OpenModelica compiler is missing in the System path (%s), please install it"
132- % os .path .join (self .omhome , 'bin' , 'omc' ))
133- raise
134-
135-
136104class OMCSessionBase (metaclass = abc .ABCMeta ):
137105
138106 def __init__ (self , readonly = False ):
@@ -531,15 +499,16 @@ def getClassNames(self, className=None, recursive=False, qualified=False, sort=F
531499 return value
532500
533501
534- class OMCSessionZMQ (OMCSessionHelper , OMCSessionBase ):
502+ class OMCSessionZMQ (OMCSessionBase ):
535503
536504 def __init__ (self , readonly = False , timeout = 10.00 ,
537505 docker = None , dockerContainer = None , dockerExtraArgs = None , dockerOpenModelicaPath = "omc" ,
538506 dockerNetwork = None , port = None , omhome : str = None ):
539507 if dockerExtraArgs is None :
540508 dockerExtraArgs = []
541509
542- OMCSessionHelper .__init__ (self , omhome = omhome )
510+ self .omhome = self ._get_omhome (omhome = omhome )
511+
543512 OMCSessionBase .__init__ (self , readonly )
544513 # Locating and using the IOR
545514 if sys .platform != 'win32' or docker or dockerContainer :
@@ -569,6 +538,31 @@ def __init__(self, readonly=False, timeout=10.00,
569538 def __del__ (self ):
570539 OMCSessionBase .__del__ (self )
571540
541+ def _get_omhome (self , omhome : str = None ):
542+ # use the provided path
543+ if omhome is not None :
544+ return omhome
545+
546+ # check the environment variable
547+ omhome = os .environ .get ('OPENMODELICAHOME' )
548+ if omhome is not None :
549+ return omhome
550+
551+ # Get the path to the OMC executable, if not installed this will be None
552+ path_to_omc = shutil .which ("omc" )
553+ if path_to_omc is not None :
554+ return os .path .dirname (os .path .dirname (path_to_omc ))
555+
556+ raise ValueError ("Cannot find OpenModelica executable, please install from openmodelica.org" )
557+
558+ def _get_omc_path (self ):
559+ try :
560+ return os .path .join (self .omhome , 'bin' , 'omc' )
561+ except BaseException :
562+ logger .error ("The OpenModelica compiler is missing in the System path (%s), please install it"
563+ % os .path .join (self .omhome , 'bin' , 'omc' ))
564+ raise
565+
572566 def _connect_to_omc (self , timeout ):
573567 self ._omc_zeromq_uri = "file:///" + self ._port_file
574568 # See if the omc server is running
0 commit comments