printrun-src/printrun/plugins/sample.py

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

mercurial