Browse Source

Fix path ext issue

master
venkataakhil 2 years ago
parent
commit
573b80211c
  1. 15
      smart_service/apis/master_api.py

15
smart_service/apis/master_api.py

@ -393,26 +393,21 @@ def change_file_dir():
select name,file from tabProcedure_Details where content_type = 'File';''', as_dict=1)
for d in data:
frappe.log_error("Inside Loop", str(d))
path = os.path.join(base_url, d['file'])
isExist = os.path.exists(path)
if not isExist:
frappe.log_error("Invalid file:", str(path))
ext = path[-3:]
path = path[:-3]
extension = ''
if ext == 'png':
ext == 'jpg'
extension = 'jpg'
if ext == 'jpg':
ext == 'png'
path = path[:-3] + ext
extension = 'png'
path = path[:-3] + extension
if os.path.exists(path):
file_name = d[:-3]+ ext
frappe.log_error("Valid file validation:", str(path))
file_name = d[:-3]+ extension
frappe.log_error("New file :", str(file_name))
frappe.db.sql(f'''
update tabProcedure_Details set file = '{d[:-3]+ ext}' where content_type = 'File' and name = '{d['name']}';

Loading…
Cancel
Save