I'm trying to create an async subprocess and pass a variable to stdin but trio.run_process and trio.open_process both give an attribute error. It doesn't specify what is causing the error.
Traceback (most recent call last):
File "./update.py", line 122, in pkgUpdates
trio.run(self.asetup, password)
File "/home/user/.local/lib/python3.7/site-packages/trio/_core/_run.py", line 1444, in run
raise runner.main_task_outcome.error
File "./update.py", line 65, in asetup
nursery.start_soon(self.upProc, password, 'update')
File "/home/user/.local/lib/python3.7/site-packages/trio/_core/_run.py", line 506, in __aexit__
raise combined_error_from_nursery
File "./update.py", line 75, in upProc
await trio.open_process(['sudo', '-S', 'apt-get', cmd, '-y'],
File "/home/user/.local/lib/python3.7/site-packages/trio/_deprecate.py", line 125, in __getattr__
raise AttributeError(name)
AttributeError: open_process
I've also tried using trio.Process with stdin=io.BytesIO(password)
but this gives an io.UnsupportedOperation error. Passing only bytes also gives an error.
The function is:
async def upProc(self, password, cmd):
await trio.open_process(['sudo', '-S', 'apt-get', cmd, '-y'],
stdin=password.encode(), capture_stdout=True)
if (cmd == 'update'):
await self.upProc(password, 'upgrade')
return