Skip to content
New issue

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

--quiet option yields TypeError #82

Closed
chennin opened this issue Dec 19, 2019 · 1 comment
Closed

--quiet option yields TypeError #82

chennin opened this issue Dec 19, 2019 · 1 comment

Comments

@chennin
Copy link

chennin commented Dec 19, 2019

Python 3.6.9 and 3.5.2 (virtual envs, cloudflare-2.3.1)

$ cli4 -q /ips
Traceback (most recent call last):
  File "/tmp/python3-venv-20191218/bin/cli4", line 8, in <module>
    sys.exit(main())
  File "/tmp/python3-venv-20191218/lib/python3.6/site-packages/cli4/__main__.py", line 13, in main
    cli4(args)
  File "/tmp/python3-venv-20191218/lib/python3.6/site-packages/cli4/cli4.py", line 367, in cli4
    do_it(args)
  File "/tmp/python3-venv-20191218/lib/python3.6/site-packages/cli4/cli4.py", line 362, in do_it
    write_results(results, output)
  File "/tmp/python3-venv-20191218/lib/python3.6/site-packages/cli4/cli4.py", line 199, in write_results
    sys.stdout.write(results)
TypeError: write() argument must be str, not dict

Or python 2.7.12 (Ubuntu 16.04 w/ pip install cloudflare, 2.3.1)

$ cli4 -q /ips
Traceback (most recent call last):
  File "/usr/local/bin/cli4", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python2.7/dist-packages/cli4/__main__.py", line 13, in main
    cli4(args)
  File "/usr/local/lib/python2.7/dist-packages/cli4/cli4.py", line 367, in cli4
    do_it(args)
  File "/usr/local/lib/python2.7/dist-packages/cli4/cli4.py", line 362, in do_it
    write_results(results, output)
  File "/usr/local/lib/python2.7/dist-packages/cli4/cli4.py", line 199, in write_results
    sys.stdout.write(results)
TypeError: expected a string or other character buffer object

The --quiet option sets output to None, but write_results doesn't handle this case. So in this example, results is a dict, is not modified within write_results, and so the call to sys.stdout.write throws the above exception because it is not a string.

Expected results: --quiet should not output anything, not even a newline

@mahtin
Copy link
Collaborator

mahtin commented Jan 14, 2020

Fixed in quiet-option-broken branch and pushed as 2.4.2 onto GitHub and https://pypi.org/project/cloudflare/ (use pip3 install cloudflare).

@mahtin mahtin closed this as completed Jan 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants