Skip to content

Commit 19d3e67

Browse files
Merge pull request #7 from DarkmatterVale/master
Since there seems to be no one opposed to this PR, I am going to merge it.
2 parents 3e6d93b + 52a7e54 commit 19d3e67

File tree

2 files changed

+25
-6
lines changed

2 files changed

+25
-6
lines changed

BlocklyPropClient.py

+20-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__author__ = 'Michel'
1+
__author__ = 'Michel & Vale'
22

33
import Tkinter as tk
44
import ttk as ttk
@@ -23,6 +23,7 @@ def __init__(self, *args, **kwargs):
2323
# initialize values
2424
self.version = 0.0
2525
self.connected = False
26+
self.lowlevel_logging = 0
2627

2728
# initialize config variables
2829
self.ip_address = tk.StringVar()
@@ -65,6 +66,9 @@ def initialize(self):
6566

6667
self.ent_log = ScrolledText.ScrolledText(self, state='disabled')
6768
self.ent_log.grid(column=0, row=4, columnspan=2, sticky='nesw', padx=3, pady=3)
69+
70+
self.btn_log_checkbox = ttk.Button(self, text='Low level logging: Currently False', command=self.handle_lowlevel_logging)
71+
self.btn_log_checkbox.grid(column=1, row=3, sticky='nesw', padx=3, pady=3)
6872

6973
self.grid_columnconfigure(0, minsize=100)
7074
self.grid_columnconfigure(0, weight=1)
@@ -87,7 +91,7 @@ def initialize(self):
8791

8892
def handle_connect(self):
8993
if self.connected:
90-
BlocklyServer.stop()
94+
BlocklyServer.stop(self.q)
9195
self.server_process.terminate()
9296
self.connected = False
9397
self.btn_connect['text'] = "Connect"
@@ -117,6 +121,20 @@ def text_catcher(self):
117121
self.ent_log.insert(tk.END, datetime.now().strftime('%Y-%m-%d %H:%M:%S') + ' ' + level_name + ': ' + message + '\n')
118122
self.ent_log.yview_pickplace("end")
119123
self.ent_log['state'] = 'disabled'
124+
if level < 5:
125+
if self.lowlevel_logging:
126+
self.ent_log['state'] = 'normal'
127+
self.ent_log.insert(tk.END, datetime.now().strftime('%Y-%m-%d %H:%M:%S') + ' ' + level_name + ': ' + message + '\n')
128+
self.ent_log.yview_pickplace("end")
129+
self.ent_log['state'] = 'disabled'
130+
131+
def handle_lowlevel_logging(self):
132+
if self.lowlevel_logging:
133+
self.lowlevel_logging = 0
134+
self.btn_log_checkbox['text'] = "Low level logging: Currently False"
135+
else:
136+
self.lowlevel_logging = 1
137+
self.btn_log_checkbox['text'] = "Low level logging: Currently True"
120138

121139

122140
if __name__ == '__main__':

BlocklyServer.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,13 @@ def compile(self, action, language, code, comport=None):
5151
cherrypy.response.headers['Access-Control-Allow-Origin'] = '*'
5252

5353
result = self.compiler[language].handle(action, code, comport)
54-
self.queue.put((10, 'INFO', 'Application compiled'+ ' (' + action + ' : ' + language + ')'))
54+
self.queue.put((1, 'INFO', 'Application compiled'+ ' (' + action + ' : ' + language + ')'))
5555
return result
5656

5757
@cherrypy.expose(alias='serial.connect')
5858
def serial_socket(self):
5959
cherrypy.response.headers['Access-Control-Allow-Origin'] = '*'
60-
self.queue.put((10, 'INFO', 'Serial socket set up'))
60+
self.queue.put((1, 'INFO', 'Serial socket set up'))
6161
handler = cherrypy.request.ws_handler
6262

6363
propellerLoad = PropellerLoad()
@@ -91,8 +91,9 @@ def main(port, version, queue):
9191
# httpd.socket.close()
9292

9393

94-
def stop():
94+
def stop(queue):
9595
cherrypy.engine.stop()
96+
queue.put((10, 'INFO', 'Server disconnected'))
9697

9798
if __name__ == '__main__':
98-
main(PORT, VERSION, None)
99+
main(PORT, VERSION, None)

0 commit comments

Comments
 (0)