Skip to content

Commit a56184d

Browse files
author
Ferry Boender
committed
Prevent UnicodeDecodeError on non-ascii hostnames
1 parent bd55cc5 commit a56184d

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

src/ansiblecmdb/data/tpl/csv.tpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ writer = csv.writer(sys.stdout, delimiter=',', quotechar='"', quoting=csv.QUOTE_
3636
writer.writerow(fieldnames)
3737
for hostname, host in hosts.items():
3838
if 'ansible_facts' not in host:
39-
sys.stderr.write('{0}: No info collected.\n'.format(hostname))
39+
sys.stderr.write(u'{0}: No info collected.\n'.format(hostname))
4040
else:
4141
out_cols = []
4242
for col in get_cols():

src/ansiblecmdb/data/tpl/html_fancy_split.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def render(hosts, vars={}, tpl_dirs=[]):
2626
# Render host details
2727
template = lookup.get_template('html_fancy_split_detail.tpl')
2828
for hostname, host in hosts.items():
29-
out_file = os.path.join('cmdb', '{0}.html'.format(hostname))
29+
out_file = os.path.join('cmdb', u'{0}.html'.format(hostname))
3030
output = template.render(host=host, **vars).lstrip().decode('utf8')
3131
with codecs.open(out_file, 'w', encoding='utf8') as f:
3232
f.write(output)

src/ansiblecmdb/data/tpl/txt_table.tpl

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,13 @@ for col in get_cols():
4949
sys.stdout.write('\n')
5050

5151
for col in get_cols():
52-
sys.stdout.write('-' * col_longest[col['title']] + (' ' * col_space))
52+
sys.stdout.write(u'-' * col_longest[col['title']] + (u' ' * col_space))
5353
sys.stdout.write('\n')
5454

5555
# Print out columns
5656
for hostname, host in hosts.items():
5757
if 'ansible_facts' not in host:
58-
sys.stderr.write('{0}: No info collected.\n'.format(hostname))
58+
sys.stderr.write(u'{0}: No info collected.\n'.format(hostname))
5959
else:
6060
for col in get_cols():
6161
sys.stdout.write(col['field'](host).ljust(col_longest[col['title']]) + (' ' * col_space))

0 commit comments

Comments
 (0)