|
@ -390,13 +390,15 @@ def asset_to_files_path(): |
|
|
|
|
|
|
|
|
def change_file_dir(): |
|
|
def change_file_dir(): |
|
|
data = frappe.db.sql(''' |
|
|
data = frappe.db.sql(''' |
|
|
select name,file from tabProcedure_Details where content_type = 'File';''', as_dict=1) |
|
|
select name,file from tabProcedure_Details where content_type = 'File' where file_url = '/files/Driver Seat Back Rest Foam.jpg' ;''', as_dict=1) |
|
|
|
|
|
|
|
|
for d in data: |
|
|
for d in data: |
|
|
|
|
|
frappe.log_error("File data :", str(file_name)) |
|
|
|
|
|
|
|
|
path = os.path.join(base_url, d['file']) |
|
|
path = os.path.join(base_url, d['file']) |
|
|
isExist = os.path.exists(path) |
|
|
isExist = os.path.exists(path) |
|
|
|
|
|
frappe.log_error("Path exists :", str(isExist)) |
|
|
if not isExist: |
|
|
if not isExist: |
|
|
frappe.log_error("Invalid file:", str(path)) |
|
|
|
|
|
ext = path[-3:] |
|
|
ext = path[-3:] |
|
|
path = path[:-3] |
|
|
path = path[:-3] |
|
|
extension = '' |
|
|
extension = '' |
|
@ -405,13 +407,16 @@ def change_file_dir(): |
|
|
|
|
|
|
|
|
if ext == 'jpg': |
|
|
if ext == 'jpg': |
|
|
extension = 'png' |
|
|
extension = 'png' |
|
|
|
|
|
|
|
|
path = path[:-3] + extension |
|
|
path = path[:-3] + extension |
|
|
|
|
|
frappe.log_error("New path:", str(path)) |
|
|
if os.path.exists(path): |
|
|
if os.path.exists(path): |
|
|
file_name = d[:-3]+ extension |
|
|
file_name = d[:-3] + extension |
|
|
|
|
|
|
|
|
frappe.log_error("New file :", str(file_name)) |
|
|
frappe.log_error("New file :", str(file_name)) |
|
|
frappe.db.sql(f''' |
|
|
# frappe.db.sql(f''' |
|
|
update tabProcedure_Details set file = '{d[:-3]+ ext}' where content_type = 'File' and name = '{d['name']}'; |
|
|
# update tabProcedure_Details set file = '{d[:-3]+ ext}' where content_type = 'File' and name = '{d['name']}'; |
|
|
''') |
|
|
# ''') |
|
|
# frappe.db.commit() |
|
|
# frappe.db.commit() |
|
|
|
|
|
|
|
|
return data |
|
|
return data |
|
|