21
21
22
22
class BlocklyServer (object ):
23
23
24
- def __init__ (self , version , queue ):
24
+ def __init__ (self , version , app_version , queue ):
25
25
self .logger = logging .getLogger ('blockly.server' )
26
26
self .logger .info ('Creating server logger.' )
27
27
28
28
self .version = version
29
+ self .app_version = app_version
29
30
self .queue = queue
30
31
31
32
# Find the path from which application was launched
@@ -47,9 +48,11 @@ def __init__(self, version, queue):
47
48
def index (self ):
48
49
cherrypy .response .headers ['Access-Control-Allow-Origin' ] = '*'
49
50
51
+ # version supports pre-0.99 web clients, version_str supports v0.99+ web clients
50
52
serverinfo = {
51
53
"server" : "BlocklyPropHTTP" ,
52
- "version" : self .version
54
+ "version" : self .version ,
55
+ "version_str" : self .app_version
53
56
}
54
57
self .queue .put ((1 , 'TRACE' , 'Server poll received' ))
55
58
self .logger .debug ('Server poll received' )
@@ -85,7 +88,7 @@ def ports(self):
85
88
@cherrypy .expose (alias = 'load.action' )
86
89
@cherrypy .tools .json_out ()
87
90
@cherrypy .tools .allow (methods = ['POST' ])
88
- def load (self , action , binary , extension , comport = None ):
91
+ def load (self , option , action , binary , extension , comport = None ):
89
92
if action is None :
90
93
self .logger .error ('Load action is undefined.' )
91
94
return {
@@ -105,7 +108,7 @@ def load(self, action, binary, extension, comport=None):
105
108
106
109
self .logger .debug ('Loading program to device.' )
107
110
108
- (success , out , err ) = self .propellerLoad .download (action , binary_file , comport )
111
+ (success , out , err ) = self .propellerLoad .download (option , action , binary_file , comport )
109
112
self .queue .put ((10 , 'INFO' , 'Application loaded (%s)' % action ))
110
113
111
114
self .logger .info ('Application load complete.' )
@@ -125,7 +128,7 @@ def serial_socket(self):
125
128
handler = cherrypy .request .ws_handler
126
129
127
130
128
- def main (port , version , queue ):
131
+ def main (port , version , app_version , queue ):
129
132
module_logger .info ("Server starting" )
130
133
queue .put ((10 , 'INFO' , 'Server starting' ))
131
134
@@ -137,7 +140,7 @@ def main(port, version, queue):
137
140
138
141
queue .put ((10 , 'INFO' , 'Websocket configured' ))
139
142
140
- cherrypy .quickstart (BlocklyServer (version , queue ), '/' , config = {'/serial.connect' : {
143
+ cherrypy .quickstart (BlocklyServer (version , app_version , queue ), '/' , config = {'/serial.connect' : {
141
144
'tools.websocket.on' : True ,
142
145
'tools.websocket.handler_cls' : SerialSocket
143
146
}})
0 commit comments