From 2f333578cba57183585fab9e7525952f85e9da83 Mon Sep 17 00:00:00 2001 From: venkataakhil Date: Tue, 23 May 2023 09:20:45 +0530 Subject: [PATCH] Publsih API --- smart_service/apis/publish_api.py | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/smart_service/apis/publish_api.py b/smart_service/apis/publish_api.py index 7f9f254..4f5dd79 100644 --- a/smart_service/apis/publish_api.py +++ b/smart_service/apis/publish_api.py @@ -248,7 +248,7 @@ def json_grouping(args, language): """ New Publish """ -@frappe.whitelist(allow_guest=True) +@frappe.whitelist() def new_publish(args, publish_type, vehicle, language, version): # rate_res = custom_rate_limit(limit=5, seconds=15) # if rate_res != 1: @@ -323,13 +323,13 @@ def new_publish(args, publish_type, vehicle, language, version): prev_full_update_file = full_update_path + vehicle + '/' + \ '%s-%s-full_v%s.json' % (vehicle, language, prev_update_ver) - # test_full_update_file_name = '/home/ubuntu/frappe-bench/sites/guidedsmartservice.com/public/files/json_files/full_update/XUV 0613/XUV 0613-en-full_update.json' - # file_flag, final_update_file = merge_json_files( - # prev_full_update_file, file_name, full_update_file_name) - # return prev_full_update_file, file_name, new_full_update_file_name - file_flag, final_update_file = new_merge_json_files( + + file_flag, final_update_file = merge_json_files( prev_full_update_file, file_name, full_update_file_name) - return file_flag, final_update_file + if file_flag: + return True, file_name.split('public')[1] + else: + return False, 'File save issue' return True, file_name.split('public')[1] except Exception as e: @@ -337,7 +337,7 @@ def new_publish(args, publish_type, vehicle, language, version): return False, str(frappe.get_traceback()) -@frappe.whitelist(allow_guest=True) +@frappe.whitelist() def merge_json_files(old_json_path, new_json_path, out_file_path): # old_json_path = '/home/ubuntu/frappe-bench/sites/guidedsmartservice.com/public/files/json_files/full_update/XUV 0613/XUV 0613-en-full_v1.0.json' # new_json_path = '/home/ubuntu/frappe-bench/sites/guidedsmartservice.com/public/files/json_files/global/XUV 0613/XUV 0613-en_v2.00.json' @@ -565,7 +565,7 @@ def merge_json_files(old_json_path, new_json_path, out_file_path): # return "Exception in publish" -@frappe.whitelist(allow_guest=True) +@frappe.whitelist() def new_merge_json_files(old_json_path, new_json_path, out_file_path): try: @@ -875,3 +875,9 @@ def upv(): # f'''update `tabPublish` set version = 1.00 where name = 'THAR-en -2023-05-21 16:57:54.119826';''') # frappe.db.commit() return 1 + + +@frappe.whitelist() +def run_publish(): + new_publish('THAR-en -2023-05-21 16:57:54.119826', + 'global', 'THAR', 'en', 1.00)