Skip to content

Commit

Permalink
update message for msx.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mariosmsk committed Jun 23, 2024
1 parent 4f4d1dc commit 7146487
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions epyt/epanet.py
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,7 @@ def __init__(self, *argv, version=2.2, ph=False, loadfile=False, customlib=None,
warnings.simplefilter('always')
# Demand model types. DDA #0 Demand driven analysis,
# PDA #1 Pressure driven analysis.
self.customlib = customlib
self.MSXFile = None
self.MSXTempFile = None
self.DEMANDMODEL = ['DDA', 'PDA']
Expand Down Expand Up @@ -576,7 +577,7 @@ def __init__(self, *argv, version=2.2, ph=False, loadfile=False, customlib=None,
self.classversion = __version__
self.api = epanetapi(version, ph=ph, customlib=customlib)
self.display_msg = display_msg
if self.display_msg:
if self.display_msg and self.customlib is None:
print(f'EPANET version {self.getVersion()} '
f'loaded (EPyT version {self.classversion}).')

Expand Down Expand Up @@ -16173,10 +16174,10 @@ class epanetmsxapi:

def __init__(self, msxfile='', loadlib=True, ignore_msxfile=False, customMSXlib=None, display_msg=True, msxrealfile = ''):
self.display_msg = display_msg
self.customMSXlib = customMSXlib
if customMSXlib is not None:
self.MSXLibEPANET = customMSXlib
loadlib = False

self.msx_lib = cdll.LoadLibrary(self.MSXLibEPANET)
self.MSXLibEPANETPath = os.path.dirname(self.MSXLibEPANET)
self.msx_error = self.msx_lib.MSXgeterror
Expand Down Expand Up @@ -16212,7 +16213,10 @@ def MSXopen(self, msxfile, msxrealfile):
raise FileNotFoundError(f"File not found: ")

if self.display_msg:
print(f"Opening MSX file:{msxrealfile}.msx")
msxname = os.path.basename(msxrealfile)
if self.customMSXlib is None:
print(f"EPANET-MSX version {__msxversion__} loaded.")

msxbasename = os.path.basename(msxfile)
err = self.msx_lib.MSXopen(c_char_p(msxfile.encode('utf-8')))
if err != 0:
Expand All @@ -16221,7 +16225,7 @@ def MSXopen(self, msxfile, msxrealfile):
print("Error 503 may indicate a problem with the MSX file or the MSX library.")
else:
if self.display_msg:
print(f"MSX file {msxrealfile}.msx loaded successfully.")
print(f"MSX file {msxname}.msx loaded successfully.")

def MSXclose(self):
""" Close .msx file
Expand Down

0 comments on commit 7146487

Please sign in to comment.