From e675c469e4939a330c249a7b454808b8890fce0c Mon Sep 17 00:00:00 2001 From: "Marios S. Kyriakou" Date: Tue, 16 Apr 2024 10:28:47 +0300 Subject: [PATCH] update in msx --- epyt/epanet.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/epyt/epanet.py b/epyt/epanet.py index 8bdd69f..76f7eaa 100644 --- a/epyt/epanet.py +++ b/epyt/epanet.py @@ -11163,7 +11163,7 @@ def loadMSXFile(self, msxname): d.loadMSXFile('net2-cl2.msx') """ self.realmsx = msxname - self.msx = epanetmsxapi() + self.msx = epanetmsxapi(ignore_msxfile=True) self.MSXPythonSetup(msxname) def unloadMSX(self): @@ -15654,9 +15654,8 @@ def ENwriteline(self, line): class epanetmsxapi: """example msx = epanetmsxapi()""" - def __init__(self, msxfile='', ignore_msxfile=False): - if not ignore_msxfile: - + def __init__(self, msxfile='', loadlib=True, ignore_msxfile=False): + if loadlib: ops = platform.system().lower() if ops in ["windows"]: self.MSXLibEPANET = resource_filename("epyt", os.path.join("libraries", "win", "epanetmsx.dll")) @@ -15671,6 +15670,7 @@ def __init__(self, msxfile='', ignore_msxfile=False): self.msx_error = self.msx_lib.MSXgeterror self.msx_error.argtypes = [c_int, c_char_p, c_int] + if not ignore_msxfile: if not os.path.exists(msxfile): raise FileNotFoundError(f"File not found: {msxfile}") @@ -15690,7 +15690,7 @@ def MSXopen(self, msxfile): if not os.path.exists(msxfile): raise FileNotFoundError(f"File not found: {msxfile}") - msxfile = c_char_p(msxfile.encode('utf-8')) + msxfile = bytes(msxfile, 'utf-8') err = self.msx_lib.MSXopen(msxfile) if err != 0: self.MSXerror(err)