9p doc improvements
This commit is contained in:
parent
0b71166a9e
commit
2b44dba967
@ -29,6 +29,7 @@ if __name__ == "__main__":
|
||||
fbsessionfiles += glob.glob (os.path.join (ecudir, "Sessions", "FG*.xml"))
|
||||
fgsessionfiles = glob.glob (os.path.join (ecudir, "Sessions", "SG*.xml"))
|
||||
vehiclesfiles = glob.glob (os.path.join (vehicledir, "*.xml"))
|
||||
dfgfiles = glob.glob (os.path.join (vehicledir, "DFG", "*.xml"))
|
||||
locationsfiles = glob.glob (os.path.join (locationdir, "*.bqm"))
|
||||
scnerariosfiles = glob.glob (os.path.join (ecudir, "Scenarios", "*.xml"))
|
||||
|
||||
@ -45,6 +46,12 @@ if __name__ == "__main__":
|
||||
data = f.read ()
|
||||
zf.writestr (os.path.join ("Vehicles", os.path.basename (vf)), str (data))
|
||||
|
||||
for vf in dfgfiles:
|
||||
print "Processing file ", vf
|
||||
f = open(vf, "r")
|
||||
data = f.read()
|
||||
zf.writestr(os.path.join("Vehicles", "DFG", os.path.basename(vf)), str(data))
|
||||
|
||||
for vf in ecufiles:
|
||||
print "Processing file ", vf
|
||||
f = open (vf, "r")
|
||||
|
@ -388,9 +388,16 @@ def processXML( path, l, ff ):
|
||||
#ma = acf_MTC_compare_doc( sieconfigid, mtc )
|
||||
#if ma: #document complines to MTC filter
|
||||
|
||||
title = root.find('title').text.strip()
|
||||
if title=='': #check id documents refers to another
|
||||
root,title = getTitleAndRef( path, ff, root, title, l )
|
||||
try:
|
||||
title = root.find('title').text.strip()
|
||||
except:
|
||||
title = ''
|
||||
|
||||
try:
|
||||
if title=='': #check id documents refers to another
|
||||
root,title = getTitleAndRef( path, ff, root, title, l )
|
||||
except:
|
||||
pass
|
||||
|
||||
lid = l[:-4]
|
||||
|
||||
@ -401,12 +408,22 @@ def processXML( path, l, ff ):
|
||||
if fns[4]!='000000':
|
||||
title = 'DTC'+fns[4]+' '+title
|
||||
|
||||
dtcId = ''
|
||||
if fns[4]!='000000' and fns[5]=='104':
|
||||
dtcId = fns[4]
|
||||
|
||||
#add line to bookmark
|
||||
#cop = et.SubElement(h_o, 'p')
|
||||
#coa = et.SubElement(cop, 'a', href='#'+l[:-4]).text = title
|
||||
|
||||
nel = et.Element('div')
|
||||
et.SubElement(nel, 'hr', attrib={'id':lid})
|
||||
et.SubElement(nel, 'a', attrib={'href':'#home'}).text = "Up"
|
||||
|
||||
if dtcId!='':
|
||||
et.SubElement(nel, 'a', attrib={'href':'#home','id':dtcId}).text = "Up"
|
||||
else:
|
||||
et.SubElement(nel, 'a', attrib={'href':'#home'}).text = "Up"
|
||||
|
||||
convertXML( root, nel, fns, ff, lid )
|
||||
|
||||
return nel, lid, title
|
||||
@ -480,6 +497,7 @@ def f_functions( dfg_dom, ff, of, pref, domname, path ):
|
||||
of.remove( l )
|
||||
cop = et.SubElement(dom_dtc_o, 'p')
|
||||
et.SubElement(cop, 'a', href='#'+lid).text = title
|
||||
print lid,';',title
|
||||
dom_t.append(nel)
|
||||
|
||||
cop = et.SubElement(dom_o, 'p')
|
||||
@ -604,7 +622,7 @@ def generateHTML(path, mtc, vin, dfg, date_madc ):
|
||||
h_o.append(oth_o)
|
||||
|
||||
tree = et.ElementTree(doc)
|
||||
tree.write('./'+vin+'.htm', encoding='UTF-8', xml_declaration=True, default_namespace=None, method='html')
|
||||
tree.write('./doc/'+vin+'.htm', encoding='UTF-8', xml_declaration=True, default_namespace=None, method='html')
|
||||
print '\r\tDone:100%'
|
||||
|
||||
vin_opt = ''
|
||||
|
@ -284,17 +284,6 @@ class DDTECU():
|
||||
|
||||
eculist = mod_ddt_utils.loadECUlist()
|
||||
|
||||
##make or load eculist
|
||||
#print "Loading eculist"
|
||||
#eculistcache = "./cache/ddt_eculist.p"
|
||||
#
|
||||
#if os.path.isfile(eculistcache): #if cache exists
|
||||
# eculist = pickle.load( open( eculistcache, "rb" ) ) #load it
|
||||
#else: #else
|
||||
# eculist = mod_ddt_utils.loadECUlist() #loading original data
|
||||
# if eculist == None: return #return if no eculist file
|
||||
# pickle.dump( eculist, open( eculistcache, "wb" ) ) #and save cache
|
||||
|
||||
mod_ddt_utils.searchddtroot()
|
||||
|
||||
if len(mod_globals.opt_ddtxml)>0:
|
||||
@ -363,62 +352,6 @@ class DDTECU():
|
||||
if di.Name not in self.cmd4data.keys():
|
||||
self.cmd4data[di.Name] = r.Name
|
||||
|
||||
'''
|
||||
def loadECUlist(self):
|
||||
|
||||
global eculist
|
||||
|
||||
#open xml
|
||||
if not os.path.isfile('../ecus/eculist.xml'):
|
||||
print "No such file: ../ecus/eculist.xml"
|
||||
return None
|
||||
|
||||
ns = {'ns0': 'http://www-diag.renault.com/2002/ECU',
|
||||
'ns1': 'http://www-diag.renault.com/2002/screens'}
|
||||
|
||||
tree = et.parse ('../ecus/eculist.xml')
|
||||
root = tree.getroot ()
|
||||
|
||||
eculist = {}
|
||||
#print et.dump(root)
|
||||
functions = root.findall("Function")
|
||||
if len(functions):
|
||||
for function in functions:
|
||||
Address = hex(int(function.attrib["Address"])).replace("0x","").zfill(2).upper()
|
||||
eculist[Address] = {}
|
||||
FuncName = function.attrib["Name"]
|
||||
targets = function.findall("Target")
|
||||
eculist[Address]["FuncName"] = FuncName
|
||||
eculist[Address]["targets"] = {}
|
||||
if len(targets):
|
||||
for target in targets:
|
||||
href = target.attrib["href"]
|
||||
eculist[Address]["targets"][href] = {}
|
||||
pjc = target.findall("Projects")
|
||||
if len(pjc)>0:
|
||||
pjcl = [elem.tag.upper() for elem in pjc[0].iter()][1:]
|
||||
else:
|
||||
pjcl = []
|
||||
eculist[Address]["targets"][href]['Projects'] = pjcl
|
||||
ail = []
|
||||
ais = target.findall("AutoIdents")
|
||||
if len(ais):
|
||||
for ai in ais:
|
||||
AutoIdents = ai.findall("AutoIdent")
|
||||
if len(AutoIdents):
|
||||
for AutoIdent in AutoIdents:
|
||||
air = {}
|
||||
air['DiagVersion'] = AutoIdent.attrib["DiagVersion"].strip()
|
||||
air['Supplier'] = AutoIdent.attrib["Supplier"].strip()
|
||||
air['Soft'] = AutoIdent.attrib["Soft"].strip()
|
||||
air['Version'] = AutoIdent.attrib["Version"].strip()
|
||||
#if len(DiagVersion)==1 : DiagVersion = '0'+DiagVersion
|
||||
#hash = Address+DiagVersion+Supplier+Soft+Version
|
||||
#eculist[hash] = href
|
||||
ail.append(air)
|
||||
eculist[Address]["targets"][href]['AutoIdents'] = ail
|
||||
'''
|
||||
|
||||
def saveDump( self ):
|
||||
''' save responces from all 21xx, 22xxxx commands '''
|
||||
|
||||
|
@ -86,7 +86,7 @@ def loadECUlist():
|
||||
eculistcache = "./cache/ddt_eculist.p"
|
||||
|
||||
if os.path.isfile(eculistcache): # if cache exists
|
||||
eculist = pickle.load(open(eculistcache, "rb")) # load it
|
||||
eculist = pickle.load(open(eculistcache, "rb")) # load it #dbaccess
|
||||
else:
|
||||
|
||||
# open xml
|
||||
@ -135,7 +135,7 @@ def loadECUlist():
|
||||
air['Version'] = AutoIdent.attrib["Version"].strip()
|
||||
ail.append(air)
|
||||
eculist[Address]["targets"][href]['AutoIdents'] = ail
|
||||
pickle.dump(eculist, open(eculistcache, "wb")) # and save cache
|
||||
pickle.dump(eculist, open(eculistcache, "wb")) # and save cache #dbaccess
|
||||
|
||||
return eculist
|
||||
|
||||
|
@ -23,6 +23,7 @@ import mod_globals
|
||||
|
||||
from xml.dom.minidom import parse
|
||||
from datetime import datetime
|
||||
from mod_utils import show_doc
|
||||
import xml.dom.minidom
|
||||
import xml.etree.ElementTree as et
|
||||
import struct
|
||||
@ -376,6 +377,15 @@ class ECU:
|
||||
# csv_filename = csv_filename.encode("ascii","ignore")
|
||||
csvf = open("./csv/"+pyren_encode(csv_filename), "wt")
|
||||
|
||||
DTCpos = path.find('DTC')
|
||||
if DTCpos > 0:
|
||||
IDstr = '#' + path[DTCpos+3:DTCpos + 9]
|
||||
else:
|
||||
IDstr = ''
|
||||
|
||||
#debug
|
||||
#show_doc(self.ecudata['dst'], IDstr)
|
||||
|
||||
kb = KBHit()
|
||||
|
||||
tb = time.time() #time of begining
|
||||
@ -455,9 +465,9 @@ class ECU:
|
||||
newScreen = newScreen + pyren_encode( l ) + ' \n'
|
||||
|
||||
if pages>0:
|
||||
newScreen = newScreen+'\n'+"[Page "+str(page+1)+" from "+str(pages+1)+"] Press page number to switch or any other to exit"
|
||||
newScreen = newScreen+'\n'+"[Page "+str(page+1)+" from "+str(pages+1)+"] N for page number H for help or any other to exit"
|
||||
else:
|
||||
newScreen = newScreen+'\n'+"Press any key to exit"
|
||||
newScreen = newScreen+'\n'+"Press H for help or any key to exit"
|
||||
|
||||
print newScreen,
|
||||
sys.stdout.flush ()
|
||||
@ -479,6 +489,9 @@ class ECU:
|
||||
page = n-1
|
||||
clearScreen()
|
||||
continue
|
||||
if c in ['h','H']:
|
||||
show_doc(self.ecudata['dst'], IDstr)
|
||||
continue
|
||||
if mod_globals.opt_csv and (c in mod_globals.opt_usrkey):
|
||||
csvline += ";" + c
|
||||
continue
|
||||
|
@ -39,13 +39,16 @@ currentDDTscreen = None
|
||||
|
||||
ext_cur_DTC = "000000"
|
||||
|
||||
none_val = 'None'
|
||||
none_val = "None"
|
||||
|
||||
mtcdir = '../MTCSAVE/VIN'
|
||||
mtcdir = "../MTCSAVE/VIN"
|
||||
|
||||
ddtroot = '..' # parent folder for backward compatibility. for 9n and up use ../DDT2000data
|
||||
ddtroot = ".." # parent folder for backward compatibility. for 9n and up use ../DDT2000data
|
||||
|
||||
os = ""
|
||||
|
||||
language_dict = {}
|
||||
|
||||
vin = ""
|
||||
|
||||
doc_server_proc = None
|
@ -14,7 +14,14 @@ GNU General Public License for more details.
|
||||
|
||||
import sys
|
||||
import os
|
||||
import signal
|
||||
import atexit
|
||||
import subprocess
|
||||
import mod_globals
|
||||
try:
|
||||
import webbrowser
|
||||
except:
|
||||
pass
|
||||
|
||||
# Snippet from http://home.wlu.edu/~levys/software/kbhit.py
|
||||
|
||||
@ -25,9 +32,9 @@ if os.name == 'nt':
|
||||
# Posix (Linux, OS X)
|
||||
else:
|
||||
import termios
|
||||
import atexit
|
||||
#import atexit
|
||||
from select import select
|
||||
from decimal import *
|
||||
#from decimal import *
|
||||
|
||||
class KBHit:
|
||||
|
||||
@ -379,14 +386,16 @@ def chkDirTree():
|
||||
os.makedirs('./dumps')
|
||||
if not os.path.exists('./macro'):
|
||||
os.makedirs('./macro')
|
||||
if not os.path.exists('./doc'):
|
||||
os.makedirs('./doc')
|
||||
|
||||
|
||||
def getVIN( de, elm ):
|
||||
def getVIN( de, elm, getFirst = False ):
|
||||
''' getting VINs from every ECU '''
|
||||
''' de - list of detected ECUs '''
|
||||
''' elm - reference to ELM class '''
|
||||
|
||||
m_vin = {}
|
||||
m_vin = set([])
|
||||
for e in de:
|
||||
|
||||
# init elm
|
||||
@ -413,12 +422,14 @@ def getVIN( de, elm ):
|
||||
continue
|
||||
|
||||
#debug
|
||||
print e['dst'],' : ', vin
|
||||
#print e['dst'],' : ', vin
|
||||
|
||||
if len(vin)==17:
|
||||
m_vin[vin] = ''
|
||||
m_vin.add(vin)
|
||||
if getFirst:
|
||||
return vin
|
||||
|
||||
l_vin = m_vin.keys()
|
||||
l_vin = m_vin
|
||||
|
||||
if os.path.exists('savedVIN.txt'):
|
||||
with open('savedVIN.txt') as vinfile:
|
||||
@ -427,14 +438,14 @@ def getVIN( de, elm ):
|
||||
l = l.strip()
|
||||
if '#' in l: continue
|
||||
if len(l)==17:
|
||||
l_vin.append(l.upper())
|
||||
l_vin.add(l.upper())
|
||||
|
||||
if len(l_vin)==0:
|
||||
if len(l_vin)==0 and not getFirst:
|
||||
print "ERROR!!! Can't find any VIN. Check connection"
|
||||
exit()
|
||||
|
||||
if len(l_vin)<2:
|
||||
return l_vin[0]
|
||||
return next(iter(l_vin))
|
||||
|
||||
print "\nFound ",len(l_vin), " VINs\n"
|
||||
|
||||
@ -446,3 +457,24 @@ def DBG( tag, s ):
|
||||
if mod_globals.opt_debug and mod_globals.debug_file!=None:
|
||||
mod_globals.debug_file.write( '### ' + tag + '\n')
|
||||
mod_globals.debug_file.write( '"' + s + '"\n')
|
||||
|
||||
def kill_server():
|
||||
if mod_globals.doc_server_proc is None:
|
||||
pass
|
||||
else:
|
||||
os.kill(mod_globals.doc_server_proc.pid, signal.SIGTERM)
|
||||
|
||||
def show_doc( addr, id ):
|
||||
if mod_globals.vin == '':
|
||||
return
|
||||
|
||||
if mod_globals.doc_server_proc == None:
|
||||
mod_globals.doc_server_proc = subprocess.Popen(["python", "-m", "SimpleHTTPServer", "59152"])
|
||||
atexit.register(kill_server)
|
||||
|
||||
url = 'http://localhost:59152/doc/'+mod_globals.vin+'.htm'+id
|
||||
webbrowser.open(url, new=0)
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -272,6 +272,7 @@ def main():
|
||||
# Do this check every time
|
||||
se.scanAllEcus() #First scan of all ecus
|
||||
|
||||
mod_globals.vin = getVIN(se.detectedEcus, elm, getFirst=True)
|
||||
|
||||
print "Loading language "
|
||||
sys.stdout.flush()
|
||||
|
Loading…
x
Reference in New Issue
Block a user