From 78a89fdb99e4b64e56a4c212ae12f460019d378b Mon Sep 17 00:00:00 2001 From: Krithi Ramani Date: Thu, 30 Sep 2021 22:20:42 +0530 Subject: [PATCH] renamed argument to file_path. Added pycups to requirements.txt --- frappe/utils/print_format.py | 10 +++++----- requirements.txt | 1 + 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/frappe/utils/print_format.py b/frappe/utils/print_format.py index cf07c010f8..0a12c1cca7 100644 --- a/frappe/utils/print_format.py +++ b/frappe/utils/print_format.py @@ -98,7 +98,7 @@ def report_to_pdf(html, orientation="Landscape"): frappe.local.response.type = "pdf" @frappe.whitelist() -def print_by_server(doctype, name, printer_setting, print_format=None, doc=None, file=None,no_letterhead=0): +def print_by_server(doctype, name, printer_setting, print_format=None, doc=None, file_path=None,no_letterhead=0): print_settings = frappe.get_doc("Network Printer Settings", printer_setting) try: import cups @@ -111,10 +111,10 @@ def print_by_server(doctype, name, printer_setting, print_format=None, doc=None, conn = cups.Connection() output = PdfFileWriter() output = frappe.get_print(doctype, name, print_format, doc=doc, no_letterhead=no_letterhead, as_pdf = True, output = output) - if not file: - file = os.path.join("/", "tmp", "frappe-pdf-{0}.pdf".format(frappe.generate_hash())) - output.write(open(file,"wb")) - conn.printFile(print_settings.printer_name,file , name, {}) + if not file_path: + file_path = os.path.join("/", "tmp", "frappe-pdf-{0}.pdf".format(frappe.generate_hash())) + output.write(open(file_path,"wb")) + conn.printFile(print_settings.printer_name,file_path , name, {}) except IOError as e: if ("ContentNotFoundError" in e.message or "ContentOperationNotPermittedError" in e.message diff --git a/requirements.txt b/requirements.txt index a0ad0b6266..1a4a1b6617 100644 --- a/requirements.txt +++ b/requirements.txt @@ -77,3 +77,4 @@ wrapt~=1.12.1 xlrd~=2.0.1 zxcvbn-python~=4.4.24 tenacity~=8.0.1 +pycups