some fixes with encoding and DB

This commit is contained in:
shrlnm 2020-02-16 22:54:56 +03:00
parent 253b597b96
commit 11cfdb4002
5 changed files with 36 additions and 18 deletions

6
.idea/vcs.xml generated Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

View File

@ -151,6 +151,15 @@ def get_file_from_clip( filename ):
if mod_globals.clip_arc=='':
return open(os.path.join(mod_globals.cliproot, filename), mode)
else:
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 ):

View File

@ -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")

View File

@ -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 + ' <YES/NO>: ')
ch = raw_input(pyren_encode(confirm + ' <YES/NO>: '))
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 + ' <YES/NO>: ')
ch = raw_input(pyren_encode(confirm + ' <YES/NO>: '))
while (ch.upper()!='YES') and (ch.upper()!='NO'):
ch = raw_input(confirm + ' <YES/NO>: ')
ch = raw_input(pyren_encode(confirm + ' <YES/NO>: '))
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 + ' <YES/NO>: ')
ch = raw_input(pyren_encode(confirm + ' <YES/NO>: '))
while (ch.upper()!='YES') and (ch.upper()!='NO'):
ch = raw_input(confirm + ' <YES/NO>: ')
ch = raw_input(pyren_encode(confirm + ' <YES/NO>: '))
if ch.upper()!='YES':
return

View File

@ -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 + ' <YES/NO>: ')
ch = raw_input(pyren_encode(confirm + ' <YES/NO>: '))
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 + ' <YES/NO>: ')
ch = raw_input(pyren_encode(confirm + ' <YES/NO>: '))
while (ch.upper()!='YES') and (ch.upper()!='NO'):
ch = raw_input(confirm + ' <YES/NO>: ')
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 + ' <YES/NO>: ')
ch = raw_input(pyren_encode(confirm + ' <YES/NO>: '))
while (ch.upper()!='YES') and (ch.upper()!='NO'):
ch = raw_input(confirm + ' <YES/NO>: ')
if ch.upper()!='YES':