Wanted to make friends of Streamlit and Fabric just to no avail

I am leveraging the Fabric Library and Streamlit.
Fabric β€” a convenient way to interact with a remote server via SSH.

    from fabric import Connection
    import streamlit as st

    SSH_c = Connection(HOST_SSH, port=22,user=LOGIN_NAME, connect_kwargs={'key_filename':KEY_PATH})
    listdir = SSH_c.run('ls') # And just want to have a list of files
    st.write(listdir)

As result I receive the following exception:

ThreadException: Saw 1 exceptions within threads (ValueError): 
Thread args: {'kwargs': {'echo': None, 'input_': <_io.TextIOWrapper name='<stdin>' mode='r' encoding='utf-8'>, 
'output': <_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>}, 
'target': <bound method Runner.handle_stdin of <fabric.runners.Remote object at 0x7ff6cc5c5ca0>>} Traceback (most recent call last): File "/home/streamlit/.local/lib/python3.8/site-packages/invoke/util.py",
line 233, in run super(ExceptionHandlingThread, self).run() File "/usr/lib/python3.8/threading.py", 
line 870, in run self._target(*self._args, **self._kwargs) File "/home/streamlit/.local/lib/python3.8/site-packages/invoke/runners.py", 
line 813, in handle_stdin with character_buffered(input_): File "/usr/lib/python3.8/contextlib.py", 
line 113, in __enter__ return next(self.gen) File "/home/streamlit/.local/lib/python3.8/site-packages/invoke/terminals.py", 
line 175, in character_buffered or not isatty(stream) File "/home/streamlit/.local/lib/python3.8/site-packages/invoke/util.py", 
line 131, in isatty return stream.isatty() ValueError: I/O operation on closed file

I think the reason is that Streamlit intercepts terminal output. I tried various technics to catch terminal output as it was recommended on this forum, but nothing works.
That means I don’t understand what actually happened :slight_smile:

How to make it works?

UPDATE.
Despite the problem, I came to the solution by removing one layer (fabric). I used paramiko:

     import streamlit as st
     from paramiko import SSHClient

    client = SSHClient()
    client.load_system_host_keys()
    client.connect(hostname=HOST_SSH, username=LOGIN_NAME, key_filename=KEY_PATH)
    stdin, stdout, stderr = client.exec_command('ls -l')

    st.write(stdout.readlines())