Browse Source

check_vehicle_update api update

version2
venkataakhil 1 year ago
parent
commit
260b1ab2c9
  1. 658246
      smart_service/apis/THAR-en-full_v12.00.json
  2. 507
      smart_service/apis/update_validation.py

658246
smart_service/apis/THAR-en-full_v12.00.json

File diff suppressed because it is too large

507
smart_service/apis/update_validation.py

@ -13,10 +13,10 @@ base_url = os.path.expanduser(
current_db_name = frappe.conf.get("db_name")
# Constants
JSON_EXT = ".json"
# JSON_INT_PATH = "/files/json_files/internal/"
JSON_INT_PATH = "/files/json_files/full_update/internal/"
JSON_INT_PATH = "/files/json_files/internal/"
JSON_FULL_INT_PATH = "/files/json_files/full_update/internal/"
JSON_GLOABL_PATH = "/files/json_files/global/"
JSON_FULL_UPDATE_PATH = base_url+"/files/json_files/full_update/internal/"
JSON_FULL_UPDATE_PATH = "/files/json_files/full_update/"
STATUS = "status"
ERROR = "error"
UPDATE_AVAILABLE = 'IsUpdateAvailable'
@ -24,7 +24,7 @@ UPDATE_FAILED = "Update checking Failed"
PARAM_MISSING = "Parameter missing :"
VERSION = 'Version'
CUR_VERSION = 'CurrentVersion'
DIS ='Discription'
DIS = 'Discription'
FILE_ERROR = 'File failed to load'
LANGUAGE = 'Language'
FILE_SIZE = 'FileSize'
@ -66,7 +66,7 @@ def get_parent_map(input_list, parameter):
return list1, steps_length
@frappe.whitelist(allow_guest = 1)
@frappe.whitelist(allow_guest=1)
def check_all_vehicle_updates1(vehicle_list=None):
rate_res = custom_rate_limit(limit=5, seconds=15)
if rate_res != 1:
@ -144,7 +144,7 @@ def check_all_vehicle_updates1(vehicle_list=None):
response['LanguageID'] = lang
if len(vehicle_req_list) != 0:
data = [vu[0] for vu in vehicle_req_list]
data = [vu[0] for vu in vehicle_req_list]
frappe.log_error(str(data))
# publish_dec_txt = [pd[0] for pd in publish_dec]
response['VehicleReqList'] = data
@ -163,6 +163,7 @@ def check_all_vehicle_updates1(vehicle_list=None):
else:
return {STATUS: 0, ERROR: "Check argument: vehicle list"}
@frappe.whitelist()
def check_all_vehicle_updates(vehicle_list=None):
frappe.log_error('request' + str(vehicle_list))
@ -207,7 +208,8 @@ 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='{}'
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)
frappe.log_error('global_publish' + str(data))
frappe.log_error(
'global_publish' + 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='{}'
# 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_global[0]['version']), as_dict=1)
@ -244,7 +246,8 @@ 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='{}'
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)
frappe.log_error('check_ful_inter' + str(data))
frappe.log_error(
'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='{}'
# 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, data1_global[0]['version']), as_dict=1)
@ -280,7 +283,7 @@ def check_all_vehicle_updates(vehicle_list=None):
response['LanguageID'] = lang
if len(vehicle_req_list) != 0:
data = [vu[0] for vu in vehicle_req_list]
data = [vu[0] for vu in vehicle_req_list]
response['VehicleReqList'] = data
# response['release_description'] = publish_dec_txt['release_description']
return response
@ -297,7 +300,8 @@ def check_all_vehicle_updates(vehicle_list=None):
else:
return {STATUS: 0, ERROR: "Check argument: vehicle list"}
@frappe.whitelist(allow_guest = 1)
@frappe.whitelist(allow_guest=1)
def check_vehicle_update1(vehicle_list=None):
rate_res = custom_rate_limit(limit=5, seconds=15)
if rate_res != 1:
@ -331,7 +335,6 @@ def check_vehicle_update1(vehicle_list=None):
and publish_status='Published' and publish_type='Global' and vehicle_status='Active' and publish_module='Automotive System'
order by version ASC;'''.format(vehicle, l_id), 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='{}' and
publish_status='Published' and vehicle_status='Active' and
@ -357,13 +360,16 @@ def check_vehicle_update1(vehicle_list=None):
try:
for d in data:
try:
file_name =JSON_FULL_UPDATE_PATH+vehicle+"/"+vehicle + \
file_name = JSON_FULL_UPDATE_PATH+vehicle+"/"+vehicle + \
"-" + \
d[LANGUAGE]+"-"+"full_v" + \
str(d[VERSION])+JSON_EXT
frappe.log_error("name"+str(file_name))
file_size = os.path.getsize(file_name)
frappe.log_error("size"+str(file_size))
frappe.log_error(
"name"+str(file_name))
file_size = os.path.getsize(
file_name)
frappe.log_error(
"size"+str(file_size))
d[JSON_URL] = file_name
d[FILE_SIZE] = file_size
d['Error'] = None
@ -548,10 +554,11 @@ def check_vehicle_update1(vehicle_list=None):
try:
for d in data:
try:
file_name = JSON_INT_PATH+vehicle+"/" + \
file_name = JSON_INT_PATH+vehicle+"/" + \
vehicle+"-"+d[LANGUAGE] + \
"-full_v"+str(d[VERSION])+JSON_EXT
frappe.log_error('full_inernal' +str(file_name))
frappe.log_error(
'full_inernal' + str(file_name))
file_size = os.path.getsize(
base_url + file_name)
d[JSON_URL] = file_name
@ -585,8 +592,9 @@ def check_vehicle_update1(vehicle_list=None):
else:
return {STATUS: 0, ERROR: "Check Parameter: vehicle list"}
@frappe.whitelist()
def check_vehicle_update(vehicle_list=None):
@frappe.whitelist(allow_guest=1)
def check_vehicle_update_error(vehicle_list=None):
rate_res = custom_rate_limit(limit=5, seconds=15)
if rate_res != 1:
return rate_res
@ -614,20 +622,26 @@ def check_vehicle_update(vehicle_list=None):
for v in vehicle_data:
l_id = v['LanguageID']
current_version = float(v[CUR_VERSION])
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'
order by version ASC;'''.format(vehicle, l_id), as_dict=1)
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'
order by version ASC;'''.format(vehicle, l_id), as_dict=1)
frappe.log_error('global_req'+ str(data1_global))
# 22
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='{}' and
publish_status='Published' and vehicle_status='Active' and
publish_module='Automotive System'
order by version ASC;'''.format(vehicle, l_id), as_dict=1)
# 22.04
if data1_global[0]['version'] and publish_type == 'Global':
if data1[0]['version'] is not None:
frappe.log_error('inside')
if current_version == float(data1[0]['version']):
frappe.log_error('inside1')
data1[0][UPDATE_AVAILABLE] = "false"
data = {}
data[LANGUAGE] = l_id
@ -637,21 +651,25 @@ def check_vehicle_update(vehicle_list=None):
else:
if current_version < (float(data1_global[0]['version'])-1.00):
frappe.log_error('inside2')
data = frappe.db.sql('''SELECT name as Name,version 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'
and Version > '{}'
and publish_module='Automotive System' order by version DESC limit 1;'''.format(vehicle, l_id, current_version), as_dict=1)
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' order by version DESC limit 1;'''
.format(vehicle, l_id, current_version), as_dict=1)
try:
for d in data:
try:
file_name =JSON_FULL_UPDATE_PATH+vehicle+"/"+vehicle + \
file_name = JSON_FULL_UPDATE_PATH+vehicle+"/"+vehicle + \
"-" + \
d[LANGUAGE]+"-"+"full_v" + \
str(d[VERSION])+JSON_EXT
frappe.log_error("name"+str(file_name))
file_size = os.path.getsize(file_name)
frappe.log_error("size"+str(file_size))
# frappe.log_error(
# "name "+str(file_name))
file_size = os.path.getsize(
file_name)
# frappe.log_error(
# "size"+str(file_size))
d[JSON_URL] = file_name
d[FILE_SIZE] = file_size
d['Error'] = None
@ -673,6 +691,7 @@ def check_vehicle_update(vehicle_list=None):
{ERROR: UPDATE_FAILED})
elif current_version == (float(data1_global[0]['version'])-1.00):
frappe.log_error('inside3')
data = frappe.db.sql('''SELECT name as Name,format(max(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'
and Version > '{}' and publish_module='Automotive System'
@ -836,10 +855,11 @@ def check_vehicle_update(vehicle_list=None):
try:
for d in data:
try:
file_name = JSON_INT_PATH+vehicle+"/" + \
file_name = JSON_INT_PATH+vehicle+"/" + \
vehicle+"-"+d[LANGUAGE] + \
"-full_v"+str(d[VERSION])+JSON_EXT
frappe.log_error('full_inernal' +str(file_name))
frappe.log_error(
'full_inernal' + str(file_name))
file_size = os.path.getsize(
base_url + file_name)
d[JSON_URL] = file_name
@ -860,7 +880,7 @@ def check_vehicle_update(vehicle_list=None):
except Exception as e2:
vehicle_req_list.append(
{ERROR: UPDATE_FAILED})
if len(vehicle_req_list)!=0:
if len(vehicle_req_list) != 0:
response['Vehicle'] = vehicle
response['VehicleReqList'] = vehicle_req_list
return response
@ -873,6 +893,423 @@ def check_vehicle_update(vehicle_list=None):
else:
return {STATUS: 0, ERROR: "Check Parameter: vehicle list"}
@frappe.whitelist()
def check_all_vehicle_updates(vehicle_list=None):
rate_res = custom_rate_limit(limit=5, seconds=15)
if rate_res != 1:
return rate_res
# if vehicle_list == None:
# return {STATUS: 0, ERROR: "Parameter missing: Vehicle List"}
val = input_validation(vehicle_list=vehicle_list)
if val != '':
return {STATUS: 0, ERROR: PARAM_MISSING+val}
if vehicle_list:
try:
vehicle_req_list = []
response = {}
v_list = json.loads(vehicle_list)
lang = v_list['LanguageID']
iid = v_list['InstallationId']
vehicle_data = v_list['VehicleReqList']
publish_type = frappe.db.sql(
'''SELECT publish_type FROM `tabApp Device` where name='{}';'''.format(iid), as_list=1)
if publish_type[0][0] is not None:
if vehicle_data:
for v in vehicle_data:
v_id = v['Vehicle']
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='{}'
and publish_status='Published' and publish_type='Global' and vehicle_status='Active'
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='{}'
and publish_status='Published' and publish_type='{}' and vehicle_status='Active'
order by version ASC;'''.format(v_id, lang, publish_type[0][0]), as_dict=1)
if data1[0]['version'] is not None:
if current_version == float(data1[0]['version']):
data1[0][UPDATE_AVAILABLE] = "false"
vehicle_req_list.append(data1)
else:
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='{}'
and publish_status='Published' and publish_type='Global' and vehicle_status='Active' and version > '{}'
order by version ASC;'''.format(v_id, lang, current_version), as_dict=1)
elif current_version == float(data1_global[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
language='{}' and publish_status='Published' and publish_type='{}' and vehicle_status='Active' and version > '{}'
order by version ASC;'''.format(v_id, lang, publish_type[0][0], current_version), as_dict=1)
# return data
data_append = []
try:
for d in data:
d[UPDATE_AVAILABLE] = 'true'
d[CUR_VERSION] = float(
current_version)
data_append.append(d)
vehicle_req_list.append(data_append)
except:
pass
response['LanguageID'] = lang
if len(vehicle_req_list) != 0:
response['VehicleReqList'] = vehicle_req_list[0]
return response
else:
return {STATUS: 0, ERROR: "No Vehicles in criteria"}
else:
return {STATUS: 0, ERROR: "Invalid Publish Details"}
else:
return {STATUS: 0, ERROR: "Invalid Publish Details"}
except Exception as e:
return {STATUS: 0, ERROR: "Failed to fetch updates"}
else:
return {STATUS: 0, ERROR: "Check argument: vehicle list"}
@frappe.whitelist(allow_guest=1)
def check_vehicle_update(vehicle_list=None):
rate_res = custom_rate_limit(limit=5, seconds=15)
if rate_res != 1:
return rate_res
# if vehicle_list == None:
# return {STATUS: 0, ERROR: "Parameter missing: Vehicle List"}
val = input_validation(vehicle_list=vehicle_list)
if val != '':
return {STATUS: 0, ERROR: PARAM_MISSING+val}
if vehicle_list:
try:
response = {}
req_list = json.loads(vehicle_list)
response['Vehicle'] = req_list['Vehicle']
vehicle = req_list['Vehicle']
iid = req_list['InstallationId']
vehicle_data = req_list['VehicleReqList']
publish_type = frappe.db.get_list(
'App Device', filters={'name': iid}, fields='publish_type')
if len(publish_type) > 0:
publish_type = publish_type[0]['publish_type']
vehicle_req_list = []
# Iterate on language
for v in vehicle_data:
l_id = v['LanguageID']
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='{}'
and publish_status='Published' and 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)
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 vehicle_status='Active' and
publish_module='Automotive System'
order by version ASC;'''.format(vehicle, l_id), as_dict=1)
if data1_global[0]['version']:
if data1[0]['version'] is not None:
if current_version == float(data1[0]['version']):
data1[0][UPDATE_AVAILABLE] = "false"
data = {}
data[LANGUAGE] = l_id
data[UPDATE_AVAILABLE] = 'false'
data[CUR_VERSION] = 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,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'
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)
try:
for d in data:
try:
file_name = JSON_FULL_UPDATE_PATH+vehicle+"/"+vehicle + \
"-" + \
d[LANGUAGE]+"-"+"full_v" + \
str(d[VERSION])+JSON_EXT
file_size = os.path.getsize(
base_url + file_name)
d[JSON_URL] = file_name
d[FILE_SIZE] = file_size
d['Error'] = None
d[UPDATE_AVAILABLE] = 'true'
except Exception as e:
frappe.log_error(
'error1', str(e))
file_name = None
file_size = None
d[JSON_URL] = file_name
d[FILE_SIZE] = file_size
d['Error'] = e
d[UPDATE_AVAILABLE] = 'false'
d[CUR_VERSION] = float(
current_version)
vehicle_req_list.append(d)
except Exception as e:
frappe.log_error('error 2', str(e))
vehicle_req_list.append(
{ERROR: UPDATE_FAILED})
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`
where vehicle='{}' and language='{}' and publish_status='Published' and publish_type='Global' and 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)
try:
for d in data:
file_name = None
try:
file_name = JSON_GLOABL_PATH+vehicle+"/" + \
vehicle+"-" + \
d[LANGUAGE]+"_v" + \
str(d[VERSION])+JSON_EXT
file_size = os.path.getsize(
base_url + file_name)
d[JSON_URL] = file_name
d[FILE_SIZE] = file_size
d['Error'] = None
d[UPDATE_AVAILABLE] = 'true'
except Exception as e:
frappe.log_error(
'error 3', str(e))
# file_name= None
file_size = None
d[JSON_URL] = file_name
d[FILE_SIZE] = file_size
d['Error'] = e
d[UPDATE_AVAILABLE] = 'false'
d[CUR_VERSION] = float(
current_version)
vehicle_req_list.append(d)
except Exception as e1:
frappe.log_error('error 4', str(e))
vehicle_req_list.append(
{ERROR: UPDATE_FAILED})
elif current_version == float(data1_global[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
FROM `tabPublish` where vehicle='{}' and language='{}' and publish_status='Published' and
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)
try:
for d in data:
try:
if float(data1[0]['version']) - current_version > 0.01:
frappe.log_error(
'file error 1', JSON_FULL_INT_PATH + vehicle+"/" + vehicle+"-" + d[LANGUAGE]+"-full_v" + str(d[VERSION]) + JSON_EXT)
file_name = JSON_FULL_INT_PATH + vehicle+"/" + \
vehicle+"-" + \
d[LANGUAGE]+"-full_v" + \
str(d[VERSION]) + \
JSON_EXT
frappe.log_error(
'File 1 ', file_name)
file_size = os.path.getsize(
base_url + file_name)
d[JSON_URL] = file_name
d[FILE_SIZE] = file_size
d['Error'] = None
d[UPDATE_AVAILABLE] = 'true'
else:
file_name = JSON_INT_PATH+vehicle+"/" + \
vehicle+"-" + \
d[LANGUAGE]+"_v" + \
str(d[VERSION]) + \
JSON_EXT
file_size = os.path.getsize(
base_url + file_name)
d[JSON_URL] = file_name
d[FILE_SIZE] = file_size
d['Error'] = None
d[UPDATE_AVAILABLE] = 'true'
except Exception as e:
frappe.log_error(
'error 5', str(e))
file_name = None
file_size = None
d[JSON_URL] = file_name
d[FILE_SIZE] = file_size
d['Error'] = e
d[UPDATE_AVAILABLE] = 'false'
d[CUR_VERSION] = float(
current_version)
vehicle_req_list.append(d)
except Exception as e2:
frappe.log_error('error 6', str(e))
vehicle_req_list.append(
{ERROR: UPDATE_FAILED})
elif (float(data1_global[0]['version'])-1.00) < current_version < float(data1_global[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,release_description as description FROM `tabPublish`
where vehicle='{}' and language='{}' and publish_status='Published' and 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)
try:
for d in data:
try:
file_name = JSON_GLOABL_PATH+vehicle+"/" + \
vehicle+"-" + \
d[LANGUAGE]+"_v" + \
str(d[VERSION]) + \
JSON_EXT
file_size = os.path.getsize(
base_url + file_name)
d[JSON_URL] = file_name
d[FILE_SIZE] = file_size
d['Error'] = None
d[UPDATE_AVAILABLE] = 'true'
except Exception as e:
frappe.log_error(
'error 7', str(e))
file_name = JSON_GLOABL_PATH+vehicle+"/" + \
vehicle+"-" + \
d[LANGUAGE]+"_v" + \
str(d[VERSION]) + \
JSON_EXT
file_size = None
d[JSON_URL] = file_name
d[FILE_SIZE] = file_size
d['Error'] = e
d[UPDATE_AVAILABLE] = 'false'
d[CUR_VERSION] = float(
current_version)
vehicle_req_list.append(d)
except Exception as e2:
frappe.log_error('error 8', str(e))
vehicle_req_list.append(
{ERROR: UPDATE_FAILED})
elif current_version > float(data1_global[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 FROM `tabPublish`
where vehicle='{}' and language='{}' and publish_status='Published' and 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)
try:
for d in data:
try:
if float(data1[0]['version']) - current_version > 0.01:
file_name = JSON_FULL_INT_PATH + vehicle+"/" + \
vehicle+"-" + \
d[LANGUAGE]+"-full_v" + \
str(d[VERSION]) + \
JSON_EXT
frappe.log_error(
'File 2 ', file_name)
file_size = os.path.getsize(
base_url + file_name)
d[JSON_URL] = file_name
d[FILE_SIZE] = file_size
d['Error'] = None
d[UPDATE_AVAILABLE] = 'true'
else:
file_name = JSON_INT_PATH+vehicle+"/" + \
vehicle+"-" + \
d[LANGUAGE]+"_v" + \
str(d[VERSION]) + \
JSON_EXT
file_size = os.path.getsize(
base_url + file_name)
d[JSON_URL] = file_name
d[FILE_SIZE] = file_size
d['Error'] = None
d[UPDATE_AVAILABLE] = 'true'
except Exception as e:
frappe.log_error(
'error 9', str(e))
file_name = JSON_INT_PATH+vehicle+"/" + \
vehicle+"-" + \
d[LANGUAGE]+"_v" + \
str(d[VERSION]) + \
JSON_EXT
file_size = None
d[JSON_URL] = file_name
d[FILE_SIZE] = file_size
d['Error'] = e
d[UPDATE_AVAILABLE] = 'false'
d[CUR_VERSION] = float(
current_version)
vehicle_req_list.append(d)
except Exception as e3:
frappe.log_error(
'error 10', str(e))
vehicle_req_list.append(
{'Error': UPDATE_FAILED})
# else:
# vehicle_req_list.append({'Error':"Else 3"})
else:
vehicle_req_list.append(
{LANGUAGE: l_id, UPDATE_AVAILABLE: 'false', CUR_VERSION: float(current_version)})
else:
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 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)
try:
for d in data:
try:
file_name = JSON_INT_PATH+vehicle+"/" + \
vehicle+"-"+d[LANGUAGE] + \
"_v"+str(d[VERSION])+JSON_EXT
file_size = os.path.getsize(
base_url + file_name)
d[JSON_URL] = file_name
d[FILE_SIZE] = file_size
d['Error'] = None
d[UPDATE_AVAILABLE] = 'true'
except:
frappe.log_error('error 11', str(e))
file_name = None
file_size = None
d[JSON_URL] = file_name
d[FILE_SIZE] = file_size
d['Error'] = FILE_ERROR
d[UPDATE_AVAILABLE] = 'false'
d[CUR_VERSION] = float(current_version)
vehicle_req_list.append(d)
except Exception as e2:
frappe.log_error('error 12', str(e))
vehicle_req_list.append(
{ERROR: UPDATE_FAILED})
response['Vehicle'] = vehicle
response['VehicleReqList'] = vehicle_req_list
return response
else:
response['JSON'] = {STATUS: 0, ERROR: "Data Not available"}
return response
except Exception as e:
response['JSON'] = {STATUS: 0, ERROR: UPDATE_FAILED}
return response
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)

Loading…
Cancel
Save