Server IP : 149.255.58.128 / Your IP : 216.73.216.125
System : Linux cloud516.thundercloud.uk 5.14.0-427.26.1.el9_4.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Jul 17 15:51:13 EDT 2024 x86_64
PHP Version : 8.2.28
Disable Function : allow_url_include, apache_child_terminate, apache_setenv, exec, passthru, pcntl_exec, posix_kill, posix_mkfifo, posix_getpwuid, posix_setpgid, posix_setsid, posix_setuid, posix_setgid, posix_seteuid, posix_setegid, posix_uname, proc_close, proc_get_status, proc_open, proc_terminate, shell_exec, show_source, system
cURL : ON | WGET : ON | Sudo : OFF | Pkexec : OFF
Upload Files :
Command :
Current File : /usr/lib/python3.9/site-packages/pexpect//_async.py
import asyncio
import errno
import signal
from pexpect import EOF
@asyncio.coroutine
def expect_async(expecter, timeout=None):
# First process data that was previously read - if it maches, we don't need
# async stuff.
idx = expecter.existing_data()
if idx is not None:
return idx
if not expecter.spawn.async_pw_transport:
pw = PatternWaiter()
pw.set_expecter(expecter)
transport, pw = yield from asyncio.get_event_loop()\
.connect_read_pipe(lambda: pw, expecter.spawn)
expecter.spawn.async_pw_transport = pw, transport
else:
pw, transport = expecter.spawn.async_pw_transport
pw.set_expecter(expecter)
transport.resume_reading()
try:
return (yield from asyncio.wait_for(pw.fut, timeout))
except asyncio.TimeoutError as e:
transport.pause_reading()
return expecter.timeout(e)
@asyncio.coroutine
def repl_run_command_async(repl, cmdlines, timeout=-1):
res = []
repl.child.sendline(cmdlines[0])
for line in cmdlines[1:]:
yield from repl._expect_prompt(timeout=timeout, async_=True)
res.append(repl.child.before)
repl.child.sendline(line)
# Command was fully submitted, now wait for the next prompt
prompt_idx = yield from repl._expect_prompt(timeout=timeout, async_=True)
if prompt_idx == 1:
# We got the continuation prompt - command was incomplete
repl.child.kill(signal.SIGINT)
yield from repl._expect_prompt(timeout=1, async_=True)
raise ValueError("Continuation prompt found - input was incomplete:")
return u''.join(res + [repl.child.before])
class PatternWaiter(asyncio.Protocol):
transport = None
def set_expecter(self, expecter):
self.expecter = expecter
self.fut = asyncio.Future()
def found(self, result):
if not self.fut.done():
self.fut.set_result(result)
self.transport.pause_reading()
def error(self, exc):
if not self.fut.done():
self.fut.set_exception(exc)
self.transport.pause_reading()
def connection_made(self, transport):
self.transport = transport
def data_received(self, data):
spawn = self.expecter.spawn
s = spawn._decoder.decode(data)
spawn._log(s, 'read')
if self.fut.done():
spawn._before.write(s)
spawn._buffer.write(s)
return
try:
index = self.expecter.new_data(s)
if index is not None:
# Found a match
self.found(index)
except Exception as e:
self.expecter.errored()
self.error(e)
def eof_received(self):
# N.B. If this gets called, async will close the pipe (the spawn object)
# for us
try:
self.expecter.spawn.flag_eof = True
index = self.expecter.eof()
except EOF as e:
self.error(e)
else:
self.found(index)
def connection_lost(self, exc):
if isinstance(exc, OSError) and exc.errno == errno.EIO:
# We may get here without eof_received being called, e.g on Linux
self.eof_received()
elif exc is not None:
self.error(exc)
Name |
Size |
Last Modified |
Owner / Group |
Permissions |
Options |
.. | -- | March 19 2025 22:42:16 | 0 / root | 0755 | |
__pycache__ | -- | October 13 2023 17:01:36 | 0 / root | 0755 | |
| | | | | |
ANSI.py | 11.892 KB | January 17 2020 17:08:15 | 0 / root | 0644 | |
FSM.py | 13.104 KB | January 17 2020 17:08:15 | 0 / root | 0644 | |
__init__.py | 3.811 KB | January 17 2020 17:08:15 | 0 / root | 0644 | |
_async.py | 3.227 KB | January 17 2020 17:08:15 | 0 / root | 0644 | |
bashrc.sh | 0.371 KB | January 17 2020 17:08:15 | 0 / root | 0644 | |
exceptions.py | 1.043 KB | January 17 2020 17:08:15 | 0 / root | 0644 | |
expect.py | 13.503 KB | January 17 2020 17:08:15 | 0 / root | 0644 | |
fdpexpect.py | 5.691 KB | January 17 2020 17:08:15 | 0 / root | 0644 | |
popen_spawn.py | 6.017 KB | January 17 2020 17:08:15 | 0 / root | 0644 | |
pty_spawn.py | 36.506 KB | January 17 2020 17:08:15 | 0 / root | 0644 | |
pxssh.py | 23.71 KB | January 17 2020 17:08:15 | 0 / root | 0644 | |
replwrap.py | 5.501 KB | January 17 2020 17:08:15 | 0 / root | 0644 | |
run.py | 6.473 KB | January 17 2020 17:08:15 | 0 / root | 0644 | |
screen.py | 13.383 KB | January 17 2020 17:08:15 | 0 / root | 0644 | |
spawnbase.py | 20.749 KB | January 17 2020 17:08:15 | 0 / root | 0644 | |
utils.py | 5.878 KB | January 17 2020 17:08:15 | 0 / root | 0644 | |