ckan / ckan/ckanapi

Error handling problems

Open
#209 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
212
Forks
81
PR merge metrics
No merged PRs in 30d

Description

**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
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?

```python
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'))

```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.