From ed676ff723c7de6298005af601ed86aae21e5355 Mon Sep 17 00:00:00 2001 From: venkataakhil Date: Wed, 19 Apr 2023 13:09:38 +0530 Subject: [PATCH] To get missing file list --- smart_service/apis/master_api.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/smart_service/apis/master_api.py b/smart_service/apis/master_api.py index 6147835..0bf8bfd 100644 --- a/smart_service/apis/master_api.py +++ b/smart_service/apis/master_api.py @@ -429,3 +429,25 @@ def change_file_dir(): return file_data else: return "Done" + + +def file_not_exists(): + base_path = os.path.expanduser( + "~") + "/frappe-bench/sites/" + site_name + "/public" + file_data = frappe.db.sql(''' + select parent,step_name,file from tabProcedure_Details where content_type = 'File' order by parent; ;''', as_dict=1) + + changed_file_list = [] + for d in file_data: + path = d['file'] + isExist = os.path.exists(base_path + path) + + if not isExist: + changed_file_list.append(d) + + file_path_not_exists = base_path + "/files/json_files/1.json" + with open(file_path_not_exists, 'w') as outfile: + try: + outfile.write(json.dumps(changed_file_list)) + except Exception as e: + pass