@@ -92,6 +92,9 @@ def __init__(self, executable, socket_addr=None,
92
92
self .context = None
93
93
self .socket = None
94
94
95
+ def _program_name (self ):
96
+ raise NotImplemented
97
+
95
98
def _preamble_code (self ):
96
99
return ["addpath(genpath('%s'))" % MATLAB_FOLDER ]
97
100
@@ -111,7 +114,7 @@ def _run_server(self):
111
114
# Start server/client session and make the connection
112
115
def start (self ):
113
116
# Start the MATLAB server in a new process
114
- print "Starting MATLAB on ZMQ socket %s" % (self .socket_addr )
117
+ print "Starting %s on ZMQ socket %s" % (self . _program_name (), self .socket_addr )
115
118
print "Send 'exit' command to kill the server"
116
119
self ._run_server ()
117
120
@@ -124,10 +127,10 @@ def start(self):
124
127
125
128
# Test if connection is established
126
129
if self .is_connected ():
127
- print "MATLAB started and connected!"
130
+ print "%s started and connected!" % self . _program_name ()
128
131
return True
129
132
else :
130
- print "MATLAB failed to start"
133
+ print "%s failed to start" % self . _program_name ()
131
134
return False
132
135
133
136
def _response (self , ** kwargs ):
@@ -140,7 +143,7 @@ def _response(self, **kwargs):
140
143
def stop (self ):
141
144
# Matlab should respond with "exit" if successful
142
145
if self ._response (cmd = 'exit' ) == "exit" :
143
- print "MATLAB closed"
146
+ print "%s closed" % self . _program_name ()
144
147
145
148
self .started = False
146
149
return True
@@ -163,11 +166,12 @@ def is_connected(self):
163
166
sys .stdout .write ('.' )
164
167
time .sleep (1 )
165
168
if time .time () - start_time > self .maxtime :
166
- print "Matlab session timed out after %d seconds" % self .maxtime
169
+ print "%s session timed out after %d seconds" % ( self ._program_name (), self . maxtime )
167
170
return False
168
171
169
172
def is_function_processor_working (self ):
170
- result = self .run_func ('%s/test_functions/test_sum.m' % MATLAB_FOLDER , {'echo' : 'Matlab: Function processor is working!' })
173
+ result = self .run_func ('%s/test_functions/test_sum.m' % MATLAB_FOLDER ,
174
+ {'echo' : '%s: Function processor is working!' % self ._program_name ()})
171
175
return result ['success' ] == 'true'
172
176
173
177
def _json_response (self , ** kwargs ):
@@ -237,6 +241,9 @@ def __init__(self, executable='matlab', socket_addr=None,
237
241
super (Matlab , self ).__init__ (executable , socket_addr , id , log , maxtime ,
238
242
platform , startup_options )
239
243
244
+ def _program_name (self ):
245
+ return 'MATLAB'
246
+
240
247
def _execute_flag (self ):
241
248
return '-r'
242
249
@@ -282,6 +289,9 @@ def __init__(self, executable='octave', socket_addr=None,
282
289
super (Octave , self ).__init__ (executable , socket_addr , id , log , maxtime ,
283
290
platform , startup_options )
284
291
292
+ def _program_name (self ):
293
+ return 'Octave'
294
+
285
295
def _preamble_code (self ):
286
296
code = super (Octave , self )._preamble_code ()
287
297
if self .log :
0 commit comments