Skip to content

Commit

Permalink
Update epanet.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Mariosmsk committed Mar 24, 2024
1 parent 53862f4 commit 46e0f14
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions epyt/epanet.py
Original file line number Diff line number Diff line change
Expand Up @@ -15654,7 +15654,7 @@ def ENwriteline(self, line):
class epanetmsxapi:
"""example msx = epanetmsxapi()"""

def __init__(self, filename=None):
def __init__(self, filename=''):
ops = platform.system().lower()
if ops in ["windows"]:
self.MSXLibEPANET = resource_filename("epyt", os.path.join("libraries", "win", "epanetmsx.dll"))
Expand All @@ -15666,25 +15666,21 @@ def __init__(self, filename=None):
self.msx_lib = cdll.LoadLibrary(self.MSXLibEPANET)
self.MSXLibEPANETPath = os.path.dirname(self.MSXLibEPANET)

# Error ~ function
self.msx_error = self.msx_lib.MSXgeterror
self.msx_error.argtypes = [c_int, c_char_p, c_int]

# msx opens starts here
if not os.path.exists(filename):
raise FileNotFoundError(f"File not found: {filename}")

if filename is not None:
print("Opening MSX file:", filename)
filename = c_char_p(filename.encode('utf-8'))
err = self.msx_lib.MSXopen(filename)
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("MSX file opened successfully.")
# msx open ends here
print("Opening MSX file:", filename)
filename = c_char_p(filename.encode('utf-8'))
err = self.msx_lib.MSXopen(filename)
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("MSX file opened successfully.")

def MSXopen(self, filename):
"""
Expand Down

0 comments on commit 46e0f14

Please sign in to comment.