|
|
@ -3,6 +3,7 @@ from frappe.model.document import Document |
|
|
|
import json |
|
|
|
import os |
|
|
|
from frappe.utils import cstr |
|
|
|
import time |
|
|
|
|
|
|
|
current_db_name = frappe.conf.get("db_name") |
|
|
|
site_name = cstr(frappe.local.site) |
|
|
@ -86,6 +87,7 @@ def check_all_vehicle_updates(vehicle_list=None): |
|
|
|
|
|
|
|
@frappe.whitelist() |
|
|
|
def check_vehicle_update(vehicle_list=None): |
|
|
|
t1 = time.time() |
|
|
|
if vehicle_list == None: |
|
|
|
return {"status": 0, "error": "Parameter missing: Vehicle List"} |
|
|
|
if vehicle_list: |
|
|
@ -114,11 +116,11 @@ def check_vehicle_update(vehicle_list=None): |
|
|
|
current_version = v['CurrentVersion'] |
|
|
|
if publish_type == 'Internal': |
|
|
|
publish_data = frappe.db.sql('''select name,CAST(version AS DECIMAL(10,2)) as version from {}.tabPublish where vehicle= '{}' |
|
|
|
and language='{}' and publish_type = '{}' and version > {} and vehicle_status = 'Active'; |
|
|
|
'''.format(current_db_name, vehicle, l_id, publish_type, current_version), as_dict=True) |
|
|
|
and language='{}' and version > {} and vehicle_status = 'Active'; |
|
|
|
'''.format(current_db_name, vehicle, l_id, current_version), as_dict=True) |
|
|
|
else: |
|
|
|
publish_data = frappe.db.sql('''select name,version,release_description as description from {}.tabPublish where vehicle= '{}' |
|
|
|
and language='{}' and publish_type= '{}' and version > {} and vehicle_status = 'Active'; '''.format( |
|
|
|
and language='{}' and publish_type = '{}' and version > {} and vehicle_status = 'Active'; '''.format( |
|
|
|
current_db_name, vehicle, l_id, publish_type, |
|
|
|
current_version), as_dict=True) |
|
|
|
|
|
|
@ -310,10 +312,13 @@ def check_vehicle_update(vehicle_list=None): |
|
|
|
outfile.write(json.dumps(dicfinal)) |
|
|
|
|
|
|
|
file_size = os.path.getsize(base_url + file_name) |
|
|
|
|
|
|
|
res['JsonURL'] = file_name |
|
|
|
res['FileSize'] = file_size |
|
|
|
res['Error'] = None |
|
|
|
|
|
|
|
t2 = time.time() |
|
|
|
res['time'] = t2-t1 |
|
|
|
|
|
|
|
except: |
|
|
|
res['JsonURL'] = None |
|
|
|
res['FileSize'] = None |
|
|
@ -324,6 +329,8 @@ def check_vehicle_update(vehicle_list=None): |
|
|
|
Vehicle_req_list.append( |
|
|
|
{'Language': l_id, 'IsUpdateAvailable': 'false', 'CurrentVersion': float(current_version)}) |
|
|
|
response['Vehicle'] = vehicle |
|
|
|
|
|
|
|
|
|
|
|
response['VehicleReqList'] = Vehicle_req_list |
|
|
|
return response |
|
|
|
|
|
|
|