Commit f80e1b4b authored by carlosperate's avatar carlosperate

Modified the HTTP request handler to suppress successful requests:

Now it only prints HTTP status codes that are not 200 (successful request).
Minor update to ServerCompilerSettings to not print too many line breaks.
parent fa5f28f9
...@@ -67,6 +67,20 @@ class BlocklyRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler): ...@@ -67,6 +67,20 @@ class BlocklyRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
self.end_headers() self.end_headers()
self.wfile.write(message_back.encode("utf-8")) self.wfile.write(message_back.encode("utf-8"))
def log_request(self, code='-', size='-'):
"""
Log an accepted request.
This is called by send_response(), and printed to the stderr by
log_message. No need to fill the command line with successful responses,
so only print any non 200.
:param code:
:param size:
:return:
"""
if code != 200:
self.log_message('"%s" %s %s',
self.requestline, str(code), str(size))
################# #################
# Main Handlers # # Main Handlers #
......
from __future__ import unicode_literals, absolute_import from __future__ import unicode_literals, absolute_import
import sys
import os import os
import re import re
try: try:
...@@ -488,7 +489,8 @@ class ServerCompilerSettings(object): ...@@ -488,7 +489,8 @@ class ServerCompilerSettings(object):
settings_file = open(self.get_settings_file_path(), 'w') settings_file = open(self.get_settings_file_path(), 'w')
settings_parser.write(settings_file) settings_parser.write(settings_file)
settings_file.close() settings_file.close()
print('\nSettings file saved to:') print('Settings file saved to:')
sys.stdout.flush()
except Exception as e: except Exception as e:
print(e) print(e)
print('\nUnable to write the settings file to:') print('\nUnable to write the settings file to:')
...@@ -519,7 +521,7 @@ class ServerCompilerSettings(object): ...@@ -519,7 +521,7 @@ class ServerCompilerSettings(object):
print('\tSerial Port Value: %s' % self.__serial_port_value__) print('\tSerial Port Value: %s' % self.__serial_port_value__)
print('\tSketch Name: %s' % self.__sketch_name__) print('\tSketch Name: %s' % self.__sketch_name__)
print('\tSketch Directory: %s' % self.__sketch_dir__) print('\tSketch Directory: %s' % self.__sketch_dir__)
print('\tLaunch IDE option: %s' % self.__launch_IDE_option__) print('\tLaunch IDE option: %s\n' % self.__launch_IDE_option__)
# The read X_from_file() functions do not save new settings and neither # The read X_from_file() functions do not save new settings and neither
# does the set_default_settings() function, so save them either way. # does the set_default_settings() function, so save them either way.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment