Compare commits

...

2 Commits

Author SHA1 Message Date
venkataakhil 04c16f8dcf Remove extra spaces in file path 2 years ago
venkataakhil ed676ff723 To get missing file list 2 years ago
  1. 38
      smart_service/apis/master_api.py

38
smart_service/apis/master_api.py

@ -16,6 +16,9 @@ site_name = cstr(frappe.local.site)
base_url = os.path.expanduser(
"~") + "/frappe-bench/sites/" + site_name + "/public/files"
base_path = os.path.expanduser(
"~") + "/frappe-bench/sites/" + site_name + "/public"
@frappe.whitelist(allow_guest=True)
def masters1():
@ -429,3 +432,38 @@ def change_file_dir():
return file_data
else:
return "Done"
def file_not_exists():
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
def remove_extra_spacces_in_file_path():
import re
file_path_not_exists = base_path + "/files/json_files/1.json"
with open(file_path_not_exists, 'r') as outfile:
data = json.load(outfile)
for d in data:
res_str = re.sub("/files/ /", "/files/", d['file'])
res_str = re.sub("/files/ ", "/files/", res_str)
frappe.db.sql(f'''
update tabProcedure_Details set file = '{res_str}' where name = '{d['name']}';
''')
frappe.db.commit()

Loading…
Cancel
Save