Fix for convert_db.py

This commit is contained in:
shrlnm 2022-11-02 11:15:32 +03:00
parent 7b114212e1
commit c570ced440

View File

@ -5,13 +5,13 @@ import os
import pickle import pickle
import sys import sys
import zipfile import zipfile
from io import StringIO from io import BytesIO
import mod_db_manager import mod_db_manager
from mod_optfile import * from mod_optfile import *
if __name__ == "__main__": if __name__ == "__main__":
zipoutput = StringIO () zipoutput = BytesIO ()
if len (sys.argv) < 2: if len (sys.argv) < 2:
print("Usage : convert_db.py [path/to/GenAppli]") print("Usage : convert_db.py [path/to/GenAppli]")
@ -39,35 +39,35 @@ if __name__ == "__main__":
with zipfile.ZipFile (zipoutput, mode='w', compression=zipfile.ZIP_DEFLATED, allowZip64=True) as zf: with zipfile.ZipFile (zipoutput, mode='w', compression=zipfile.ZIP_DEFLATED, allowZip64=True) as zf:
for vf in scnerariosfiles: for vf in scnerariosfiles:
print("Processing file ", vf) print("Processing file ", vf)
f = open (vf, "r") f = open (vf, "rb")
data = f.read () data = f.read ()
zf.writestr (os.path.join ("EcuRenault", "Scenarios", os.path.basename (vf)), str (data)) zf.writestr (os.path.join ("EcuRenault", "Scenarios", os.path.basename (vf)), data)
for vf in vehiclesfiles: for vf in vehiclesfiles:
print("Processing file ", vf) print("Processing file ", vf)
f = open (vf, "r") f = open (vf, "rb")
data = f.read () data = f.read ()
zf.writestr (os.path.join ("Vehicles", os.path.basename (vf)), str (data)) zf.writestr (os.path.join ("Vehicles", os.path.basename (vf)), data)
for vf in dfgfiles: for vf in dfgfiles:
print("Processing file ", vf) print("Processing file ", vf)
f = open(vf, "r") f = open(vf, "rb")
data = f.read() data = f.read()
zf.writestr(os.path.join("Vehicles", "DFG", os.path.basename(vf)), str(data)) zf.writestr(os.path.join("Vehicles", "DFG", os.path.basename(vf)), data)
for vf in ecufiles: for vf in ecufiles:
vf = vf[:-4] + vf[-4:].lower() vf = vf[:-4] + vf[-4:].lower()
print("Processing file ", vf) print("Processing file ", vf)
f = open (vf, "r") f = open (vf, "rb")
data = f.read () data = f.read ()
zf.writestr (os.path.join ("EcuRenault", os.path.basename (vf)), str (data)) zf.writestr (os.path.join ("EcuRenault", os.path.basename (vf)), data)
for vf in fbsessionfiles: for vf in fbsessionfiles:
vf = vf[:-4] + vf[-4:].lower() vf = vf[:-4] + vf[-4:].lower()
print("Processing file ", vf) print("Processing file ", vf)
f = open (vf, "r") f = open (vf, "r")
data = f.read () data = f.read ()
zf.writestr (os.path.join ("EcuRenault", "Sessions", os.path.basename (vf)), str (data)) zf.writestr (os.path.join ("EcuRenault", "Sessions", os.path.basename (vf)), data)
for vf in locationsfiles: for vf in locationsfiles:
print("Processing file ", vf) print("Processing file ", vf)