backup progress py3 port
This commit is contained in:
parent
5176af2409
commit
03b34aa750
@ -141,15 +141,13 @@ def get_file_from_clip( filename ):
|
|||||||
or '/sg' in filename.lower() \
|
or '/sg' in filename.lower() \
|
||||||
or '\\sg' in filename.lower()):
|
or '\\sg' in filename.lower()):
|
||||||
mode = 'rb'
|
mode = 'rb'
|
||||||
|
enc = None
|
||||||
else:
|
else:
|
||||||
mode = 'r'
|
mode = 'r'
|
||||||
|
enc = "utf-16le" if "Vehicles" in filename else "utf-8"
|
||||||
if (mod_globals.os == 'android'
|
|
||||||
or mod_globals.clip_arc != ''):
|
|
||||||
mode = 'r'
|
|
||||||
|
|
||||||
if mod_globals.clip_arc=='':
|
if mod_globals.clip_arc=='':
|
||||||
return open(os.path.join(mod_globals.cliproot, filename), mode)
|
return open(os.path.join(mod_globals.cliproot, filename), mode, encoding=enc)
|
||||||
else:
|
else:
|
||||||
if filename.startswith('../'):
|
if filename.startswith('../'):
|
||||||
filename = filename[3:]
|
filename = filename[3:]
|
||||||
|
@ -16,8 +16,6 @@ from mod_elm import ELM
|
|||||||
from mod_elm import snat
|
from mod_elm import snat
|
||||||
from mod_elm import dnat
|
from mod_elm import dnat
|
||||||
from mod_elm import AllowedList
|
from mod_elm import AllowedList
|
||||||
if mod_globals.os != 'android':
|
|
||||||
from mod_ddt import DDT
|
|
||||||
|
|
||||||
import mod_globals
|
import mod_globals
|
||||||
import mod_db_manager
|
import mod_db_manager
|
||||||
@ -529,13 +527,13 @@ class ECU:
|
|||||||
|
|
||||||
header = 'ECU : '+self.ecudata['ecuname']+ connectionData +self.ecudata['doc']+'\n'
|
header = 'ECU : '+self.ecudata['ecuname']+ connectionData +self.ecudata['doc']+'\n'
|
||||||
header = header + "Screen : "+path
|
header = header + "Screen : "+path
|
||||||
newScreen = newScreen + pyren_encode( header ) + '\n'
|
newScreen = newScreen + pyren_encode( header ).decode("utf-8") + '\n'
|
||||||
|
|
||||||
H = 25
|
H = 25
|
||||||
|
|
||||||
pages = len(strlst)/H
|
pages = len(strlst)/H
|
||||||
for l in strlst[page*H:(page+1)*H]:
|
for l in strlst[page*H:(page+1)*H]:
|
||||||
newScreen = newScreen + pyren_encode( l ) + ' \n'
|
newScreen = newScreen + pyren_encode( l ).decode("utf-8") + ' \n'
|
||||||
if not path[:3] == 'FAV':
|
if not path[:3] == 'FAV':
|
||||||
if pages>0:
|
if pages>0:
|
||||||
newScreen = newScreen+'\n'+"[Page "+str(page+1)+" from "+str(pages+1)+"] [N-next P-prev.] H for help or any other to exit"
|
newScreen = newScreen+'\n'+"[Page "+str(page+1)+" from "+str(pages+1)+"] [N-next P-prev.] H for help or any other to exit"
|
||||||
@ -1260,25 +1258,6 @@ def find_real_ecuid( eid ):
|
|||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|
||||||
try:
|
|
||||||
import androidhelper as android
|
|
||||||
mod_globals.os = 'android'
|
|
||||||
except:
|
|
||||||
try:
|
|
||||||
import android
|
|
||||||
mod_globals.os = 'android'
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
|
|
||||||
if mod_globals.os == 'android':
|
|
||||||
ecuid = input('Enetr ECU ID:')
|
|
||||||
lanid = input('Language [RU]:')
|
|
||||||
if len(lanid)<2: lanid = 'RU'
|
|
||||||
sys.argv.append(ecuid)
|
|
||||||
sys.argv.append(lanid)
|
|
||||||
sys.argv.append('TORQ')
|
|
||||||
|
|
||||||
if len(sys.argv)<3:
|
if len(sys.argv)<3:
|
||||||
print("Usage: mod_ecu.py <ID> <language> [torq] [nochk]")
|
print("Usage: mod_ecu.py <ID> <language> [torq] [nochk]")
|
||||||
print("Example:")
|
print("Example:")
|
||||||
@ -1332,13 +1311,6 @@ def main():
|
|||||||
print("Loading mnemonics")
|
print("Loading mnemonics")
|
||||||
mm_class = ecu_mnemonics ( Mnemonics, mdoc, opt_file.dict, lang.dict )
|
mm_class = ecu_mnemonics ( Mnemonics, mdoc, opt_file.dict, lang.dict )
|
||||||
|
|
||||||
#for p in Parameters.values():
|
|
||||||
# print p
|
|
||||||
#for s in States.values():
|
|
||||||
# print s
|
|
||||||
#for m in Mnemonics.values():
|
|
||||||
# print m
|
|
||||||
|
|
||||||
if len(sys.argv)==3:
|
if len(sys.argv)==3:
|
||||||
print()
|
print()
|
||||||
print("Defaults")
|
print("Defaults")
|
||||||
@ -1370,11 +1342,6 @@ def main():
|
|||||||
for i in sorted(Commands.keys()):
|
for i in sorted(Commands.keys()):
|
||||||
print(pyren_encode( Commands[i].codeMR+"["+i+"] "+Commands[i].label ))
|
print(pyren_encode( Commands[i].codeMR+"["+i+"] "+Commands[i].label ))
|
||||||
|
|
||||||
sys.exit(0)
|
|
||||||
|
|
||||||
if len(sys.argv)>3 and sys.argv[3].upper()!='TORQ':
|
|
||||||
sys.exit(0)
|
|
||||||
|
|
||||||
family = sys.argv[1][:2]
|
family = sys.argv[1][:2]
|
||||||
eindex = sys.argv[1][2:]
|
eindex = sys.argv[1][2:]
|
||||||
if len(candst)>1:
|
if len(candst)>1:
|
||||||
@ -1386,9 +1353,6 @@ def main():
|
|||||||
ddd = '82'+F2A[family]+'F1'
|
ddd = '82'+F2A[family]+'F1'
|
||||||
filename = "PR_"+F2A[family]+"_"+eindex+"_"+sys.argv[2]+".csv"
|
filename = "PR_"+F2A[family]+"_"+eindex+"_"+sys.argv[2]+".csv"
|
||||||
|
|
||||||
if mod_globals.os=='android' and os.path.exists('/sdcard/.torque/extendedpids'):
|
|
||||||
filename = '/sdcard/.torque/extendedpids/'+filename
|
|
||||||
|
|
||||||
cf = open( filename, "w")
|
cf = open( filename, "w")
|
||||||
|
|
||||||
line = "%s,%s,%s,%s,%s,%s,%s,%s\n"%("name","ShortName","ModeAndPID","Equation","Min Value","Max Value","Units","Header")
|
line = "%s,%s,%s,%s,%s,%s,%s,%s\n"%("name","ShortName","ModeAndPID","Equation","Min Value","Max Value","Units","Header")
|
||||||
@ -1494,49 +1458,7 @@ def main():
|
|||||||
print(slow05init)
|
print(slow05init)
|
||||||
print()
|
print()
|
||||||
|
|
||||||
# make profile for torque
|
self.show_screens()
|
||||||
profilename = str(int(time.time()))+'.tdv'
|
|
||||||
if mod_globals.os=='android' and os.path.exists('/sdcard/.torque/vehicles'):
|
|
||||||
profilename = '/sdcard/.torque/vehicles/'+str(int(time.time()))+'.tdv'
|
|
||||||
|
|
||||||
prn = open( profilename, "w")
|
|
||||||
prn.write( '#This is an ECU profile generated by pyren\n'.encode('utf-8') )
|
|
||||||
prn.write( 'fuelType=0\n'.encode('utf-8') )
|
|
||||||
prn.write( 'obdAdjustNew=1.0\n'.encode('utf-8') )
|
|
||||||
prn.write( 'lastMPG=0.0\n'.encode('utf-8') )
|
|
||||||
prn.write( 'tankCapacity=295.5\n'.encode('utf-8') )
|
|
||||||
prn.write( 'volumetricEfficiency=85.0\n'.encode('utf-8') )
|
|
||||||
prn.write( 'weight=1400.0\n'.encode('utf-8') )
|
|
||||||
prn.write( 'odoMeter=0.0\n'.encode('utf-8') )
|
|
||||||
prn.write( 'adapterName=OBDII [00\:00\:00\:00\:00\:0]\n'.encode('utf-8') )
|
|
||||||
prn.write( 'adapter=00\:00\:00\:00\:00\:00\n'.encode('utf-8') )
|
|
||||||
prn.write( 'boostAdjust=0.0\n'.encode('utf-8') )
|
|
||||||
prn.write( 'mpgAdjust=1.0\n'.encode('utf-8') )
|
|
||||||
prn.write( 'fuelCost=0.18000000715255737\n'.encode('utf-8') )
|
|
||||||
prn.write( 'ownProfile=false\n'.encode('utf-8') )
|
|
||||||
prn.write( 'displacement=1.6\n'.encode('utf-8') )
|
|
||||||
prn.write( 'tankUsed=147.75\n'.encode('utf-8') )
|
|
||||||
prn.write( 'lastMPGCount=0\n'.encode('utf-8') )
|
|
||||||
prn.write( 'maxRpm=7000\n'.encode('utf-8') )
|
|
||||||
prn.write( 'fuelDistance=0.0\n'.encode('utf-8') )
|
|
||||||
prn.write( 'fuelUsed=0.0\n'.encode('utf-8') )
|
|
||||||
prn.write( 'alternateHeader=true\n'.encode('utf-8') )
|
|
||||||
prn.write( ('name=PR_'+ecuid+'\n').encode('utf-8') )
|
|
||||||
if len(candst)>1:
|
|
||||||
prn.write( ('customInit='+can500init.replace('\\','\\\\')+'\n').encode('utf-8') )
|
|
||||||
prn.write( 'preferredProtocol=7\n'.encode('utf-8') )
|
|
||||||
elif len(fastinit)>1:
|
|
||||||
prn.write( ('customInit='+fast10init.replace('\\','\\\\')+'\n').encode('utf-8') )
|
|
||||||
prn.write( 'preferredProtocol=6\n'.encode('utf-8') )
|
|
||||||
else:
|
|
||||||
prn.write( ('customInit='+slow05init.replace('\\','\\\\')+'\n').encode('utf-8') )
|
|
||||||
prn.write( 'preferredProtocol=5\n'.encode('utf-8') )
|
|
||||||
prn.close()
|
|
||||||
|
|
||||||
print()
|
|
||||||
print("Torque profile:", profilename, "created")
|
|
||||||
print()
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ def get_state( st, mn, se, elm, calc, dataids = {} ):
|
|||||||
st.value = " "*(8-len(st.value)/2) + st.value
|
st.value = " "*(8-len(st.value)/2) + st.value
|
||||||
return "%-6s %-41s %-16s"%(st.codeMR,st.label,st.value), st.helps, csv_val
|
return "%-6s %-41s %-16s"%(st.codeMR,st.label,st.value), st.helps, csv_val
|
||||||
else:
|
else:
|
||||||
st.value = " "*(16-len(st.value)/2) + st.value
|
st.value = " "*int(16-len(st.value)/2) + st.value.decode("utf-8")
|
||||||
return "%-6s %-50s %-20s"%(st.codeMR,st.label,st.value), st.helps, csv_val
|
return "%-6s %-50s %-20s"%(st.codeMR,st.label,st.value), st.helps, csv_val
|
||||||
|
|
||||||
class ecu_state:
|
class ecu_state:
|
||||||
|
@ -210,7 +210,7 @@ class Port:
|
|||||||
print("")
|
print("")
|
||||||
print("Available COM ports:")
|
print("Available COM ports:")
|
||||||
for port, desc, hwid in iterator:
|
for port, desc, hwid in iterator:
|
||||||
print("%-30s \n\tdesc: %s \n\thwid: %s" % (port, desc.decode ("windows-1251"), hwid))
|
print("%-30s \n\tdesc: %s \n\thwid: %s" % (port, desc, hwid))
|
||||||
print("")
|
print("")
|
||||||
mod_globals.opt_demo = True
|
mod_globals.opt_demo = True
|
||||||
exit (2)
|
exit (2)
|
||||||
@ -304,22 +304,25 @@ class Port:
|
|||||||
byte = self.hdr.read(inInputBuffer)
|
byte = self.hdr.read(inInputBuffer)
|
||||||
else:
|
else:
|
||||||
byte = self.hdr.read(1)
|
byte = self.hdr.read(1)
|
||||||
except:
|
except Exception as e:
|
||||||
|
print(e)
|
||||||
print('*' * 40)
|
print('*' * 40)
|
||||||
print('* Connection to ELM was lost')
|
print('* Connection to ELM was lost')
|
||||||
mod_globals.opt_demo = True
|
mod_globals.opt_demo = True
|
||||||
|
if byte:
|
||||||
|
print("READINGG", byte)
|
||||||
return byte
|
return byte
|
||||||
|
|
||||||
def write(self, data):
|
def write(self, data):
|
||||||
|
if type(data) is str:
|
||||||
|
data = data.encode("utf-8")
|
||||||
# dummy sync
|
# dummy sync
|
||||||
self.rwLock = True
|
self.rwLock = True
|
||||||
i = 0
|
i = 0
|
||||||
while self.kaLock and i < 10:
|
while self.kaLock and i < 10:
|
||||||
time.sleep (0.02)
|
time.sleep (0.02)
|
||||||
i = i + 1
|
i = i + 1
|
||||||
|
print("WRITINGG", data)
|
||||||
try:
|
try:
|
||||||
if self.portType == 1:
|
if self.portType == 1:
|
||||||
try:
|
try:
|
||||||
@ -333,7 +336,8 @@ class Port:
|
|||||||
return self.droid.bluetoothWrite (data)
|
return self.droid.bluetoothWrite (data)
|
||||||
else:
|
else:
|
||||||
return self.hdr.write (data)
|
return self.hdr.write (data)
|
||||||
except:
|
except Exception as e:
|
||||||
|
print(e)
|
||||||
print('*' * 40)
|
print('*' * 40)
|
||||||
print('* Connection to ELM was lost')
|
print('* Connection to ELM was lost')
|
||||||
mod_globals.opt_demo = True
|
mod_globals.opt_demo = True
|
||||||
@ -381,15 +385,15 @@ class Port:
|
|||||||
|
|
||||||
# search > string
|
# search > string
|
||||||
tb = time.time () # start time
|
tb = time.time () # start time
|
||||||
self.buff = ""
|
self.buff = b""
|
||||||
while True:
|
while True:
|
||||||
if not mod_globals.opt_demo:
|
if not mod_globals.opt_demo:
|
||||||
byte = self.read ()
|
byte = self.read() or b""
|
||||||
else:
|
else:
|
||||||
byte = '>'
|
byte = '>'.encode("ascii")
|
||||||
self.buff += byte
|
self.buff += byte
|
||||||
tc = time.time ()
|
tc = time.time ()
|
||||||
if '>' in self.buff:
|
if '>'.encode("ascii") in self.buff:
|
||||||
mod_globals.opt_speed = s
|
mod_globals.opt_speed = s
|
||||||
print("\nStart COM speed: ", s)
|
print("\nStart COM speed: ", s)
|
||||||
self.hdr.timeout = self.portTimeout
|
self.hdr.timeout = self.portTimeout
|
||||||
@ -1227,12 +1231,12 @@ class ELM:
|
|||||||
if cmd_len < 8: # single frame
|
if cmd_len < 8: # single frame
|
||||||
# check L1 cache here
|
# check L1 cache here
|
||||||
if isCommandInCache and int('0x' + self.l1_cache[command], 16) < 16:
|
if isCommandInCache and int('0x' + self.l1_cache[command], 16) < 16:
|
||||||
raw_command.append (("%0.2X" % cmd_len) + command + self.l1_cache[command])
|
raw_command.append (("%0.2X" % int(cmd_len)) + command + self.l1_cache[command])
|
||||||
else:
|
else:
|
||||||
raw_command.append (("%0.2X" % cmd_len) + command)
|
raw_command.append (("%0.2X" % int(cmd_len)) + command)
|
||||||
else:
|
else:
|
||||||
# first frame
|
# first frame
|
||||||
raw_command.append ("1" + ("%0.3X" % cmd_len)[-3:] + command[:12])
|
raw_command.append ("1" + ("%0.3X" % int(cmd_len))[-3:] + command[:12])
|
||||||
command = command[12:]
|
command = command[12:]
|
||||||
# consecutive frames
|
# consecutive frames
|
||||||
frame_number = 1
|
frame_number = 1
|
||||||
@ -1409,10 +1413,10 @@ class ELM:
|
|||||||
raw_command = []
|
raw_command = []
|
||||||
cmd_len = len(command) / 2
|
cmd_len = len(command) / 2
|
||||||
if cmd_len < 8: # single frame
|
if cmd_len < 8: # single frame
|
||||||
raw_command.append(("%0.2X" % cmd_len) + command)
|
raw_command.append(("%0.2X" % int(cmd_len)) + command)
|
||||||
else:
|
else:
|
||||||
# first frame
|
# first frame
|
||||||
raw_command.append("1" + ("%0.3X" % cmd_len)[-3:] + command[:12])
|
raw_command.append("1" + ("%0.3X" % int(cmd_len))[-3:] + command[:12])
|
||||||
command = command[12:]
|
command = command[12:]
|
||||||
# consecutive frames
|
# consecutive frames
|
||||||
frame_number = 1
|
frame_number = 1
|
||||||
@ -1610,10 +1614,10 @@ class ELM:
|
|||||||
raw_command = []
|
raw_command = []
|
||||||
cmd_len = len (command) / 2
|
cmd_len = len (command) / 2
|
||||||
if cmd_len < 8: # single frame
|
if cmd_len < 8: # single frame
|
||||||
raw_command.append (("%0.2X" % cmd_len) + command)
|
raw_command.append (("%0.2X" % int(cmd_len)) + command)
|
||||||
else:
|
else:
|
||||||
# first frame
|
# first frame
|
||||||
raw_command.append ("1" + ("%0.3X" % cmd_len)[-3:] + command[:12])
|
raw_command.append ("1" + ("%0.3X" % int(cmd_len))[-3:] + command[:12])
|
||||||
command = command[12:]
|
command = command[12:]
|
||||||
# consecutive frames
|
# consecutive frames
|
||||||
frame_number = 1
|
frame_number = 1
|
||||||
|
@ -94,7 +94,7 @@ class optfile:
|
|||||||
|
|
||||||
if progress and (i&0xff==0):
|
if progress and (i&0xff==0):
|
||||||
pr = (i+2-keyoff)*100/(tb-keyoff)
|
pr = (i+2-keyoff)*100/(tb-keyoff)
|
||||||
print('\r['+'X'*(pr/2)+' '*(50-pr/2)+'] '+str(int(pr))+'%', end=' ')
|
print('\r['+'X'*int(pr/2)+' '*int(50-pr/2)+'] '+str(int(pr))+'%', end=' ')
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
|
|
||||||
lf.seek(i)
|
lf.seek(i)
|
||||||
|
@ -88,6 +88,7 @@ class ScanEcus:
|
|||||||
#if model_n<86: continue
|
#if model_n<86: continue
|
||||||
except ValueError:
|
except ValueError:
|
||||||
pass
|
pass
|
||||||
|
print(file)
|
||||||
DOMTree = xml.dom.minidom.parse(mod_db_manager.get_file_from_clip(file))
|
DOMTree = xml.dom.minidom.parse(mod_db_manager.get_file_from_clip(file))
|
||||||
vh = DOMTree.documentElement
|
vh = DOMTree.documentElement
|
||||||
if vh.hasAttribute("defaultText"):
|
if vh.hasAttribute("defaultText"):
|
||||||
@ -169,7 +170,7 @@ class ScanEcus:
|
|||||||
self.allecus[ecu]['pin1']==canH and
|
self.allecus[ecu]['pin1']==canH and
|
||||||
self.allecus[ecu]['pin2']==canL):
|
self.allecus[ecu]['pin2']==canL):
|
||||||
i = i+1
|
i = i+1
|
||||||
print('\r'+'\t\t\t\t'+'\rScanning:'+str(i)+'/'+str(len(self.allecus))+" Detected: "+str(len(self.detectedEcus)), end=' ')
|
print('\r'+'\t\t\t\t'+'\rScanning CAN:'+str(i)+'/'+str(len(self.allecus))+" Detected: "+str(len(self.detectedEcus)), end=' ')
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
|
|
||||||
self.elm.set_can_addr( self.allecus[ecu]['dst'], self.allecus[ecu] )
|
self.elm.set_can_addr( self.allecus[ecu]['dst'], self.allecus[ecu] )
|
||||||
@ -186,7 +187,7 @@ class ScanEcus:
|
|||||||
self.allecus[ecu]['pin2']=='15'):
|
self.allecus[ecu]['pin2']=='15'):
|
||||||
|
|
||||||
i = i+1
|
i = i+1
|
||||||
print('\r'+'\t\t\t\t'+'\rScanning:'+str(i)+'/'+str(len(self.allecus))+" Detected: "+str(len(self.detectedEcus)), end=' ')
|
print('\r'+'\t\t\t\t'+'\rScanning KWP:'+str(i)+'/'+str(len(self.allecus))+" Detected: "+str(len(self.detectedEcus)), end=' ')
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
|
|
||||||
self.elm.set_iso_addr( self.allecus[ecu]['dst'], self.allecus[ecu] )
|
self.elm.set_iso_addr( self.allecus[ecu]['dst'], self.allecus[ecu] )
|
||||||
@ -989,7 +990,6 @@ def readECUIds( elm ):
|
|||||||
|
|
||||||
return StartSession, DiagVersion, Supplier, Version, Soft, Std, VIN
|
return StartSession, DiagVersion, Supplier, Version, Soft, Std, VIN
|
||||||
|
|
||||||
|
|
||||||
def findTCOM( addr, cmd, rsp ):
|
def findTCOM( addr, cmd, rsp ):
|
||||||
ecuvhc = {}
|
ecuvhc = {}
|
||||||
vehicle = ''
|
vehicle = ''
|
||||||
@ -1047,6 +1047,7 @@ def findTCOM( addr, cmd, rsp ):
|
|||||||
print(r, se.allecus[r]['doc'], se.allecus[r]['ids'], ecuvhc[r])
|
print(r, se.allecus[r]['doc'], se.allecus[r]['ids'], ecuvhc[r])
|
||||||
except:
|
except:
|
||||||
print()
|
print()
|
||||||
|
|
||||||
def generateSavedEcus( eculist, fileName ):
|
def generateSavedEcus( eculist, fileName ):
|
||||||
se = ScanEcus( 0 )
|
se = ScanEcus( 0 )
|
||||||
se.read_Uces_file( all = True )
|
se.read_Uces_file( all = True )
|
||||||
|
@ -157,7 +157,7 @@ def Choice(list, question ):
|
|||||||
sys.exit()
|
sys.exit()
|
||||||
if ch=='q': ch = 'Q'
|
if ch=='q': ch = 'Q'
|
||||||
if ch=='cmd': mod_globals.opt_cmd = True
|
if ch=='cmd': mod_globals.opt_cmd = True
|
||||||
if ch in list(d.keys()):
|
if ch in d.keys():
|
||||||
return [d[ch],ch]
|
return [d[ch],ch]
|
||||||
|
|
||||||
def ChoiceLong(list, question, header = '' ):
|
def ChoiceLong(list, question, header = '' ):
|
||||||
@ -178,7 +178,7 @@ def ChoiceLong(list, question, header = '' ):
|
|||||||
|
|
||||||
while( 1 ):
|
while( 1 ):
|
||||||
|
|
||||||
clearScreen()
|
# clearScreen()
|
||||||
#os.system('cls' if os.name == 'nt' else 'clear') # clear screen
|
#os.system('cls' if os.name == 'nt' else 'clear') # clear screen
|
||||||
#print chr(27)+"[2J"+chr(27)+"[;H", # clear ANSI screen (thanks colorama for windows)
|
#print chr(27)+"[2J"+chr(27)+"[;H", # clear ANSI screen (thanks colorama for windows)
|
||||||
|
|
||||||
@ -218,7 +218,7 @@ def ChoiceLong(list, question, header = '' ):
|
|||||||
break
|
break
|
||||||
|
|
||||||
if ch=='cmd': mod_globals.opt_cmd = True
|
if ch=='cmd': mod_globals.opt_cmd = True
|
||||||
if ch in list(d.keys()):
|
if ch in d.keys():
|
||||||
return [d[ch],ch]
|
return [d[ch],ch]
|
||||||
|
|
||||||
def ChoiceFromDict(dict, question, showId = True ):
|
def ChoiceFromDict(dict, question, showId = True ):
|
||||||
|
@ -1330,7 +1330,7 @@ class Production(object):
|
|||||||
return len(self.prod)
|
return len(self.prod)
|
||||||
|
|
||||||
def __bool__(self):
|
def __bool__(self):
|
||||||
return 1
|
return True
|
||||||
|
|
||||||
def __getitem__(self, index):
|
def __getitem__(self, index):
|
||||||
return self.prod[index]
|
return self.prod[index]
|
||||||
@ -1718,7 +1718,7 @@ class Grammar(object):
|
|||||||
def undefined_symbols(self):
|
def undefined_symbols(self):
|
||||||
result = []
|
result = []
|
||||||
for p in self.Productions:
|
for p in self.Productions:
|
||||||
if not p:
|
if not p is None:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
for s in p.prod:
|
for s in p.prod:
|
||||||
|
@ -9,48 +9,6 @@ mod_globals.os = os.name
|
|||||||
os.chdir(os.path.dirname(os.path.realpath(sys.argv[0])))
|
os.chdir(os.path.dirname(os.path.realpath(sys.argv[0])))
|
||||||
|
|
||||||
import pickle
|
import pickle
|
||||||
|
|
||||||
if mod_globals.os == 'nt':
|
|
||||||
import pip
|
|
||||||
|
|
||||||
try:
|
|
||||||
import serial
|
|
||||||
except ImportError:
|
|
||||||
pip.main(['install','pyserial'])
|
|
||||||
|
|
||||||
try:
|
|
||||||
import colorama
|
|
||||||
except ImportError:
|
|
||||||
pip.main(['install','colorama'])
|
|
||||||
try:
|
|
||||||
import colorama
|
|
||||||
except ImportError:
|
|
||||||
print("\n\n\n\t\t\tGive me access to the Internet for download modules\n\n\n")
|
|
||||||
sys.exit()
|
|
||||||
colorama.init()
|
|
||||||
else:
|
|
||||||
# let's try android
|
|
||||||
try:
|
|
||||||
import androidhelper as android
|
|
||||||
mod_globals.os = 'android'
|
|
||||||
except:
|
|
||||||
try:
|
|
||||||
import android
|
|
||||||
mod_globals.os = 'android'
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
|
|
||||||
if mod_globals.os != 'android':
|
|
||||||
try:
|
|
||||||
import serial
|
|
||||||
from serial.tools import list_ports
|
|
||||||
#import ply
|
|
||||||
except ImportError:
|
|
||||||
print("\n\n\n\tPleas install additional modules")
|
|
||||||
print("\t\t>sudo easy_install pyserial")
|
|
||||||
#print "\t\t>sudo easy_install ply"
|
|
||||||
sys.exit()
|
|
||||||
|
|
||||||
import mod_utils
|
import mod_utils
|
||||||
import mod_ddt_utils
|
import mod_ddt_utils
|
||||||
|
|
||||||
@ -60,6 +18,9 @@ from mod_ecu import ECU
|
|||||||
from mod_optfile import *
|
from mod_optfile import *
|
||||||
from mod_utils import *
|
from mod_utils import *
|
||||||
|
|
||||||
|
from serial.tools import list_ports
|
||||||
|
from os import getenv
|
||||||
|
|
||||||
|
|
||||||
def optParser():
|
def optParser():
|
||||||
'''Parsing of command line parameters. User should define at least com port name'''
|
'''Parsing of command line parameters. User should define at least com port name'''
|
||||||
@ -221,7 +182,7 @@ def optParser():
|
|||||||
print("")
|
print("")
|
||||||
print("Available COM ports:")
|
print("Available COM ports:")
|
||||||
for port, desc, hwid in iterator:
|
for port, desc, hwid in iterator:
|
||||||
print("%-30s \n\tdesc: %s \n\thwid: %s" % (port,desc.decode("windows-1251"),hwid))
|
print("%-30s \n\tdesc: %s \n\thwid: %s" % (port,desc,hwid))
|
||||||
print("")
|
print("")
|
||||||
exit(2)
|
exit(2)
|
||||||
else:
|
else:
|
||||||
@ -229,7 +190,7 @@ def optParser():
|
|||||||
mod_globals.opt_ecuid = options.ecuid
|
mod_globals.opt_ecuid = options.ecuid
|
||||||
mod_globals.opt_speed = int(options.speed)
|
mod_globals.opt_speed = int(options.speed)
|
||||||
mod_globals.opt_rate = int(options.rate)
|
mod_globals.opt_rate = int(options.rate)
|
||||||
mod_globals.opt_lang = options.lang
|
mod_globals.opt_lang = options.lang.strip()
|
||||||
mod_globals.opt_car = options.car
|
mod_globals.opt_car = options.car
|
||||||
mod_globals.opt_log = options.logfile
|
mod_globals.opt_log = options.logfile
|
||||||
mod_globals.opt_demo = options.demo
|
mod_globals.opt_demo = options.demo
|
||||||
|
Loading…
x
Reference in New Issue
Block a user