ansible / ansible-policy

ansible-policy is a prototype implementation which allows us to define and set constraints to the Ansible project in OPA Rego language.
Apache License 2.0
20 stars 10 forks source link

error when using os.get_terminal_size in sub proccess #21

Closed ldjebran closed 5 months ago

ldjebran commented 5 months ago

after the latest (yesterday) changes os.get_terminal_size is failing when used in a subprocess

stderr: b'Traceback (most recent call last):\n  File "<frozen runpy>", line 198, in _run_module_as_main\n  File "<frozen runpy>", line 88, in _run_code\n  File "/home/ec2-user/.venv/lib64/python3.11/site-packages/ansible_gatekeeper/eval_policy.py", line 74, in <module>\n    main()\n  File "/home/ec2-user/.venv/lib64/python3.11/site-packages/ansible_gatekeeper/eval_policy.py", line 70, in main\n    ResultFormatter(format_type=args.format).print(result=result)\n    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n  File "<string>", line 6, in __init__\n  File "/home/ec2-user/.venv/lib64/python3.11/site-packages/ansible_gatekeeper/models.py", line 723, in __post_init__\n    self.term_width = os.get_terminal_size().columns\n                      ^^^^^^^^^^^^^^^^^^^^^^\nOSError: [Errno 25] Inappropriate ioctl for device\n'

using shutil high level shutil.get_terminal_size() resolve the problem

image

matburt commented 5 months ago

Going to merge this. Let me know if there are issues.