Dump output as binary
This commit is contained in:
@@ -8,12 +8,16 @@ sys.path.append("..")
|
||||
from api import project
|
||||
from api import inp_out
|
||||
|
||||
|
||||
'''
|
||||
def _verify_platform():
|
||||
_platform = platform.system()
|
||||
if _platform != "Windows":
|
||||
raise Exception(f'Platform {_platform} unsupported (not yet)')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
_verify_platform()
|
||||
|
||||
|
||||
class Output:
|
||||
def __init__(self, path: str) -> None:
|
||||
@@ -210,10 +214,6 @@ class Output:
|
||||
return data
|
||||
|
||||
|
||||
def dump_report(path: str) -> str:
|
||||
return open(path, mode='r').read()
|
||||
|
||||
|
||||
def _dump_output(path: str) -> dict[str, Any]:
|
||||
opt = Output(path)
|
||||
data = opt.dump()
|
||||
@@ -225,6 +225,14 @@ def _dump_output(path: str) -> dict[str, Any]:
|
||||
def dump_output(path: str) -> str:
|
||||
data = _dump_output(path)
|
||||
return json.dumps(data)
|
||||
'''
|
||||
|
||||
def dump_report(path: str) -> str:
|
||||
return open(path, 'r').read()
|
||||
|
||||
|
||||
def dump_output_binary(path: str) -> str:
|
||||
return open(path, 'rb').read()
|
||||
|
||||
|
||||
def run_project(name: str) -> str:
|
||||
@@ -250,7 +258,8 @@ def run_project(name: str) -> str:
|
||||
data['simulation_result'] = 'failed'
|
||||
else:
|
||||
data['simulation_result'] = 'successful'
|
||||
data |= _dump_output(opt)
|
||||
# data |= _dump_output(opt)
|
||||
data['output'] = dump_output_binary(opt)
|
||||
|
||||
data['report'] = dump_report(rpt)
|
||||
|
||||
@@ -273,12 +282,9 @@ def run_inp(name: str) -> str:
|
||||
data['simulation_result'] = 'failed'
|
||||
else:
|
||||
data['simulation_result'] = 'successful'
|
||||
data |= _dump_output(opt)
|
||||
# data |= _dump_output(opt)
|
||||
data['output'] = dump_output_binary(opt)
|
||||
|
||||
data['report'] = dump_report(rpt)
|
||||
|
||||
return json.dumps(data)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
_verify_platform()
|
||||
|
||||
Reference in New Issue
Block a user