2121
2222class BlocklyServer (object ):
2323
24- def __init__ (self , version , queue ):
24+ def __init__ (self , version , app_version , queue ):
2525 self .logger = logging .getLogger ('blockly.server' )
2626 self .logger .info ('Creating server logger.' )
2727
2828 self .version = version
29+ self .app_version = app_version
2930 self .queue = queue
3031
3132 # Find the path from which application was launched
@@ -47,9 +48,11 @@ def __init__(self, version, queue):
4748 def index (self ):
4849 cherrypy .response .headers ['Access-Control-Allow-Origin' ] = '*'
4950
51+ # version supports pre-0.99 web clients, version_str supports v0.99+ web clients
5052 serverinfo = {
5153 "server" : "BlocklyPropHTTP" ,
52- "version" : self .version
54+ "version" : self .version ,
55+ "version_str" : self .app_version
5356 }
5457 self .queue .put ((1 , 'TRACE' , 'Server poll received' ))
5558 self .logger .debug ('Server poll received' )
@@ -85,7 +88,7 @@ def ports(self):
8588 @cherrypy .expose (alias = 'load.action' )
8689 @cherrypy .tools .json_out ()
8790 @cherrypy .tools .allow (methods = ['POST' ])
88- def load (self , action , binary , extension , comport = None ):
91+ def load (self , option , action , binary , extension , comport = None ):
8992 if action is None :
9093 self .logger .error ('Load action is undefined.' )
9194 return {
@@ -105,7 +108,7 @@ def load(self, action, binary, extension, comport=None):
105108
106109 self .logger .debug ('Loading program to device.' )
107110
108- (success , out , err ) = self .propellerLoad .download (action , binary_file , comport )
111+ (success , out , err ) = self .propellerLoad .download (option , action , binary_file , comport )
109112 self .queue .put ((10 , 'INFO' , 'Application loaded (%s)' % action ))
110113
111114 self .logger .info ('Application load complete.' )
@@ -125,7 +128,7 @@ def serial_socket(self):
125128 handler = cherrypy .request .ws_handler
126129
127130
128- def main (port , version , queue ):
131+ def main (port , version , app_version , queue ):
129132 module_logger .info ("Server starting" )
130133 queue .put ((10 , 'INFO' , 'Server starting' ))
131134
@@ -137,7 +140,7 @@ def main(port, version, queue):
137140
138141 queue .put ((10 , 'INFO' , 'Websocket configured' ))
139142
140- cherrypy .quickstart (BlocklyServer (version , queue ), '/' , config = {'/serial.connect' : {
143+ cherrypy .quickstart (BlocklyServer (version , app_version , queue ), '/' , config = {'/serial.connect' : {
141144 'tools.websocket.on' : True ,
142145 'tools.websocket.handler_cls' : SerialSocket
143146 }})
0 commit comments