Skip to content

Commit

Permalink
use display msg param in msx.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mariosmsk committed May 11, 2024
1 parent 37e86e6 commit fa1bbfa
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion epyt/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
__author__ = """Marios S. Kyriakou"""
__email__ = "[email protected]"
__version__ = "1.1.4"
__version__ = "1.1.5"
__msxversion__ = "2.0.0"
__copyright__ = """Copyright 2022, KIOS Research and Innovation Center of Excellence (KIOS CoE),
University of Cyprus (www.kios.org.cy)."""
Expand Down
11 changes: 7 additions & 4 deletions epyt/epanet.py
Original file line number Diff line number Diff line change
Expand Up @@ -11207,7 +11207,7 @@ def loadMSXFile(self, msxname, customMSXlib=None, ignore_properties=False):

self.msxname = msxname[:-4] + '_temp.msx'
copyfile(msxname, self.msxname)
self.msx = epanetmsxapi(self.msxname, customMSXlib=customMSXlib)
self.msx = epanetmsxapi(self.msxname, customMSXlib=customMSXlib, display_msg=self.display_msg)

# Message to user if he uses ph with msx
if self.api._ph is not None:
Expand Down Expand Up @@ -15885,7 +15885,8 @@ def ENwriteline(self, line):
class epanetmsxapi:
"""example msx = epanetmsxapi()"""

def __init__(self, msxfile='', loadlib=True, ignore_msxfile=False, customMSXlib=None):
def __init__(self, msxfile='', loadlib=True, ignore_msxfile=False, customMSXlib=None, display_msg=True):
self.display_msg = display_msg
if customMSXlib is not None:
self.MSXLibEPANET = customMSXlib
loadlib = False
Expand Down Expand Up @@ -15924,15 +15925,17 @@ def MSXopen(self, msxfile):
if not os.path.exists(msxfile):
raise FileNotFoundError(f"File not found: {msxfile}")

print("Opening MSX file:", msxfile)
if display_msg:
print("Opening MSX file:", msxfile)
msxbasename = os.path.basename(msxfile)
err = self.msx_lib.MSXopen(c_char_p(msxfile.encode('utf-8')))
if err != 0:
self.MSXerror(err)
if err == 503:
print("Error 503 may indicate a problem with the MSX file or the MSX library.")
else:
print(f"MSX file {msxbasename} loaded successfully.")
if display_msg:
print(f"MSX file {msxbasename} loaded successfully.")

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

0 comments on commit fa1bbfa

Please sign in to comment.