@ -166,7 +166,7 @@ def check_all_vehicle_updates1(vehicle_list=None):
@frappe . whitelist ( )
@frappe . whitelist ( )
def check_all_vehicle_updates ( vehicle_list = None ) :
def check_all_vehicle_updates ( vehicle_list = None ) :
frappe . log_error ( ' request ' + str ( vehicle_list ) )
# frappe.log_error('request' + str(vehicle_list) )
rate_res = custom_rate_limit ( limit = 5 , seconds = 15 )
rate_res = custom_rate_limit ( limit = 5 , seconds = 15 )
if rate_res != 1 :
if rate_res != 1 :
return rate_res
return rate_res
@ -186,7 +186,8 @@ def check_all_vehicle_updates(vehicle_list=None):
vehicle_data = v_list [ ' VehicleReqList ' ]
vehicle_data = v_list [ ' VehicleReqList ' ]
publish_type = frappe . db . sql (
publish_type = frappe . db . sql (
''' SELECT publish_type FROM `tabApp Device` where name= ' {} ' ; ''' . format ( iid ) , as_list = 1 )
''' SELECT publish_type FROM `tabApp Device` where name= ' {} ' ; ''' . format ( iid ) , as_list = 1 )
frappe . log_error ( ' publish_type ' + str ( publish_type ) )
frappe . log_error ( ' iid ' + str ( iid ) )
if publish_type [ 0 ] [ 0 ] is not None :
if publish_type [ 0 ] [ 0 ] is not None :
if vehicle_data :
if vehicle_data :
for v in vehicle_data :
for v in vehicle_data :
@ -195,8 +196,10 @@ def check_all_vehicle_updates(vehicle_list=None):
data1_global = frappe . db . sql ( ''' SELECT name,format(max(version),2) as version,vehicle_id,language,release_description as description FROM `tabPublish` where vehicle= ' {} ' and language= ' {} '
data1_global = frappe . db . sql ( ''' SELECT name,format(max(version),2) as version,vehicle_id,language,release_description as description FROM `tabPublish` where vehicle= ' {} ' and language= ' {} '
and publish_status = ' Published ' and publish_type = ' Global ' and vehicle_status = ' Active ' and publish_module = ' Automotive System '
and publish_status = ' Published ' and publish_type = ' Global ' and vehicle_status = ' Active ' and publish_module = ' Automotive System '
order by version ASC ; ''' .format(v_id, lang), as_dict=1)
order by version ASC ; ''' .format(v_id, lang), as_dict=1)
data1 = frappe . db . sql ( ''' SELECT name,format(max(version),2) as version,vehicle_id,language,release_description as description FROM `tabPublish` where vehicle= ' {} ' and language= ' {} '
data1 = frappe . db . sql ( ''' SELECT name,format(max(version),2) as version,vehicle_id,language,release_description as description
and publish_status = ' Published ' and publish_type = ' {} ' and vehicle_status = ' Active ' and publish_module = ' Automotive System '
FROM ` tabPublish ` where vehicle = ' {} ' and language = ' {} '
and publish_status = ' Published ' and publish_type = ' {} ' and vehicle_status = ' Active '
and publish_module = ' Automotive System '
order by version ASC ; ''' .format(v_id, lang, publish_type[0][0]), as_dict=1)
order by version ASC ; ''' .format(v_id, lang, publish_type[0][0]), as_dict=1)
if publish_type [ 0 ] [ 0 ] == " Global " :
if publish_type [ 0 ] [ 0 ] == " Global " :
@ -246,6 +249,7 @@ def check_all_vehicle_updates(vehicle_list=None):
data = frappe . db . sql ( ''' SELECT name,format(max(version),2) as version,vehicle_id,language,release_description as description FROM `tabPublish` where vehicle= ' {} ' and language= ' {} '
data = frappe . db . sql ( ''' SELECT name,format(max(version),2) as version,vehicle_id,language,release_description as description FROM `tabPublish` where vehicle= ' {} ' and language= ' {} '
and publish_status = ' Published ' and publish_type = ' Internal ' and vehicle_status = ' Active ' and version > ' {} ' and publish_module = ' Automotive System '
and publish_status = ' Published ' and publish_type = ' Internal ' and vehicle_status = ' Active ' and version > ' {} ' and publish_module = ' Automotive System '
order by version ASC ; ''' .format(v_id, lang, current_version), as_dict=1)
order by version ASC ; ''' .format(v_id, lang, current_version), as_dict=1)
# 22.06
frappe . log_error (
frappe . log_error (
' check_ful_inter ' + str ( data ) )
' check_ful_inter ' + str ( data ) )
publish_dec = frappe . db . sql ( ''' SELECT name,format(max(version),2) as version,vehicle_id,language,release_description as description FROM `tabPublish` where vehicle= ' {} ' and language= ' {} '
publish_dec = frappe . db . sql ( ''' SELECT name,format(max(version),2) as version,vehicle_id,language,release_description as description FROM `tabPublish` where vehicle= ' {} ' and language= ' {} '
@ -257,10 +261,15 @@ def check_all_vehicle_updates(vehicle_list=None):
data = frappe . db . sql ( ''' SELECT name,format(max(version),2) as version,vehicle_id,language,release_description as description FROM `tabPublish` where vehicle= ' {} ' and
data = frappe . db . sql ( ''' SELECT name,format(max(version),2) as version,vehicle_id,language,release_description as description FROM `tabPublish` where vehicle= ' {} ' and
language = ' {} ' and publish_status = ' Published ' and publish_type = ' {} ' and vehicle_status = ' Active ' and version > ' {} ' and publish_module = ' Automotive System '
language = ' {} ' and publish_status = ' Published ' and publish_type = ' {} ' and vehicle_status = ' Active ' and version > ' {} ' and publish_module = ' Automotive System '
order by version ASC ; ''' .format(v_id, lang, publish_type[0][0], current_version), as_dict=1)
order by version ASC ; ''' .format(v_id, lang, publish_type[0][0], current_version), as_dict=1)
frappe . log_error (
' check_ful_inter_else ' + str ( data ) )
publish_dec = frappe . db . sql ( ''' SELECT name,format(max(version),2) as version,vehicle_id,language,release_description as description FROM `tabPublish` where vehicle= ' {} ' and language= ' {} '
publish_dec = frappe . db . sql ( ''' SELECT name,format(max(version),2) as version,vehicle_id,language,release_description as description FROM `tabPublish` where vehicle= ' {} ' and language= ' {} '
and publish_status = ' Published ' and publish_type = ' Global ' and vehicle_status = ' Active ' and version = ' {} ' and publish_module = ' Automotive System '
and publish_status = ' Published ' and publish_type = ' Global ' and vehicle_status = ' Active ' and version = ' {} ' and publish_module = ' Automotive System '
order by version ASC ; ''' .format(v_id, lang, data1[0][ ' version ' ]), as_dict=1)
order by version ASC ; ''' .format(v_id, lang, data1[0][ ' version ' ]), as_dict=1)
# return data
# return data
else :
frappe . log_error (
' check_ful_inter_else ' )
data_append = [ ]
data_append = [ ]
rd = [ ]
rd = [ ]
try :
try :
@ -923,9 +932,11 @@ def check_all_vehicle_updates(vehicle_list=None):
current_version = float ( v [ CUR_VERSION ] )
current_version = float ( v [ CUR_VERSION ] )
data1_global = frappe . db . sql ( ''' SELECT name,format(max(version),2) as version,vehicle_id,language FROM `tabPublish` where vehicle= ' {} ' and language= ' {} '
data1_global = frappe . db . sql ( ''' SELECT name,format(max(version),2) as version,vehicle_id,language FROM `tabPublish` where vehicle= ' {} ' and language= ' {} '
and publish_status = ' Published ' and publish_type = ' Global ' and vehicle_status = ' Active '
and publish_status = ' Published ' and publish_type = ' Global ' and vehicle_status = ' Active '
and publish_module = ' Automotive System '
order by version ASC ; ''' .format(v_id, lang), as_dict=1)
order by version ASC ; ''' .format(v_id, lang), as_dict=1)
data1 = frappe . db . sql ( ''' SELECT name,format(max(version),2) as version,vehicle_id,language FROM `tabPublish` where vehicle= ' {} ' and language= ' {} '
data1 = frappe . db . sql ( ''' SELECT name,format(max(version),2) as version,vehicle_id,language FROM `tabPublish` where vehicle= ' {} ' and language= ' {} '
and publish_status = ' Published ' and publish_type = ' {} ' and vehicle_status = ' Active '
and publish_status = ' Published ' and publish_type = ' {} ' and vehicle_status = ' Active '
and publish_module = ' Automotive System '
order by version ASC ; ''' .format(v_id, lang, publish_type[0][0]), as_dict=1)
order by version ASC ; ''' .format(v_id, lang, publish_type[0][0]), as_dict=1)
if data1 [ 0 ] [ ' version ' ] is not None :
if data1 [ 0 ] [ ' version ' ] is not None :
@ -936,12 +947,14 @@ def check_all_vehicle_updates(vehicle_list=None):
if current_version < float ( data1_global [ 0 ] [ ' version ' ] ) :
if current_version < float ( data1_global [ 0 ] [ ' version ' ] ) :
data = frappe . db . sql ( ''' SELECT name,format(max(version),2) as version,vehicle_id,language FROM `tabPublish` where vehicle= ' {} ' and language= ' {} '
data = frappe . db . sql ( ''' SELECT name,format(max(version),2) as version,vehicle_id,language FROM `tabPublish` where vehicle= ' {} ' and language= ' {} '
and publish_status = ' Published ' and publish_type = ' Global ' and vehicle_status = ' Active ' and version > ' {} '
and publish_status = ' Published ' and publish_type = ' Global ' and vehicle_status = ' Active ' and version > ' {} '
and publish_module = ' Automotive System '
order by version ASC ; ''' .format(v_id, lang, current_version), as_dict=1)
order by version ASC ; ''' .format(v_id, lang, current_version), as_dict=1)
elif current_version == float ( data1_global [ 0 ] [ ' version ' ] ) :
elif current_version == float ( data1_global [ 0 ] [ ' version ' ] ) :
if current_version < float ( data1 [ 0 ] [ ' version ' ] ) :
if current_version < float ( data1 [ 0 ] [ ' version ' ] ) :
data = frappe . db . sql ( ''' SELECT name,format(max(version),2) as version,vehicle_id,language FROM `tabPublish` where vehicle= ' {} ' and
data = frappe . db . sql ( ''' SELECT name,format(max(version),2) as version,vehicle_id,language FROM `tabPublish` where vehicle= ' {} ' and
language = ' {} ' and publish_status = ' Published ' and publish_type = ' {} ' and vehicle_status = ' Active ' and version > ' {} '
language = ' {} ' and publish_status = ' Published ' and publish_type = ' {} ' and vehicle_status = ' Active ' and version > ' {} '
and publish_module = ' Automotive System '
order by version ASC ; ''' .format(v_id, lang, publish_type[0][0], current_version), as_dict=1)
order by version ASC ; ''' .format(v_id, lang, publish_type[0][0], current_version), as_dict=1)
# return data
# return data
data_append = [ ]
data_append = [ ]
@ -1002,9 +1015,9 @@ def check_vehicle_update(vehicle_list=None):
for v in vehicle_data :
for v in vehicle_data :
l_id = v [ ' LanguageID ' ]
l_id = v [ ' LanguageID ' ]
current_version = float ( v [ CUR_VERSION ] )
current_version = float ( v [ CUR_VERSION ] )
data1_global = frappe . db . sql ( ''' SELECT name,format(version,2) as version,vehicle_id,language FROM `tabPublish` where vehicle= ' {} ' and language= ' {} '
data1_global = frappe . db . sql ( ''' SELECT name,format(max( version) ,2) as version,vehicle_id,language FROM `tabPublish` where vehicle= ' {} ' and language= ' {} '
and publish_status = ' Published ' and vehicle_status = ' Active ' and publish_module = ' Automotive System '
and publish_status = ' Published ' and vehicle_status = ' Active ' and publish_module = ' Automotive System '
and version = ( select max ( version ) as version from ` tabPublish ` where publish_modul e= ' Automotive System ' and publish_type = ' {} ' )
and publish_typ e= ' Global ' ;
''' .format(vehicle, l_id,publish_type), as_dict=1)
''' .format(vehicle, l_id,publish_type), as_dict=1)
data1 = frappe . db . sql ( ''' SELECT name,format(max(version),2) as version,vehicle_id,language FROM `tabPublish` where vehicle= ' {} ' and language= ' {} ' and
data1 = frappe . db . sql ( ''' SELECT name,format(max(version),2) as version,vehicle_id,language FROM `tabPublish` where vehicle= ' {} ' and language= ' {} ' and
@ -1026,10 +1039,11 @@ def check_vehicle_update(vehicle_list=None):
if current_version < ( float ( data1_global [ 0 ] [ ' version ' ] ) - 1.00 ) :
if current_version < ( float ( data1_global [ 0 ] [ ' version ' ] ) - 1.00 ) :
data = frappe . db . sql ( ''' SELECT name as Name,format(version,2) as Version,vehicle_id as Vehicle,language as Language,release_description as description FROM `tabPublish`
data = frappe . db . sql ( ''' SELECT name as Name,format(version,2) as Version,vehicle_id as Vehicle,language as Language,release_description as description FROM `tabPublish`
where vehicle = ' {} ' and language = ' {} ' and publish_status = ' Published ' and publish_type = ' Global ' and
where vehicle = ' {} ' and language = ' {} ' and publish_status = ' Published ' and
vehicle_status = ' Active '
vehicle_status = ' Active '
and publish_module = ' Automotive System '
and publish_module = ' Automotive System '
and version = ( select max ( version ) as version from ` tabPublish ` where publish_module = ' Automotive System ' and publish_type = ' {} ' ) ; ''' .format(vehicle, l_id, publish_type), as_dict=1)
and version = ( select max ( version ) as version from ` tabPublish `
where publish_module = ' Automotive System ' and publish_type = ' Global ' ) ''' .format(vehicle, l_id, publish_type), as_dict=1)
try :
try :
for d in data :
for d in data :
try :
try :
@ -1064,9 +1078,9 @@ def check_vehicle_update(vehicle_list=None):
elif current_version == ( float ( data1_global [ 0 ] [ ' version ' ] ) - 1.00 ) :
elif current_version == ( float ( data1_global [ 0 ] [ ' version ' ] ) - 1.00 ) :
data = frappe . db . sql ( ''' SELECT name as Name,format(version,2) as Version,vehicle_id as Vehicle,language as Language,release_description as description FROM `tabPublish`
data = frappe . db . sql ( ''' SELECT name as Name,format(version,2) as Version,vehicle_id as Vehicle,language as Language,release_description as description FROM `tabPublish`
where vehicle = ' {} ' and language = ' {} ' and publish_status = ' Published ' and publish_type = ' Global ' and vehicle_status = ' Active '
where vehicle = ' {} ' and language = ' {} ' and publish_status = ' Published ' and vehicle_status = ' Active '
and publish_module = ' Automotive System '
and publish_module = ' Automotive System '
and version = ( select max ( version ) as version from ` tabPublish ` where publish_module = ' Automotive System ' and publish_type = ' {} ' ) ''' .format(vehicle, l_id, publish_type), as_dict=1)
and version = ( select max ( version ) as version from ` tabPublish ` where publish_module = ' Automotive System ' and publish_type = ' Global ' ) ''' .format(vehicle, l_id, publish_type), as_dict=1)
try :
try :
for d in data :
for d in data :
file_name = None
file_name = None
@ -1100,12 +1114,17 @@ def check_vehicle_update(vehicle_list=None):
vehicle_req_list . append (
vehicle_req_list . append (
{ ERROR : UPDATE_FAILED } )
{ ERROR : UPDATE_FAILED } )
elif current_version == float ( data1_global [ 0 ] [ ' version ' ] ) :
elif current_version == float ( data1_global [ 0 ] [ ' version ' ] ) :
""" Check For only internal """
if current_version < float ( data1 [ 0 ] [ ' version ' ] ) :
if current_version < float ( data1 [ 0 ] [ ' version ' ] ) :
data = frappe . db . sql ( ''' SELECT name as Name,format(version,2) as Version,vehicle_id as Vehicle,language as Language
data = frappe . db . sql ( ''' SELECT name as Name,format(version,2) as Version,vehicle_id as Vehicle,language as Language
FROM ` tabPublish ` where vehicle = ' {} ' and language = ' {} ' and publish_status = ' Published ' and
FROM ` tabPublish ` where vehicle = ' {} ' and language = ' {} ' and publish_status = ' Published ' and
vehicle_status = ' Active ' and publish_module = ' Automotive System '
vehicle_status = ' Active ' and publish_module = ' Automotive System '
and version = ( select max ( version ) as version from ` tabPublish ` where publish_module = ' Automotive System ' and publish_type = ' {} ' ) ''' .format(vehicle, l_id, publish_type), as_dict=1)
and version = ( select max ( version ) as version from ` tabPublish ` where publish_module = ' Automotive System ' and
publish_type = ' {} ' ) ''' .format(vehicle, l_id, publish_type), as_dict=1)
try :
try :
for d in data :
for d in data :
try :
try :