def getHtmlFilepath(report_name, fileName): jsr = jasper_session_obj or Jr.JasperRoot() path_jasper_module = os.path.dirname(jasper_erpnext_report.__file__) html_reports_path = get_html_reports_path(report_name, hash=jsr.html_hash) full_path = os.path.join(html_reports_path, fileName) relat_path = os.path.relpath(full_path, os.path.join(path_jasper_module, "public")) return os.path.join("jasper_erpnext_report",relat_path)
def get_email_pdf_path(report_name, reqId, site=None): site = site or frappe.local.site file_path = get_html_reports_path(report_name, where="reports", hash=reqId, localsite=site) return file_path
def get_html_path(self, report_name, localsite=None, content=None): import hashlib site = localsite or frappe.local.site if not self.html_hash: hash_obj = hashlib.md5(frappe.utils.encode(content)) self.html_hash = hash_obj.hexdigest() self.report_html_path = get_html_reports_path(report_name, localsite=site, hash=self.html_hash) return self.report_html_path
def getAttachments(self, reqId, expId, expIdObj, report_name): for attach in expIdObj.get('attachments',[]): attachFileName = attach.get("fileName") content = self.jps.getAttachment(reqId, expId, attachFileName) from jasper_erpnext_report.utils.file import get_html_reports_images_path, get_html_reports_path report_path = get_html_reports_path(report_name, hash=self.html_hash) image_path = get_html_reports_images_path(report_path) write_file(content.content, os.path.join(image_path, attachFileName), "wb")
def _get_report(data): jasper_run_method("jasper_before_get_report", data) jsr = jasper_session_obj or Jr.JasperRoot() fileName, content, report_name = jsr.get_report_server(data) pformat = data.get("pformat") if pformat == "html": html_reports_path = get_html_reports_path(report_name, hash=jsr.html_hash) write_file(content[0], os.path.join(html_reports_path, fileName)) return fileName, content, report_name