Support run epa3
This commit is contained in:
@@ -284,12 +284,14 @@ def read_inp(project: str, inp: str, version: str = '3') -> bool:
|
||||
create_project(project)
|
||||
open_project(project)
|
||||
|
||||
try:
|
||||
parse_file(project, inp, version)
|
||||
|
||||
'''try:
|
||||
parse_file(project, inp, version)
|
||||
except:
|
||||
close_project(project)
|
||||
delete_project(project)
|
||||
return False
|
||||
return False'''
|
||||
|
||||
close_project(project)
|
||||
return True
|
||||
|
||||
@@ -227,17 +227,21 @@ def dump_output(path: str) -> str:
|
||||
return json.dumps(data)
|
||||
|
||||
|
||||
def run_project(name: str) -> str:
|
||||
def run_project(name: str, version: str = '3') -> str:
|
||||
if version != '3' and version != '2':
|
||||
version = '2'
|
||||
|
||||
if not project.have_project(name):
|
||||
raise Exception(f'Not found project [{name}]')
|
||||
|
||||
dir = os.path.abspath(os.getcwd())
|
||||
|
||||
db_inp = os.path.join(os.path.join(dir, 'db_inp'), name + '.db.inp')
|
||||
inp_out.dump_inp(name, db_inp)
|
||||
inp_out.dump_inp(name, db_inp, version)
|
||||
|
||||
input = name + '.db'
|
||||
exe = os.path.join(os.path.join(dir, 'epanet'), 'runepanet.exe')
|
||||
program = 'runepanet.exe' if version == '2' else 'run-epanet3.exe'
|
||||
exe = os.path.join(os.path.join(dir, 'epanet'), program)
|
||||
inp = os.path.join(os.path.join(dir, 'db_inp'), input + '.inp')
|
||||
rpt = os.path.join(os.path.join(dir, 'temp'), input + '.rpt')
|
||||
opt = os.path.join(os.path.join(dir, 'temp'), input + '.opt')
|
||||
|
||||
@@ -197,8 +197,8 @@ def import_inp(name: str, cs: ChangeSet, version: str = '3') -> bool:
|
||||
def export_inp(name: str, version: str = '3') -> ChangeSet:
|
||||
return api.export_inp(name, version)
|
||||
|
||||
def run_project(name: str) -> str:
|
||||
return epanet.run_project(name)
|
||||
def run_project(name: str, version: str = '3') -> str:
|
||||
return epanet.run_project(name, version)
|
||||
|
||||
# put in inp folder, name without extension
|
||||
def run_inp(name: str) -> str:
|
||||
|
||||
Reference in New Issue
Block a user