9q fix mod_term
This commit is contained in:
parent
34885b3547
commit
2e6df9c891
@ -116,6 +116,7 @@ from mod_elm import ELM
|
||||
from mod_scan_ecus import ScanEcus
|
||||
from mod_utils import *
|
||||
from mod_mtc import acf_getMTC
|
||||
from mod_mtc import acf_buildFull
|
||||
|
||||
#global variables
|
||||
|
||||
@ -634,6 +635,7 @@ def generateHTML(path, mtc, vin, dfg, date_madc ):
|
||||
print '\r\tDone:100%'
|
||||
|
||||
vin_opt = ''
|
||||
allvin = ''
|
||||
|
||||
def optParser():
|
||||
'''Parsing of command line parameters. User should define at least com port name'''
|
||||
@ -641,6 +643,7 @@ def optParser():
|
||||
import argparse
|
||||
|
||||
global vin_opt
|
||||
global allvin
|
||||
|
||||
parser = argparse.ArgumentParser(
|
||||
#usage = "%prog -p <port> [options]",
|
||||
@ -708,6 +711,11 @@ def optParser():
|
||||
default=False,
|
||||
action="store_true")
|
||||
|
||||
parser.add_argument("--allvin",
|
||||
help="generate file with all VIN numbers for platform",
|
||||
dest="allvin",
|
||||
default="")
|
||||
|
||||
options = parser.parse_args()
|
||||
|
||||
#if not options.port and mod_globals.os != 'android':
|
||||
@ -731,6 +739,7 @@ def optParser():
|
||||
mod_globals.opt_cfc0 = options.cfc
|
||||
mod_globals.opt_sd = options.sd
|
||||
vin_opt = options.vinnum
|
||||
allvin = options.allvin
|
||||
|
||||
def main():
|
||||
'''Main function
|
||||
@ -744,12 +753,17 @@ def main():
|
||||
|
||||
global dfg_ds
|
||||
global vin_opt
|
||||
global allvin
|
||||
|
||||
optParser()
|
||||
|
||||
mod_utils.chkDirTree()
|
||||
mod_db_manager.find_DBs()
|
||||
|
||||
if allvin!="":
|
||||
acf_buildFull(allvin)
|
||||
exit()
|
||||
|
||||
'''If MTC database does not exists then demo mode'''
|
||||
if not os.path.exists('../BVMEXTRACTION'):
|
||||
mod_globals.opt_demo = True
|
||||
|
@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import sys
|
||||
import csv
|
||||
import os
|
||||
import mod_globals
|
||||
import mod_elm
|
||||
@ -57,7 +57,67 @@ def acf_loadMTCfromFile( folder ):
|
||||
mtcdata = ';'.join(sorted(tmp.split('\n')))
|
||||
|
||||
return vindata, mtcdata, refdata, platform
|
||||
|
||||
|
||||
def acf_buildFull( platf ):
|
||||
'''compile all VINs in one file'''
|
||||
|
||||
plDIR = "../BVMEXTRACTION/"+platf.upper()
|
||||
|
||||
if not os.path.exists(plDIR):
|
||||
print "ERROR: Can't find the BVMEXTRACTION db"
|
||||
return
|
||||
|
||||
mtc = {}
|
||||
mtcf = open(plDIR+'/MTC.dat', 'rb')
|
||||
mtc_list = csv.reader(mtcf, delimiter=';')
|
||||
for i in mtc_list:
|
||||
mtc[int(i[0][:-4])] = i[1:]
|
||||
|
||||
ref = {}
|
||||
reff = open(plDIR+'/REF.dat', 'rb')
|
||||
ref_list = csv.reader(reff, delimiter=';')
|
||||
for i in ref_list:
|
||||
ref[int(i[0][:10])] = [i[0][11:]] + i[1:]
|
||||
|
||||
all_vin = open(plDIR+'/all_vin.csv', 'w')
|
||||
|
||||
for root, dirs, files in os.walk(plDIR):
|
||||
for dir in dirs:
|
||||
if len(dir)!=3:
|
||||
continue
|
||||
VIN1 = dir
|
||||
cdir = os.path.join(plDIR, dir)
|
||||
print cdir
|
||||
for root, dirs, files in os.walk(cdir):
|
||||
for file in files:
|
||||
zfname = file.split('.')[0]
|
||||
if len(zfname)==6:
|
||||
if not file.lower().endswith('.dat'):
|
||||
continue
|
||||
zip=zipfile.ZipFile(os.path.join(root, file))
|
||||
flist = zip.namelist()
|
||||
for i in flist:
|
||||
VIN2 = i.split('.')[0]
|
||||
print ' '+VIN2
|
||||
zf=zip.open(i)
|
||||
vin3list=zf.read()
|
||||
zf.close()
|
||||
for l in vin3list.split('\n'):
|
||||
l = l.strip()
|
||||
if len(l)==0:
|
||||
continue
|
||||
vr = l.split(';')
|
||||
VIN = VIN1 + VIN2 + vr[0]
|
||||
try:
|
||||
d = vr[4].split(':')[1].split('.')
|
||||
data = d[2] + d[1] + d[0]
|
||||
except:
|
||||
pass
|
||||
outl = data+'#'+VIN+'#'+' '.join(vr[1:])+'#'+' '.join(mtc[int(vr[1])])+'#'+'_'.join(ref[int(vr[2])])
|
||||
all_vin.write(outl+'\n')
|
||||
all_vin.close()
|
||||
print "\n\n File: "+plDIR+"/all_vin.csv is build\n\n"
|
||||
|
||||
def acf_getMTC( VIN, preferFile=False ):
|
||||
''' getting MTC data from BVMEXTRACTION'''
|
||||
|
||||
|
@ -178,7 +178,7 @@ def optParser():
|
||||
|
||||
parser = argparse.ArgumentParser(
|
||||
#usage = "%prog -p <port> [options]",
|
||||
version="pyRen terminal Version 0.9.k",
|
||||
version="pyRen terminal Version 0.9.q",
|
||||
description = "pyRen terminal"
|
||||
)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user