MCPcopy Index your code
hub / github.com/bugy/script-server / open

Method open

src/web/server.py:268–313  ·  view source on GitHub ↗
(self, user, execution_id)

Source from the content-addressed store, hash-verified

266 @check_authorization
267 @inject_user
268 def open(self, user, execution_id):
269 execution_service = self.application.execution_service
270
271 try:
272 self.executor = execution_service.get_active_executor(execution_id, get_user(self))
273 except Exception as e:
274 self.handle_exception_on_open(e)
275 return
276
277 self.ioloop = tornado.ioloop.IOLoop.current()
278
279 self.write_message(wrap_to_server_event('input', 'your input >>'))
280
281 user_id = identify_user(self)
282
283 output_stream = execution_service.get_raw_output_stream(execution_id, user_id)
284 pipe_output_to_http(output_stream, self.safe_write)
285
286 file_download_feature = self.application.file_download_feature
287 web_socket = self
288
289 def finished():
290 try:
291 downloadable_files = file_download_feature.get_downloadable_files(execution_id)
292
293 for file in downloadable_files:
294 filename = os.path.basename(file)
295 url_path = web_socket.prepare_download_url(file)
296
297 web_socket.safe_write(wrap_to_server_event(
298 'file',
299 {'url': url_path, 'filename': filename}))
300 except:
301 LOGGER.exception('Could not prepare downloadable files')
302
303 connection = web_socket.ws_connection
304 if (connection is not None) and (hasattr(connection, 'ping_callback')):
305 # we need to stop callback explicitly and as soon as possible, to avoid sending ping after close
306 connection.ping_callback.stop()
307
308 output_stream.wait_close(timeout=5)
309 web_socket.ioloop.add_callback(web_socket.close, code=1000)
310
311 file_download_feature.subscribe_on_inline_images(execution_id, self.send_inline_image)
312
313 execution_service.add_finish_listener(finished, execution_id)
314
315 def on_message(self, text):
316 self.executor.write_to_input(text)

Callers 2

callHttpFunction · 0.45
clickOnParamFunction · 0.45

Calls 9

get_userFunction · 0.90
wrap_to_server_eventFunction · 0.90
identify_userFunction · 0.90
pipe_output_to_httpFunction · 0.85
get_active_executorMethod · 0.80
get_raw_output_streamMethod · 0.45
add_finish_listenerMethod · 0.45

Tested by

no test coverage detected