@ -126,81 +126,25 @@ def check_vehicle_update(vehicle_list=None):
data1 = frappe . db . sql ( ''' SELECT name,max(version) as version,vehicle_id,language FROM {} .tabPublish where vehicle= ' {} ' and language= ' {} ' and publish_status= ' Published '
and vehicle_status = ' Active ' order by version ASC ; ''' .format(
current_db_name , vehicle , l_id ) , as_dict = True )
if data1_global [ 0 ] [ ' version ' ] :
if data1 [ 0 ] [ ' version ' ] is not None :
if current_version == float ( data1 [ 0 ] [ ' version ' ] ) :
data1 [ 0 ] [ ' IsUpdateAvailable ' ] = " false "
data = { }
data [ ' Language ' ] = l_id
data [ ' IsUpdateAvailable ' ] = ' false '
data [ ' CurrentVersion ' ] = float ( current_version )
Vehicle_req_list . append ( data )
if data1 [ 0 ] [ ' version ' ] is not None :
if current_version == float ( data1 [ 0 ] [ ' version ' ] ) :
data1 [ 0 ] [ ' IsUpdateAvailable ' ] = " false "
data = { }
data [ ' Language ' ] = l_id
data [ ' IsUpdateAvailable ' ] = ' false '
data [ ' CurrentVersion ' ] = float ( current_version )
Vehicle_req_list . append ( data )
else :
if current_version < ( float ( data1_global [ 0 ] [ ' version ' ] ) - 1.00 ) :
data = frappe . db . sql ( ''' SELECT name as Name,max(version) as Version,vehicle_id as Vehicle,language as Language FROM {} .tabPublish where vehicle= ' {} ' and language= ' {} ' and publish_status= ' Published '
and publish_type = ' Global ' and vehicle_status = ' Active ' and Version > ' {} ' order by version ASC ; ''' .format(
current_db_name , vehicle , l_id , current_version ) , as_dict = True )
try :
for d in data :
try :
file_name = " /files/json_files/full_update/ " + vehicle + " / " + vehicle + " - " + d [ ' Language ' ] + " - " + " full_v " + str ( d [ ' Version ' ] ) + " .json "
get_step_total_count ( base_url + file_name , )
file_size = os . path . getsize ( base_url + file_name )
d [ ' JsonURL ' ] = file_name
d [ ' FileSize ' ] = file_size
d [ ' Error ' ] = None
except :
file_name = None
file_size = None
d [ ' JsonURL ' ] = file_name
d [ ' FileSize ' ] = file_size
d [ ' Error ' ] = ' File failed to load '
d [ ' IsUpdateAvailable ' ] = ' true '
d [ ' CurrentVersion ' ] = float ( current_version )
Vehicle_req_list . append ( d )
except Exception as e :
Vehicle_req_list . append ( { " Error " : e } )
elif current_version == ( float ( data1_global [ 0 ] [ ' version ' ] ) - 1.00 ) :
data = frappe . db . sql ( ''' SELECT name as Name,max(version) as Version,vehicle_id as Vehicle,language as Language FROM {} .tabPublish where vehicle= ' {} ' and language= ' {} ' and publish_status= ' Published '
and publish_type = ' Global ' and vehicle_status = ' Active ' and Version > ' {} ' order by version ASC ; ''' .format(
current_db_name , vehicle , l_id , current_version ) , as_dict = True )
try :
for d in data :
try :
file_name = " /files/json_files/global/ " + vehicle + " / " + vehicle + " - " + d [ ' Language ' ] + " _v " + str ( d [ ' Version ' ] ) + " .json "
file_size = os . path . getsize ( base_url + file_name )
d [ ' JsonURL ' ] = file_name
d [ ' FileSize ' ] = file_size
d [ ' Error ' ] = None
except :
file_name = None
file_size = None
d [ ' JsonURL ' ] = file_name
d [ ' FileSize ' ] = file_size
d [ ' Error ' ] = ' File failed to load '
d [ ' IsUpdateAvailable ' ] = ' true '
d [ ' CurrentVersion ' ] = float ( current_version )
Vehicle_req_list . append ( d )
except Exception as e1 :
Vehicle_req_list . append ( { " Error " : e1 } )
elif current_version == float ( data1_global [ 0 ] [ ' version ' ] ) :
if current_version < float ( data1 [ 0 ] [ ' version ' ] ) :
else :
if current_version < ( float ( data1_global [ 0 ] [ ' version ' ] ) - 1.00 ) :
data = frappe . db . sql ( ''' SELECT name as Name,max(version) as Version,vehicle_id as Vehicle,language as Language FROM {} .tabPublish where vehicle= ' {} ' and language= ' {} ' and publish_status= ' Published '
and publish_type = ' {} ' and vehicle_status = ' Active ' and v ersion > ' {} ' order by version ASC ; ''' .format(
current_db_name , vehicle , l_id , publish_type , current_version ) , as_dict = True )
and publish_type = ' Global ' and vehicle_status = ' Active ' and Version > ' {} ' order by version ASC ; ''' .format(
current_db_name , vehicle , l_id , current_version ) , as_dict = True )
try :
for d in data :
try :
file_name = " /files/json_files/internal / " + vehicle + " / " + vehicle + " - " + d [ ' Language ' ] + " _v " + str ( d [ ' Version ' ] ) + " .json "
file_name = " /files/json_files/full_update/ " + vehicle + " / " + vehicle + " - " + d [ ' Language ' ] + " - " + " full_v " + str ( d [ ' Version ' ] ) + " .json "
file_size = os . path . getsize ( base_url + file_name )
d [ ' JsonURL ' ] = file_name
d [ ' FileSize ' ] = file_size
@ -216,17 +160,15 @@ def check_vehicle_update(vehicle_list=None):
d [ ' IsUpdateAvailable ' ] = ' true '
d [ ' CurrentVersion ' ] = float ( current_version )
Vehicle_req_list . append ( d )
except Exception as e2 :
Vehicle_req_list . append ( { " Error " : e2 } )
except Exception as e :
Vehicle_req_list . append ( { " Error " : e } )
elif ( float ( data1_global [ 0 ] [ ' version ' ] ) - 1.00 ) < current_version < float ( data1_global [ 0 ] [ ' version ' ] ) :
Vehicle_req_list . append ( { ' Cur_ver ' : current_version , " Global Ver " : data1 [ 0 ] [ ' version ' ] } )
if current_version < float ( data1 [ 0 ] [ ' version ' ] ) :
Vehicle_req_list . append ( { " loop " : 4.1 } )
elif current_version == ( float ( data1_global [ 0 ] [ ' version ' ] ) - 1.00 ) :
data = frappe . db . sql ( ''' SELECT name as Name,max(version) as Version,vehicle_id as Vehicle,language as Language FROM {} .tabPublish where vehicle= ' {} ' and language= ' {} ' and publish_status= ' Published '
and publish_type = ' Global ' and vehicle_status = ' Active ' and version > ' {} ' order by version ASC ; ''' .format(
current_db_name , vehicle , l_id , current_version ) , as_dict = True )
Vehicle_req_list . append ( { " Data " : ' Append ' } )
and publish_type = ' Global ' and vehicle_status = ' Active ' and Version > ' {} ' order by version ASC ; ''' .format(
current_db_name , vehicle , l_id , current_version ) , as_dict = True )
try :
for d in data :
try :
@ -237,7 +179,7 @@ def check_vehicle_update(vehicle_list=None):
d [ ' Error ' ] = None
except :
file_name = " /files/json_files/global/ " + vehicle + " / " + vehicle + " - " + d [ ' Language ' ] + " _v " + str ( d [ ' Version ' ] ) + " .json "
file_name = None
file_size = None
d [ ' JsonURL ' ] = file_name
d [ ' FileSize ' ] = file_size
@ -246,43 +188,126 @@ def check_vehicle_update(vehicle_list=None):
d [ ' IsUpdateAvailable ' ] = ' true '
d [ ' CurrentVersion ' ] = float ( current_version )
Vehicle_req_list . append ( d )
except Exception as e2 :
Vehicle_req_list . append ( { " Error " : e2 } )
# else:
# Vehicle_req_list.append({"error2":"Else"})
except Exception as e1 :
Vehicle_req_list . append ( { " Error " : e1 } )
elif current_version > float ( data1_global [ 0 ] [ ' version ' ] ) :
if current_version < float ( data1 [ 0 ] [ ' version ' ] ) :
data = frappe . db . sql ( ''' SELECT name as Name,max(version) as Version,vehicle_id as Vehicle,language as Language FROM {} .tabPublish where vehicle= ' {} ' and language= ' {} ' and publish_status= ' Published '
and publish_type = ' {} ' and vehicle_status = ' Active ' and version > ' {} ' order by version ASC ; ''' .format(
current_db_name , vehicle , l_id , publish_type , current_version ) , as_dict = True )
try :
for d in data :
try :
file_name = " /files/json_files/internal/ " + vehicle + " / " + vehicle + " - " + d [ ' Language ' ] + " _v " + str ( d [ ' Version ' ] ) + " .json "
file_size = os . path . getsize ( base_url + file_name )
d [ ' JsonURL ' ] = file_name
d [ ' FileSize ' ] = file_size
d [ ' Error ' ] = None
elif current_version == float ( data1_global [ 0 ] [ ' version ' ] ) :
if current_version < float ( data1 [ 0 ] [ ' version ' ] ) :
data = frappe . db . sql ( ''' SELECT name as Name,max(version) as Version,vehicle_id as Vehicle,language as Language FROM {} .tabPublish where vehicle= ' {} ' and language= ' {} ' and publish_status= ' Published '
and publish_type = ' {} ' and vehicle_status = ' Active ' and version > ' {} ' order by version ASC ; ''' .format(
current_db_name , vehicle , l_id , publish_type , current_version ) , as_dict = True )
try :
for d in data :
try :
file_name = " /files/json_files/internal/ " + vehicle + " / " + vehicle + " - " + d [ ' Language ' ] + " _v " + str ( d [ ' Version ' ] ) + " .json "
file_size = os . path . getsize ( base_url + file_name )
d [ ' JsonURL ' ] = file_name
d [ ' FileSize ' ] = file_size
d [ ' Error ' ] = None
except :
file_name = None
file_size = None
d [ ' JsonURL ' ] = file_name
d [ ' FileSize ' ] = file_size
d [ ' Error ' ] = ' File failed to load '
d [ ' IsUpdateAvailable ' ] = ' true '
d [ ' CurrentVersion ' ] = float ( current_version )
Vehicle_req_list . append ( d )
except Exception as e2 :
Vehicle_req_list . append ( { " Error " : e2 } )
elif ( float ( data1_global [ 0 ] [ ' version ' ] ) - 1.00 ) < current_version < float ( data1_global [ 0 ] [ ' version ' ] ) :
Vehicle_req_list . append ( { ' Cur_ver ' : current_version , " Global Ver " : data1 [ 0 ] [ ' version ' ] } )
if current_version < float ( data1 [ 0 ] [ ' version ' ] ) :
Vehicle_req_list . append ( { " loop " : 4.1 } )
data = frappe . db . sql ( ''' SELECT name as Name,max(version) as Version,vehicle_id as Vehicle,language as Language FROM {} .tabPublish where vehicle= ' {} ' and language= ' {} ' and publish_status= ' Published '
and publish_type = ' Global ' and vehicle_status = ' Active ' and version > ' {} ' order by version ASC ; ''' .format(
current_db_name , vehicle , l_id , current_version ) , as_dict = True )
Vehicle_req_list . append ( { " Data " : ' Append ' } )
try :
for d in data :
try :
file_name = " /files/json_files/global/ " + vehicle + " / " + vehicle + " - " + d [ ' Language ' ] + " _v " + str ( d [ ' Version ' ] ) + " .json "
file_size = os . path . getsize ( base_url + file_name )
d [ ' JsonURL ' ] = file_name
d [ ' FileSize ' ] = file_size
d [ ' Error ' ] = None
except :
file_name = " /files/json_files/global/ " + vehicle + " / " + vehicle + " - " + d [ ' Language ' ] + " _v " + str ( d [ ' Version ' ] ) + " .json "
file_size = None
d [ ' JsonURL ' ] = file_name
d [ ' FileSize ' ] = file_size
d [ ' Error ' ] = ' File failed to load '
d [ ' IsUpdateAvailable ' ] = ' true '
d [ ' CurrentVersion ' ] = float ( current_version )
Vehicle_req_list . append ( d )
except Exception as e2 :
Vehicle_req_list . append ( { " Error " : e2 } )
# else:
# Vehicle_req_list.append({"error2":"Else"})
elif current_version > float ( data1_global [ 0 ] [ ' version ' ] ) :
if current_version < float ( data1 [ 0 ] [ ' version ' ] ) :
data = frappe . db . sql ( ''' SELECT name as Name,max(version) as Version,vehicle_id as Vehicle,language as Language FROM {} .tabPublish where vehicle= ' {} ' and language= ' {} ' and publish_status= ' Published '
and publish_type = ' {} ' and vehicle_status = ' Active ' and version > ' {} ' order by version ASC ; ''' .format(
current_db_name , vehicle , l_id , publish_type , current_version ) , as_dict = True )
try :
for d in data :
try :
file_name = " /files/json_files/internal/ " + vehicle + " / " + vehicle + " - " + d [ ' Language ' ] + " _v " + str ( d [ ' Version ' ] ) + " .json "
file_size = os . path . getsize ( base_url + file_name )
d [ ' JsonURL ' ] = file_name
d [ ' FileSize ' ] = file_size
d [ ' Error ' ] = None
except :
file_name = " /files/json_files/internal/ " + vehicle + " / " + vehicle + " - " + d [ ' Language ' ] + " _v " + str ( d [ ' Version ' ] ) + " .json "
file_size = None
d [ ' JsonURL ' ] = file_name
d [ ' FileSize ' ] = file_size
d [ ' Error ' ] = ' File failed to load '
d [ ' IsUpdateAvailable ' ] = ' true '
d [ ' CurrentVersion ' ] = float ( current_version )
Vehicle_req_list . append ( d )
except Exception as e3 :
Vehicle_req_list . append ( { ' Error ' : e3 } )
# else:
# Vehicle_req_list.append({'Error':"Else 3"})
except :
file_name = " /files/json_files/internal/ " + vehicle + " / " + vehicle + " - " + d [ ' Language ' ] + " _v " + str ( d [ ' Version ' ] ) + " .json "
file_size = None
d [ ' JsonURL ' ] = file_name
d [ ' FileSize ' ] = file_size
d [ ' Error ' ] = ' File failed to load '
else :
Vehicle_req_list . append (
{ ' Language ' : l_id , ' IsUpdateAvailable ' : ' false ' , ' CurrentVersion ' : float ( current_version ) } )
else :
data = frappe . db . sql ( ''' SELECT name as Name,max(version) as Version,vehicle_id as Vehicle,language as Language FROM {} .tabPublish where vehicle= ' {} ' and language= ' {} ' and publish_status= ' Published '
and publish_type = ' {} ' and vehicle_status = ' Active ' and version > ' {} ' order by version ASC ; ''' .format(
current_db_name , vehicle , l_id , publish_type , current_version ) , as_dict = True )
try :
for d in data :
try :
file_name = " /files/json_files/internal/ " + vehicle + " / " + vehicle + " - " + d [ ' Language ' ] + " _v " + str ( d [ ' Version ' ] ) + " .json "
file_size = os . path . getsize ( base_url + file_name )
d [ ' JsonURL ' ] = file_name
d [ ' FileSize ' ] = file_size
d [ ' Error ' ] = None
d [ ' IsUpdateAvailable ' ] = ' true '
d [ ' CurrentVersion ' ] = float ( current_version )
Vehicle_req_list . append ( d )
except Exception as e3 :
Vehicle_req_list . append ( { ' Error ' : e3 } )
# else:
# Vehicle_req_list.append({'Error':"Else 3"})
except :
file_name = None
file_size = None
d [ ' JsonURL ' ] = file_name
d [ ' FileSize ' ] = file_size
d [ ' Error ' ] = ' File failed to load '
d [ ' IsUpdateAvailable ' ] = ' true '
d [ ' CurrentVersion ' ] = float ( current_version )
Vehicle_req_list . append ( d )
except Exception as e2 :
Vehicle_req_list . append ( { " Error " : e2 } )
else :
Vehicle_req_list . append (
{ ' Language ' : l_id , ' IsUpdateAvailable ' : ' false ' , ' CurrentVersion ' : float ( current_version ) } )
response [ ' Vehicle ' ] = vehicle
response [ ' VehicleReqList ' ] = Vehicle_req_list
return response
@ -295,10 +320,10 @@ def check_vehicle_update(vehicle_list=None):
else :
return { " status " : 0 , " error " : " Check Parameter: vehicle list " }
def get_step_total_count ( json_path ) :
with open ( json_path ) as json_file :
data = json . load ( json_file )
data = calculate_step ( data )
data = calculate_total ( data )
generate_json ( data , json_path )
@ -313,9 +338,7 @@ def generate_json(data, json_path):
def calculate_total ( data ) :
total_count = 0
for variant in data [ ' JSON ' ] :
total_count + = len ( variant [ ' Variant ' ] [ ' Assets ' ] )
total_count + = len ( variant [ ' Variant ' ] [ ' Systems ' ] )
for system in variant [ ' Variant ' ] [ ' Systems ' ] :