MCPcopy
hub / github.com/RUB-NDS/PRET / do_print

Method do_print

printer.py:802–820  ·  view source on GitHub ↗

Print image file or raw text: print |"text

(self, arg)

Source from the content-addressed store, hash-verified

800
801 # ------------------------[ print <file>|"text" ]----------------------------
802 def do_print(self, arg):
803 'Print image file or raw text: print <file>|"text"'
804 """
805 ┌──────────────────────────────────────────────────────────┐
806 │ Poor man&#x27;s driverless printing (PCL based, experimental) │
807 └──────────────────────────────────────────────────────────┘
808 """
809 if not arg:
810 arg = eval(input('File or "text": '))
811 if arg.startswith('"'):
812 data = arg.strip('"') # raw text string
813 elif arg.endswith(".ps"):
814 data = file().read(arg) # postscript file
815 else:
816 data = self.convert(arg, "pcl") # anything else…
817 data = c.UEL.encode() + data + c.UEL.encode()
818 if data:
819 self.send(data) # send pcl datastream to printer
820 print("H")
821
822 # convert image to page description language
823 def convert(self, path, pdl="pcl"):

Callers

nothing calls this directly

Calls 4

convertMethod · 0.95
sendMethod · 0.95
fileClass · 0.90
readMethod · 0.80

Tested by

no test coverage detected