We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
server.shell(command...)).stdout gives error TypeError('cannot unpack non-iterable OutputLine object',)
try this task in v2.9 vs 3.0.
from pyinfra import host, logger, logging from pyinfra.operations.server import shell from pyinfra.operations.python import call # init logging logging.basicConfig(level = logging.DEBUG, format = '[%(asctime)s] %(levelname)s [%(name)s:%(lineno)s] %(message)s') logger = logging.getLogger(__name__) logger.setLevel( level=logging.DEBUG ) def server_op_callback(): result = shell(commands=["ls -lha"]) logger.debug(type(result)) logger.debug(str(result.stdout)) call( name="Execute server_op_callback function", function=server_op_callback, )
output
--> Loading config... --> Loading inventory... --> Connecting to hosts... [infra.host] Connected --> Preparing operations... --> Preparing Operations... Loading: custom/tests/pyinfra_python_call_callback.py [infra.host] Ready: custom/tests/pyinfra_python_call_callback.py [2024-02-23 09:10:31,046] DEBUG [paramiko.transport:1909] Received global request "[email protected]" [2024-02-23 09:10:31,047] DEBUG [paramiko.transport:1909] Rejecting "[email protected]" global request from server. [2024-02-23 09:10:31,047] DEBUG [paramiko.transport:1909] Debug msg: b'/home/project/.ssh/authorized_keys:3: key options: agent-forwarding port-forwarding pty user-rc x11-forwarding' --> Skipping change detection --> Beginning operation run... --> Starting operation: Execute server_op_callback function Starting nested operation: Server/Shell (commands=['ls -lha']) [2024-02-23 09:10:31,253] DEBUG [paramiko.transport:1210] [chan 0] Max packet in: 32768 bytes [2024-02-23 09:10:31,275] DEBUG [paramiko.transport:1210] [chan 0] Max packet out: 32768 bytes [2024-02-23 09:10:31,276] DEBUG [paramiko.transport:1909] Secsh channel 0 opened. [2024-02-23 09:10:31,303] DEBUG [paramiko.transport:1210] [chan 0] Sesch channel 0 request ok [2024-02-23 09:10:31,324] DEBUG [paramiko.transport:1210] [chan 0] EOF received (0) [2024-02-23 09:10:31,324] DEBUG [paramiko.transport:1210] [chan 0] EOF sent (0) [infra.host] nested Success [2024-02-23 09:10:31,326] DEBUG [builtins:13] <class 'pyinfra.api.operation.OperationMeta'> Traceback (most recent call last): File "src/gevent/greenlet.py", line 908, in gevent._gevent_cgreenlet.Greenlet.run File "/home/me/codes/project/backend/deploy-prod/venv/lib/python3.11/site-packages/pyinfra/api/command.py", line 229, in execute_function self.function(*self.args, **self.kwargs) File "custom/tests/pyinfra_python_call_callback.py", line 14, in server_op_callback logger.debug(str(result.stdout)) ^^^^^^^^^^^^^ File "/home/me/codes/project/backend/deploy-prod/venv/lib/python3.11/site-packages/pyinfra/api/operation.py", line 115, in stdout return "\n".join(self.stdout_lines) ^^^^^^^^^^^^^^^^^ File "/home/me/codes/project/backend/deploy-prod/venv/lib/python3.11/site-packages/pyinfra/api/operation.py", line 107, in stdout_lines return self._get_lines(types=("stdout",)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/me/codes/project/backend/deploy-prod/venv/lib/python3.11/site-packages/pyinfra/api/operation.py", line 103, in _get_lines return [line for type_, line in self._combined_output_lines if type_ in types] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/me/codes/project/backend/deploy-prod/venv/lib/python3.11/site-packages/pyinfra/api/operation.py", line 103, in <listcomp> return [line for type_, line in self._combined_output_lines if type_ in types] ^^^^^^^^^^^ TypeError: cannot unpack non-iterable OutputLine object 2024-02-23T08:10:31Z <Greenlet at 0x7f5c7c2058a0: execute_function> failed with TypeError Traceback (most recent call last): File "/home/me/codes/project/backend/deploy-prod/venv/lib/python3.11/site-packages/pyinfra/api/operations.py", line 95, in _run_host_op status = command.execute(state, host, connector_arguments) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/me/codes/project/backend/deploy-prod/venv/lib/python3.11/site-packages/pyinfra/api/command.py", line 232, in execute return greenlet.get() ^^^^^^^^^^^^^^ File "src/gevent/greenlet.py", line 831, in gevent._gevent_cgreenlet.Greenlet.get File "src/gevent/greenlet.py", line 373, in gevent._gevent_cgreenlet.Greenlet._raise_exception File "/home/me/codes/project/backend/deploy-prod/venv/lib/python3.11/site-packages/gevent/_compat.py", line 49, in reraise raise value.with_traceback(tb) File "src/gevent/greenlet.py", line 908, in gevent._gevent_cgreenlet.Greenlet.run File "/home/me/codes/project/backend/deploy-prod/venv/lib/python3.11/site-packages/pyinfra/api/command.py", line 229, in execute_function self.function(*self.args, **self.kwargs) ^^^^^^^^^^^^^^^^^ File "custom/tests/pyinfra_python_call_callback.py", line 14, in server_op_callback logger.debug(str(result.stdout)) ^^^^^^^^^^^^^^^^^ File "/home/me/codes/project/backend/deploy-prod/venv/lib/python3.11/site-packages/pyinfra/api/operation.py", line 115, in stdout return "\n".join(self.stdout_lines) ^^^^^^^^^^^^^^^^^ File "/home/me/codes/project/backend/deploy-prod/venv/lib/python3.11/site-packages/pyinfra/api/operation.py", line 107, in stdout_lines return self._get_lines(types=("stdout",)) ^^^^^^^^^^^^^^^^^ File "/home/me/codes/project/backend/deploy-prod/venv/lib/python3.11/site-packages/pyinfra/api/operation.py", line 103, in _get_lines return [line for type_, line in self._combined_output_lines if type_ in types] ^^^^^^^^^^^^^^^^^ File "/home/me/codes/project/backend/deploy-prod/venv/lib/python3.11/site-packages/pyinfra/api/operation.py", line 103, in <listcomp> return [line for type_, line in self._combined_output_lines if type_ in types] ^^^^^^^^^^^^^^^^^ TypeError: cannot unpack non-iterable OutputLine object [infra.host] Unexpected error in Python callback: TypeError('cannot unpack non-iterable OutputLine object',) [infra.host] Error: executed 0 commands --> Disconnecting from hosts... --> pyinfra error: No hosts remaining! [2024-02-23 09:10:31,450] DEBUG [paramiko.transport:1909] EOF in transport thread
in v2 output is:
--> Loading config... --> Loading inventory... --> Connecting to hosts... [infra.host] Connected --> Preparing Operations... Loading: custom/tests/pyinfra_python_call_callback.py [infra.host] Ready: custom/tests/pyinfra_python_call_callback.py [2024-02-23 09:16:29,976] INFO [pyinfra:168] [infra.host] Ready: custom/tests/pyinfra_python_call_callback.py [2024-02-23 09:16:29,977] DEBUG [paramiko.transport:1909] Received global request "[email protected]" [2024-02-23 09:16:29,977] DEBUG [paramiko.transport:1909] Rejecting "[email protected]" global request from server. [2024-02-23 09:16:29,977] DEBUG [paramiko.transport:1909] Debug msg: b'/home/project/.ssh/authorized_keys:3: key options: agent-forwarding port-forwarding pty user-rc x11-forwarding' --> Proposed changes: Groups: inventory / infra [2024-02-23 09:16:30,177] INFO [pyinfra:202] Groups: inventory / infra [infra.host] Operations: 1 Change: 1 No change: 0 [2024-02-23 09:16:30,178] INFO [pyinfra:202] [infra.host] Operations: 1 Change: 1 No change: 0 --> Beginning operation run... --> Starting operation: Execute server_op_callback function [2024-02-23 09:16:30,178] INFO [pyinfra:230] --> Starting operation: Execute server_op_callback function Note: nested operations are currently in beta (line 392 in venv/lib/python3.11/site-packages/pyinfra/api/operation.py) More information: https://docs.pyinfra.com/en/2.x/using-operations.html#nested-operations [2024-02-23 09:16:30,188] WARNING [pyinfra:339] Note: nested operations are currently in beta (line 392 in venv/lib/python3.11/site-packages/pyinfra/api/operation.py) More information: https://docs.pyinfra.com/en/2.x/using-operations.html#nested-operations Starting nested operation: Server/Shell (commands=['ls -lha']) [2024-02-23 09:16:30,188] INFO [pyinfra:230] Starting nested operation: Server/Shell (commands=['ls -lha']) [2024-02-23 09:16:30,189] DEBUG [paramiko.transport:1210] [chan 0] Max packet in: 32768 bytes [2024-02-23 09:16:30,215] DEBUG [paramiko.transport:1210] [chan 0] Max packet out: 32768 bytes [2024-02-23 09:16:30,215] DEBUG [paramiko.transport:1909] Secsh channel 0 opened. [2024-02-23 09:16:30,242] DEBUG [paramiko.transport:1210] [chan 0] Sesch channel 0 request ok [2024-02-23 09:16:30,263] DEBUG [paramiko.transport:1210] [chan 0] EOF received (0) [2024-02-23 09:16:30,263] DEBUG [paramiko.transport:1210] [chan 0] EOF sent (0) [infra.host] nested Success [2024-02-23 09:16:30,264] INFO [pyinfra:176] [infra.host] nested Success [2024-02-23 09:16:30,265] DEBUG [builtins:13] <class 'pyinfra.api.operation.OperationMeta'> [2024-02-23 09:16:30,265] DEBUG [builtins:14] total 28K drwxr-xr-x 3 project project 4.0K Jan 30 05:03 . drwxr-xr-x 3 root root 4.0K Jan 29 16:49 .. -rw------- 1 project project 223 Feb 20 13:31 .bash_history -rw-r--r-- 1 project project 220 Apr 23 2023 .bash_logout -rw-r--r-- 1 project project 3.5K Apr 23 2023 .bashrc -rw-r--r-- 1 project project 807 Apr 23 2023 .profile drwx------ 2 project project 4.0K Jan 29 16:49 .ssh -rw-r--r-- 1 project project 0 Jan 29 16:56 .sudo_as_admin_successful [infra.host] Success [2024-02-23 09:16:30,265] INFO [pyinfra:176] [infra.host] Success --> Results: Groups: inventory / infra [2024-02-23 09:16:30,381] INFO [pyinfra:202] Groups: inventory / infra [infra.host] Changed: 2 No change: 0 Errors: 0 [2024-02-23 09:16:30,381] INFO [pyinfra:202] [infra.host] Changed: 2 No change: 0 Errors: 0 [2024-02-23 09:16:30,382] DEBUG [paramiko.transport:1909] EOF in transport thread
return or output of command result
The text was updated successfully, but these errors were encountered:
Fizzadar
No branches or pull requests
Describe the bug
server.shell(command...)).stdout gives error TypeError('cannot unpack non-iterable OutputLine object',)
To Reproduce
try this task in v2.9 vs 3.0.
output
in v2 output is:
Expected behavior
return or output of command result
Meta
The text was updated successfully, but these errors were encountered: