(self, str_send, fb=True, crop=True, binary=False)
| 20 | # -------------------------------------------------------------------- |
| 21 | # send PostScript command to printer, optionally receive response |
| 22 | def cmd(self, str_send, fb=True, crop=True, binary=False): |
| 23 | str_recv = "" # response buffer |
| 24 | if self.iohack: |
| 25 | str_send = '{' + str_send + '} stopped' # br-script workaround |
| 26 | # unique response delimiter |
| 27 | token = c.DELIMITER + str(random.randrange(2**16)) |
| 28 | iohack = c.PS_IOHACK if self.iohack else '' # optionally include output hack |
| 29 | # additional line feed necessary |
| 30 | footer = '\n(' + token + '\\n) print flush\n' |
| 31 | # send command to printer device # to get output on some printers |
| 32 | try: |
| 33 | cmd_send = c.UEL + c.PS_HEADER + iohack + str_send + footer # + c.UEL |
| 34 | # write to logfile |
| 35 | log().write(self.logfile, str_send + os.linesep) |
| 36 | # sent to printer |
| 37 | self.send(cmd_send) |
| 38 | # use random token or error message as delimiter PS responses |
| 39 | str_recv = self.recv(token + ".*$" + "|" + c.PS_FLUSH, fb, crop, binary) |
| 40 | return self.ps_err(str_recv) |
| 41 | |
| 42 | # handle CTRL+C and exceptions |
| 43 | except (KeyboardInterrupt, Exception) as e: |
| 44 | self.reconnect(str(e)) |
| 45 | return "" |
| 46 | |
| 47 | # send PostScript command, cause permanent changes |
| 48 | def globalcmd(self, str_send, *stuff): |
no test coverage detected