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

Error handling problems #209

Open
pdelboca opened this issue Nov 21, 2023 · 0 comments
Open

Error handling problems #209

pdelboca opened this issue Nov 21, 2023 · 0 comments

Comments

@pdelboca
Copy link
Member

pdelboca commented Nov 21, 2023

Note: I'm running on Python 3.11

I'm facing issues when the package is trying to print to stderr (error logging).

Traceback (most recent call last):
  File "/home/pdelboca/Repos/ckanapi/.venv/bin/ckanapi", line 33, in <module>
    sys.exit(load_entry_point('ckanapi', 'console_scripts', 'ckanapi')())
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/pdelboca/Repos/ckanapi/ckanapi/cli/main.py", line 156, in main
    return dump_things(ckan, thing[0], arguments)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/pdelboca/Repos/ckanapi/ckanapi/cli/dump.py", line 110, in dump_things
    create_datapackage(record, datapackages_path, stderr, apikey)
  File "/home/pdelboca/Repos/ckanapi/ckanapi/datapackage.py", line 72, in create_datapackage
    create_resource(resource, filename, datapackage_dir, stderr, apikey)
  File "/home/pdelboca/Repos/ckanapi/ckanapi/datapackage.py", line 36, in create_resource
    stderr.write('URL {url} refused connection. The resource will not be downloaded\n'.format(url=resource['url']))
TypeError: a bytes-like object is required, not 'str'

It looks like the way we are trying to log things is not working properly. Also, we are trying to log normal workflow to the stderr output. Why is that?

            if not arguments['--quiet']:
                stderr.write('{0} {1} {2} {3} {4}\n'.format(
                    finished,
                    job_ids,
                    next(stats),
                    error,
                    record.get('name', '') if record else '',
                    ).encode('utf-8'))
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

1 participant