MCPcopy Create free account
hub / github.com/pgadmin-org/pgadmin4 / read_terminal_data

Function read_terminal_data

web/pgadmin/tools/psql/__init__.py:203–226  ·  view source on GitHub ↗

Read the terminal output. :param parent: :param data_ready: :param max_read_bytes: :param sid: :return:

(parent, data_ready, max_read_bytes, sid)

Source from the content-addressed store, hash-verified

201
202
203def read_terminal_data(parent, data_ready, max_read_bytes, sid):
204 """
205 Read the terminal output.
206 :param parent:
207 :param data_ready:
208 :param max_read_bytes:
209 :param sid:
210 :return:
211 """
212 if parent in data_ready:
213 # Read the output from parent fd (terminal).
214 output = os.read(parent, max_read_bytes)
215 try:
216 decode_data = output.decode()
217 except Exception:
218 try:
219 decode_data = output.decode('UTF-8')
220 except Exception:
221 decode_data = output.decode('UTF-8', errors='replace')
222
223 sio.emit('pty-output',
224 {'result': decode_data,
225 'error': False},
226 namespace='/pty', room=sid)
227
228
229def read_stdout(process, sid, max_read_bytes, win_emit_output=True):

Callers 1

non_windows_platformFunction · 0.85

Calls 2

decodeMethod · 0.80
emitMethod · 0.80

Tested by

no test coverage detected