From 11cfdb4002555e2977e3793b88eee8796331c0bf Mon Sep 17 00:00:00 2001 From: shrlnm Date: Sun, 16 Feb 2020 22:54:56 +0300 Subject: [PATCH] some fixes with encoding and DB --- .idea/vcs.xml | 6 ++++++ pyren/mod_db_manager.py | 11 ++++++++++- pyren/scen_ecri_calinj1.py | 3 ++- pyren/scen_ecri_paraminj1.py | 19 ++++++++++--------- pyren/scen_ecri_paraminj2.py | 15 ++++++++------- 5 files changed, 36 insertions(+), 18 deletions(-) create mode 100644 .idea/vcs.xml diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/pyren/mod_db_manager.py b/pyren/mod_db_manager.py index 1442470..676c02a 100644 --- a/pyren/mod_db_manager.py +++ b/pyren/mod_db_manager.py @@ -151,7 +151,16 @@ def get_file_from_clip( filename ): if mod_globals.clip_arc=='': return open(os.path.join(mod_globals.cliproot, filename), mode) else: - return mod_globals.clip_arc.open(filename, mode) + if filename.startswith('../'): + filename = filename[3:] + try: + f = mod_globals.clip_arc.open(filename, mode) + return f + except: + fn = filename.split('/')[-1] + lfn = fn.lower() + filename = filename.replace(fn,lfn) + return mod_globals.clip_arc.open(filename, mode) def file_in_clip( pattern ): if mod_globals.clip_arc=='': diff --git a/pyren/scen_ecri_calinj1.py b/pyren/scen_ecri_calinj1.py index f56b0e6..621a2ab 100755 --- a/pyren/scen_ecri_calinj1.py +++ b/pyren/scen_ecri_calinj1.py @@ -18,6 +18,7 @@ import string import mod_globals import mod_utils import mod_ecu +import mod_db_manager from mod_utils import pyren_encode from mod_utils import clearScreen from mod_utils import ASCIITOHEX @@ -59,7 +60,7 @@ def run( elm, ecu, command, data ): # # Data file parsing # - DOMTree = xml.dom.minidom.parse(data) + DOMTree = xml.dom.minidom.parse(mod_db_manager.get_file_from_clip(data)) ScmRoom = DOMTree.documentElement ScmParams = ScmRoom.getElementsByTagName("ScmParam") diff --git a/pyren/scen_ecri_paraminj1.py b/pyren/scen_ecri_paraminj1.py index 0e026f4..5b40612 100644 --- a/pyren/scen_ecri_paraminj1.py +++ b/pyren/scen_ecri_paraminj1.py @@ -18,6 +18,7 @@ import string import mod_globals import mod_utils import mod_ecu +import mod_db_manager from mod_utils import pyren_encode from mod_utils import clearScreen from mod_utils import ASCIITOHEX @@ -76,10 +77,10 @@ def run( elm, ecu, command, data ): # # Data file parsing # - DOMTree = xml.dom.minidom.parse(data) + DOMTree = xml.dom.minidom.parse(mod_db_manager.get_file_from_clip(data)) ScmRoom = DOMTree.documentElement - root = et.parse(data).getroot() + root = et.parse(mod_db_manager.get_file_from_clip(data)).getroot() ScmParams = ScmRoom.getElementsByTagName("ScmParam") @@ -308,22 +309,22 @@ def run( elm, ecu, command, data ): print '*'*80 print get_message("MessageBox2") print - ch = raw_input(confirm + ' : ') + ch = raw_input(pyren_encode(confirm + ' : ')) if ch.upper()!='YES': return - mileage = raw_input(mileageText + ' (' + mileageUnit + ')' + ': ') + mileage = raw_input(pyren_encode(mileageText + ' (' + mileageUnit + ')' + ': ')) while not (mileage.isdigit() and 2 <= len(mileage) <= 6 and int(mileage) >= 10): print get_message("MessageBox1") print - mileage = raw_input(mileageText + ' (' + mileageUnit + ')' + ': ') + mileage = raw_input(pyren_encode(mileageText + ' (' + mileageUnit + ')' + ': ')) clearScreen() print mileageText + ': ' + mileage + ' ' + mileageUnit print - ch = raw_input(confirm + ' : ') + ch = raw_input(pyren_encode(confirm + ' : ')) while (ch.upper()!='YES') and (ch.upper()!='NO'): - ch = raw_input(confirm + ' : ') + ch = raw_input(pyren_encode(confirm + ' : ')) if ch.upper()!='YES': return @@ -452,9 +453,9 @@ def run( elm, ecu, command, data ): print get_message_by_id('55663') print '*'*80 print - ch = raw_input(confirm + ' : ') + ch = raw_input(pyren_encode(confirm + ' : ')) while (ch.upper()!='YES') and (ch.upper()!='NO'): - ch = raw_input(confirm + ' : ') + ch = raw_input(pyren_encode(confirm + ' : ')) if ch.upper()!='YES': return diff --git a/pyren/scen_ecri_paraminj2.py b/pyren/scen_ecri_paraminj2.py index a8f9058..7c96c4f 100644 --- a/pyren/scen_ecri_paraminj2.py +++ b/pyren/scen_ecri_paraminj2.py @@ -18,6 +18,7 @@ import string import mod_globals import mod_utils import mod_ecu +import mod_db_manager from mod_utils import pyren_encode from mod_utils import clearScreen from mod_utils import ASCIITOHEX @@ -75,10 +76,10 @@ def run( elm, ecu, command, data ): # # Data file parsing # - DOMTree = xml.dom.minidom.parse(data) + DOMTree = xml.dom.minidom.parse(mod_db_manager.get_file_from_clip(data)) ScmRoom = DOMTree.documentElement - root = et.parse(data).getroot() + root = et.parse(mod_db_manager.get_file_from_clip(data)).getroot() ScmParams = ScmRoom.getElementsByTagName("ScmParam") @@ -253,20 +254,20 @@ def run( elm, ecu, command, data ): print '*'*80 print get_message("MessageBox2") print - ch = raw_input(confirm + ' : ') + ch = raw_input(pyren_encode(confirm + ' : ')) if ch.upper()!='YES': return - mileage = raw_input(mileageText + ' (' + mileageUnit + ')' + ': ') + mileage = raw_input(pyren_encode(mileageText + ' (' + mileageUnit + ')' + ': ')) while not (mileage.isdigit() and 2 <= len(mileage) <= 6 and int(mileage) >= 10): print get_message("MessageBox1") print - mileage = raw_input(mileageText + ' (' + mileageUnit + ')' + ': ') + mileage = raw_input(pyren_encode(mileageText + ' (' + mileageUnit + ')' + ': ')) clearScreen() print mileageText + ': ' + mileage + ' ' + mileageUnit print - ch = raw_input(confirm + ' : ') + ch = raw_input(pyren_encode(confirm + ' : ')) while (ch.upper()!='YES') and (ch.upper()!='NO'): ch = raw_input(confirm + ' : ') if ch.upper()!='YES': @@ -393,7 +394,7 @@ def run( elm, ecu, command, data ): print get_message_by_id('55663') print '*'*80 print - ch = raw_input(confirm + ' : ') + ch = raw_input(pyren_encode(confirm + ' : ')) while (ch.upper()!='YES') and (ch.upper()!='NO'): ch = raw_input(confirm + ' : ') if ch.upper()!='YES':