nicolas-r / katello-centos-errata-import

Imports CentOS (from http://cefs.steve-meier.de/) errata into Katello
28 stars 11 forks source link

UnicodeEncodeError #16

Open thefretrunner opened 3 years ago

thefretrunner commented 3 years ago

I get an error when running the import:

2021-02-06 14:12:29,837 :: DEBUG :: Processing errata CESA-2016:0372 2021-02-06 14:12:29,837 :: DEBUG :: Working on OS release 7 2021-02-06 14:12:29,837 :: DEBUG :: Packages list for errata CESA-2016:0372 for OS release 7: ['openssl098e-0.9.8e-29.el7.centos.3.i686.rpm', 'openssl098e-0.9.8e-29.el7.centos.3.x86_64.rpm'] 2021-02-06 14:12:29,837 :: DEBUG :: Working on repository Centos_7_base_x86_64 Traceback (most recent call last): File "./centos-errata-katello-importer.py", line 223, in subprocess.call(pulp_cmd) File "/usr/lib64/python3.6/subprocess.py", line 287, in call with Popen(*popenargs, **kwargs) as p: File "/usr/lib64/python3.6/subprocess.py", line 729, in init restore_signals, start_new_session) File "/usr/lib64/python3.6/subprocess.py", line 1295, in _execute_child restore_signals, start_new_session, preexec_fn) UnicodeEncodeError: 'ascii' codec can't encode character '\xe4' in position 2440: ordinal not in range(128)

thefretrunner commented 3 years ago

I don't know how to do pull requests but the fix is quite simple.

Change line 208 in centos-errata-katello-importer.py to:

pulp_cmd.append('--description=' + str(errata.get_description().encode('utf-8')))

Basically convert unicode to ascii using utf-8 encode and cast to str()

At least it works fine for me.

thefretrunner commented 3 years ago

Looking more in the code I can see the description of the errata never gets imported. It is hardcoded to N/A. Any reason for this?