printrun-src/printrun/plugins/sample.py

Wed, 20 Jan 2021 10:15:13 +0100

author
mdd
date
Wed, 20 Jan 2021 10:15:13 +0100
changeset 46
cce0af6351f0
permissions
-rw-r--r--

updated and added new files for printrun

46
cce0af6351f0 updated and added new files for printrun
mdd
parents:
diff changeset
1 # This file is part of the Printrun suite.
cce0af6351f0 updated and added new files for printrun
mdd
parents:
diff changeset
2 #
cce0af6351f0 updated and added new files for printrun
mdd
parents:
diff changeset
3 # Printrun is free software: you can redistribute it and/or modify
cce0af6351f0 updated and added new files for printrun
mdd
parents:
diff changeset
4 # it under the terms of the GNU General Public License as published by
cce0af6351f0 updated and added new files for printrun
mdd
parents:
diff changeset
5 # the Free Software Foundation, either version 3 of the License, or
cce0af6351f0 updated and added new files for printrun
mdd
parents:
diff changeset
6 # (at your option) any later version.
cce0af6351f0 updated and added new files for printrun
mdd
parents:
diff changeset
7 #
cce0af6351f0 updated and added new files for printrun
mdd
parents:
diff changeset
8 # Printrun is distributed in the hope that it will be useful,
cce0af6351f0 updated and added new files for printrun
mdd
parents:
diff changeset
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
cce0af6351f0 updated and added new files for printrun
mdd
parents:
diff changeset
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
cce0af6351f0 updated and added new files for printrun
mdd
parents:
diff changeset
11 # GNU General Public License for more details.
cce0af6351f0 updated and added new files for printrun
mdd
parents:
diff changeset
12 #
cce0af6351f0 updated and added new files for printrun
mdd
parents:
diff changeset
13 # You should have received a copy of the GNU General Public License
cce0af6351f0 updated and added new files for printrun
mdd
parents:
diff changeset
14 # along with Printrun. If not, see <http://www.gnu.org/licenses/>.
cce0af6351f0 updated and added new files for printrun
mdd
parents:
diff changeset
15
cce0af6351f0 updated and added new files for printrun
mdd
parents:
diff changeset
16 from printrun.eventhandler import PrinterEventHandler
cce0af6351f0 updated and added new files for printrun
mdd
parents:
diff changeset
17
cce0af6351f0 updated and added new files for printrun
mdd
parents:
diff changeset
18 class SampleHandler(PrinterEventHandler):
cce0af6351f0 updated and added new files for printrun
mdd
parents:
diff changeset
19 '''
cce0af6351f0 updated and added new files for printrun
mdd
parents:
diff changeset
20 Sample event handler for printcore.
cce0af6351f0 updated and added new files for printrun
mdd
parents:
diff changeset
21 '''
cce0af6351f0 updated and added new files for printrun
mdd
parents:
diff changeset
22
cce0af6351f0 updated and added new files for printrun
mdd
parents:
diff changeset
23 def __init__(self):
cce0af6351f0 updated and added new files for printrun
mdd
parents:
diff changeset
24 pass
cce0af6351f0 updated and added new files for printrun
mdd
parents:
diff changeset
25
cce0af6351f0 updated and added new files for printrun
mdd
parents:
diff changeset
26 def __write(self, field, text = ""):
cce0af6351f0 updated and added new files for printrun
mdd
parents:
diff changeset
27 print("%-15s - %s" % (field, text))
cce0af6351f0 updated and added new files for printrun
mdd
parents:
diff changeset
28
cce0af6351f0 updated and added new files for printrun
mdd
parents:
diff changeset
29 def on_init(self):
cce0af6351f0 updated and added new files for printrun
mdd
parents:
diff changeset
30 self.__write("on_init")
cce0af6351f0 updated and added new files for printrun
mdd
parents:
diff changeset
31
cce0af6351f0 updated and added new files for printrun
mdd
parents:
diff changeset
32 def on_send(self, command, gline):
cce0af6351f0 updated and added new files for printrun
mdd
parents:
diff changeset
33 self.__write("on_send", command)
cce0af6351f0 updated and added new files for printrun
mdd
parents:
diff changeset
34
cce0af6351f0 updated and added new files for printrun
mdd
parents:
diff changeset
35 def on_recv(self, line):
cce0af6351f0 updated and added new files for printrun
mdd
parents:
diff changeset
36 self.__write("on_recv", line.strip())
cce0af6351f0 updated and added new files for printrun
mdd
parents:
diff changeset
37
cce0af6351f0 updated and added new files for printrun
mdd
parents:
diff changeset
38 def on_connect(self):
cce0af6351f0 updated and added new files for printrun
mdd
parents:
diff changeset
39 self.__write("on_connect")
cce0af6351f0 updated and added new files for printrun
mdd
parents:
diff changeset
40
cce0af6351f0 updated and added new files for printrun
mdd
parents:
diff changeset
41 def on_disconnect(self):
cce0af6351f0 updated and added new files for printrun
mdd
parents:
diff changeset
42 self.__write("on_disconnect")
cce0af6351f0 updated and added new files for printrun
mdd
parents:
diff changeset
43
cce0af6351f0 updated and added new files for printrun
mdd
parents:
diff changeset
44 def on_error(self, error):
cce0af6351f0 updated and added new files for printrun
mdd
parents:
diff changeset
45 self.__write("on_error", error)
cce0af6351f0 updated and added new files for printrun
mdd
parents:
diff changeset
46
cce0af6351f0 updated and added new files for printrun
mdd
parents:
diff changeset
47 def on_online(self):
cce0af6351f0 updated and added new files for printrun
mdd
parents:
diff changeset
48 self.__write("on_online")
cce0af6351f0 updated and added new files for printrun
mdd
parents:
diff changeset
49
cce0af6351f0 updated and added new files for printrun
mdd
parents:
diff changeset
50 def on_temp(self, line):
cce0af6351f0 updated and added new files for printrun
mdd
parents:
diff changeset
51 self.__write("on_temp", line)
cce0af6351f0 updated and added new files for printrun
mdd
parents:
diff changeset
52
cce0af6351f0 updated and added new files for printrun
mdd
parents:
diff changeset
53 def on_start(self, resume):
cce0af6351f0 updated and added new files for printrun
mdd
parents:
diff changeset
54 self.__write("on_start", "true" if resume else "false")
cce0af6351f0 updated and added new files for printrun
mdd
parents:
diff changeset
55
cce0af6351f0 updated and added new files for printrun
mdd
parents:
diff changeset
56 def on_end(self):
cce0af6351f0 updated and added new files for printrun
mdd
parents:
diff changeset
57 self.__write("on_end")
cce0af6351f0 updated and added new files for printrun
mdd
parents:
diff changeset
58
cce0af6351f0 updated and added new files for printrun
mdd
parents:
diff changeset
59 def on_layerchange(self, layer):
cce0af6351f0 updated and added new files for printrun
mdd
parents:
diff changeset
60 self.__write("on_layerchange", "%f" % (layer))
cce0af6351f0 updated and added new files for printrun
mdd
parents:
diff changeset
61
cce0af6351f0 updated and added new files for printrun
mdd
parents:
diff changeset
62 def on_preprintsend(self, gline, index, mainqueue):
cce0af6351f0 updated and added new files for printrun
mdd
parents:
diff changeset
63 self.__write("on_preprintsend", gline)
cce0af6351f0 updated and added new files for printrun
mdd
parents:
diff changeset
64
cce0af6351f0 updated and added new files for printrun
mdd
parents:
diff changeset
65 def on_printsend(self, gline):
cce0af6351f0 updated and added new files for printrun
mdd
parents:
diff changeset
66 self.__write("on_printsend", gline)
cce0af6351f0 updated and added new files for printrun
mdd
parents:
diff changeset
67

mercurial