How to use the aioconsole.compat.platform function in aioconsole

To help you get started, we’ve selected a few aioconsole examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github vxgmichel / aioconsole / aioconsole / apython.py View on Github external
def run_apython(args=None):
    namespace = parse_args(args)

    if namespace.readline and not namespace.serve and \
       compat.platform != 'win32':

        try:
            import readline
            import rlcompleter
        except ImportError:
            readline, rlcompleter = None, None

        if readline:
            if rlcompleter:
                readline.parse_and_bind("tab: complete")
            code = run_apython_in_subprocess(args, namespace.prompt_control)
            sys.exit(code)

    try:
        sys._argv = sys.argv
        sys._path = sys.path
github vxgmichel / aioconsole / aioconsole / rlwrap.py View on Github external
def wait_for_prompt(src, dest, prompt_control, buffersize=1):

    def read():
        value = src.read(buffersize)
        if value:
            return value
        raise EOFError

    def write(arg):
        if arg:
            dest.write(arg)
            dest.flush()

    # Prevent exception in macOS with large output (issue #42)
    if compat.platform == 'darwin':
        fcntl.fcntl(dest.fileno(), fcntl.F_SETFL, 0)

    # Wait for first prompt control
    while True:
        current = read()
        if prompt_control in current:
            break
        write(current)

    preprompt, current = current.split(prompt_control, 1)
    write(preprompt)

    # Wait for second prompt control
    while prompt_control not in current:
        current += read()
github vxgmichel / aioconsole / aioconsole / stream.py View on Github external
def is_pipe_transport_compatible(pipe):
    if compat.platform == 'win32':
        return False
    try:
        fileno = pipe.fileno()
    except OSError:
        return False
    mode = os.fstat(fileno).st_mode
    is_char = stat.S_ISCHR(mode)
    is_fifo = stat.S_ISFIFO(mode)
    is_socket = stat.S_ISSOCK(mode)
    if not (is_char or is_fifo or is_socket):
        return False
    return True