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

Method cmd

postscript.py:22–45  ·  view source on GitHub ↗
(self, str_send, fb=True, crop=True, binary=False)

Source from the content-addressed store, hash-verified

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):

Callers 15

globalcmdMethod · 0.95
supercmdMethod · 0.95
on_connectMethod · 0.95
vol_existsMethod · 0.95
file_existsMethod · 0.95
getMethod · 0.95
putMethod · 0.95
deleteMethod · 0.95
do_renameMethod · 0.95
do_idMethod · 0.95
do_versionMethod · 0.95
do_dfMethod · 0.95

Calls 6

ps_errMethod · 0.95
logClass · 0.90
reconnectMethod · 0.80
writeMethod · 0.45
sendMethod · 0.45
recvMethod · 0.45

Tested by

no test coverage detected