This commit is contained in:
neo-dl 2023-09-03 10:00:31 +02:00
parent 8ec46fdde4
commit 27e3b095a2

View File

@ -64,12 +64,10 @@ 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: