@@ -98,7 +98,18 @@ class Proxy(object):
9898 Stopping the server proxy. # doctest: +SKIP
9999 """
100100
101- def __init__ (self , package = None , python = None , url = 'http://127.0.0.1' , port = 1753 , service = None , max_conn_attempts = 100 , autoreload = True , capture_output = True ):
101+ def __init__ (
102+ self ,
103+ package = None ,
104+ python = None ,
105+ url = "http://127.0.0.1" ,
106+ port = 1753 ,
107+ service = None ,
108+ max_conn_attempts = 100 ,
109+ autoreload = True ,
110+ capture_output = True ,
111+ path = None ,
112+ ):
102113 self ._package = None
103114 self ._python = compas ._os .select_python (python )
104115 self ._url = url
@@ -108,6 +119,7 @@ def __init__(self, package=None, python=None, url='http://127.0.0.1', port=1753,
108119 self ._process = None
109120 self ._function = None
110121 self ._profile = None
122+ self ._path = path
111123
112124 self .service = service
113125 self .package = package
@@ -151,7 +163,7 @@ def service(self):
151163 @service .setter
152164 def service (self , service ):
153165 if not service :
154- self ._service = ' compas.rpc.services.default'
166+ self ._service = " compas.rpc.services.default"
155167 else :
156168 self ._service = service
157169
@@ -262,14 +274,25 @@ def start_server(self):
262274 self ._process .StartInfo .RedirectStandardOutput = self .capture_output
263275 self ._process .StartInfo .RedirectStandardError = self .capture_output
264276 self ._process .StartInfo .FileName = self .python
265- self ._process .StartInfo .Arguments = '-m {0} --port {1} --{2}autoreload' .format (self .service , self ._port , '' if self .autoreload else 'no-' )
277+ self ._process .StartInfo .Arguments = (
278+ "-m {0} --port {1} --{2}autoreload" .format (
279+ self .service , self ._port , "" if self .autoreload else "no-"
280+ )
281+ )
266282 self ._process .Start ()
267283 else :
268- args = [self .python , '-m' , self .service , '--port' , str (self ._port ), '--{}autoreload' .format ('' if self .autoreload else 'no-' )]
284+ args = [
285+ self .python ,
286+ "-m" ,
287+ self .service ,
288+ "--port" ,
289+ str (self ._port ),
290+ "--{}autoreload" .format ("" if self .autoreload else "no-" ),
291+ ]
269292 kwargs = dict (env = env )
270293 if self .capture_output :
271- kwargs [' stdout' ] = PIPE
272- kwargs [' stderr' ] = PIPE
294+ kwargs [" stdout" ] = PIPE
295+ kwargs [" stderr" ] = PIPE
273296
274297 self ._process = Popen (args , ** kwargs )
275298 # this starts the client side
@@ -285,7 +308,11 @@ def start_server(self):
285308 except Exception :
286309 time .sleep (0.1 )
287310 attempt_count += 1
288- print (" {} attempts left." .format (self .max_conn_attempts - attempt_count ))
311+ print (
312+ " {} attempts left." .format (
313+ self .max_conn_attempts - attempt_count
314+ )
315+ )
289316 else :
290317 success = True
291318 break
@@ -374,15 +401,15 @@ def _proxy(self, *args, **kwargs):
374401 Numpy objects are automatically converted to their built-in Python equivalents.
375402
376403 """
377- idict = {' args' : args , ' kwargs' : kwargs }
404+ idict = {" args" : args , " kwargs" : kwargs }
378405 istring = json .dumps (idict , cls = DataEncoder )
379406 # it makes sense that there is a broken pipe error
380407 # because the process is not the one receiving the feedback
381408 # when there is a print statement on the server side
382409 # this counts as output
383410 # it should be sent as part of RPC communication
384411 try :
385- ostring = self ._function (istring )
412+ ostring = self ._function (istring , self . _path or '' )
386413 except Exception :
387414 # not clear what the point of this is
388415 # self.stop_server()
@@ -395,8 +422,8 @@ def _proxy(self, *args, **kwargs):
395422
396423 result = json .loads (ostring , cls = DataDecoder )
397424
398- if result [' error' ]:
399- raise RPCServerError (result [' error' ])
425+ if result [" error" ]:
426+ raise RPCServerError (result [" error" ])
400427
401- self .profile = result [' profile' ]
402- return result [' data' ]
428+ self .profile = result [" profile" ]
429+ return result [" data" ]
0 commit comments