SUSE Manager, Cobbler and UTF-8

I’ve come across a little nuisance, which took some days to become buggin’ enough to make me look up the solution. Since you’re reading this article, you’re probably facing the same problem:

During the progress of debugging a Cobbler AutoYaST profile template, I wanted to take a closer look at what profile Cobbler is actually delivering to the installed system, after all the template processing. There’ a nice command for this, “cobbler system getks –name <systemname>“. But that made the many profile lines fly by on the console, so I wanted to pipe the result to “more” and into “vi”. But unexpectedly, that call threw an error:

suma:~ # cobbler system getks --name mynewsystem|more
Traceback (most recent call last):
  File "/usr/bin/cobbler", line 36, in <module>
  File "/usr/lib/python2.7/site-packages/cobbler/", line 653, in main
    rc =
  File "/usr/lib/python2.7/site-packages/cobbler/", line 280, in run
    self.object_command(object_type, object_action)
  File "/usr/lib/python2.7/site-packages/cobbler/", line 396, in object_command
    print data
UnicodeEncodeError: 'ascii' codec can't encode characters in position 53590-53591: ordinal not in range(128)
suma:~ #

Again, running the command without any piping works without error, so what’s up? And more important, what needs to be done to fix it?

Fortunately, the solution is pretty simple, and the error message already gives the according hint: Obviously, some characters in the output stream won’t work with the currently active (within the Python environment of this call) character encoding. According to the error message, the current encoding is set to ASCII. That is the actual Python default, even in 2018, and today’s systems rather run on UTF-8.

You’ll only hit this problem if your profiles contain non-ASCII characters, thought.

An easy fix is available, as you only need to tell your Python program to use the UTF-8 encoding. One way to do so is via an environment variable, which you need to set before executing your Python program (i. e. “cobbler”):


Once that’s done, piping the output works without error.

This entry was posted in SUSE Manager. Bookmark the permalink.

Leave a Reply