MCPcopy Create free account
hub / github.com/dot-agent/nextpy / __init__

Method __init__

nextpy/ai/engine/library/_shell.py:102–122  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

100 """
101
102 def __init__(self):
103 import pty # TODO: Make this work on Windows
104 self.shell_cmd = os.environ.get('SHELL', '/bin/sh')
105 self.master_fd, self.slave_fd = pty.openpty()
106 my_env = os.environ.copy()
107 self.p = subprocess.Popen(
108 self.shell_cmd,
109 preexec_fn=os.setsid,
110 stdin=self.slave_fd,
111 stdout=self.slave_fd,
112 stderr=self.slave_fd,
113 text=True,
114 env=my_env
115 )
116 self._env_inited = False
117 self.loop = asyncio.get_event_loop()
118 self.loop.add_reader(self.master_fd, self.read)
119
120 # an event that the command has finished
121 self.command_finished = asyncio.Event()
122 self._current_output = ""
123
124 def read(self):
125 """ Read the next chunk of output from the shell.

Callers

nothing calls this directly

Calls 2

getMethod · 0.45
copyMethod · 0.45

Tested by

no test coverage detected