fix
This commit is contained in:
parent
8ec46fdde4
commit
27e3b095a2
@ -64,16 +64,14 @@ class Os_Label_Printer(Component):
|
|||||||
label_file = "tmp/label.prn"
|
label_file = "tmp/label.prn"
|
||||||
with open(label_file, "w", errors="surrogateescape") as f:
|
with open(label_file, "w", errors="surrogateescape") as f:
|
||||||
f.write(label_file_contents)
|
f.write(label_file_contents)
|
||||||
if self.platform == "windows":
|
if platform.system().lower() == "windows":
|
||||||
cmd = f'print /d:"{self.printer}" "{label_file}"'
|
cmd = f'print /d:"{self.printer}" "{label_file}"'
|
||||||
elif self.platform == "cups":
|
|
||||||
cmd = f'lp -d "{self.printer}" "{label_file}"'
|
|
||||||
else:
|
else:
|
||||||
raise NotImplementedError(f"platform {self.platform!r} is not supported")
|
cmd = f'lp -d "{self.printer}" "{label_file}"'
|
||||||
if not self.simulate:
|
if not self.simulate:
|
||||||
p = subprocess.run(cmd, stderr=subprocess.STDOUT, stdout=subprocess.PIPE, shell=True) # unsafe
|
p = subprocess.run(cmd, stderr=subprocess.STDOUT, stdout=subprocess.PIPE, shell=True) # unsafe
|
||||||
if p.returncode != 0:
|
if p.returncode != 0:
|
||||||
self.log.exception(f"failed to print: returncode: {p.returncode}\noutput:\n{p.stdout}")
|
self.log.exception(f"failed to print: return code: {p.returncode}\noutput:\n{p.stdout}")
|
||||||
QMessageBox.critical(
|
QMessageBox.critical(
|
||||||
None,
|
None,
|
||||||
"Errore Stampante",
|
"Errore Stampante",
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user