def attach_file_test(html_,path_data): import easywebdav a=webnotes.conn.sql("select value from `tabSingles` where doctype='LDAP Settings' and field='dms_server'",as_list=1) if a: webdav = easywebdav.connect(a[0][0],username='******',password='******') import io name=path_data[0] path=cstr(path_data[0]).replace("/","") f = io.open("files/"+path+".html", 'w', encoding='utf8') f.write(html_) f.close() s=auth() if s[0]=="Done": dms_path=webnotes.conn.sql("select value from `tabSingles` where doctype='LDAP Settings' and field='dms_path'",as_list=1) check_status=webnotes.conn.sql("select file_url from `tabFile Data` where file_url='"+dms_path[0][0]+path_data[1]+"/"+path+".html"+"'",as_list=1) if not check_status: webdav.upload("files/"+path+".html",'/doxbox/OwlWebDav/index.php/'+path_data[1]+"/"+path+".html") file_attach=Document("File Data") file_attach.file_name="files/"+path+".html" file_attach.attached_to_doctype=path_data[2] file_attach.file_url=dms_path[0][0]+path_data[1]+"/"+path+".html" file_attach.attached_to_name=name file_attach.save() os.remove("files/"+path+".html") return "File Save Sucessfully" else: return "File Already Exist" else: return s[1] else: return ["Error","Server is not defined"]
def attach_file(a,path_data): import easywebdav #path=self.file_name(path_data[0]) #html_file= open(path[0],"w") import io html_=a name=path_data[0] path=cstr(path_data[0]).replace("/","") f = io.open("files/"+path+".html", 'w', encoding='utf8') f.write(a) f.close() s=auth() if s[0]=="Done": path_name=create_path(nowdate(),path_data[1],s[1]) check_status=sql("select file_url from `tabFile Data` where file_url='"+path_name+"/"+path+".html"+"'",as_list=1) if not check_status: document_attach("files/"+path+".html",path_name+"/"+path+".html",s[1],"upload") file_attach=Document("File Data") file_attach.file_name="files/"+path+".html" file_attach.attached_to_doctype=path_data[2] file_attach.file_url=path_name+"/"+path+".html" file_attach.attached_to_name=name file_attach.save() os.remove("files/"+path+".html") return path_name+"/"+path+".html" else: return "File Already Exist" else: return s[1]