rel-eng/packages/spacecmd | 2 +-
spacecmd/spacecmd.spec | 5 ++++-
spacecmd/src/lib/utils.py | 9 ++++++---
3 files changed, 11 insertions(+), 5 deletions(-)
New commits:
commit c3c61a596abfa31150116db85c23f9592f1a65f0
Author: Milan Zazrivec <mzazrivec(a)redhat.com>
Date: Fri Feb 21 16:46:01 2014 +0100
Automatic commit of package [spacecmd] release [2.1.25-1].
diff --git a/rel-eng/packages/spacecmd b/rel-eng/packages/spacecmd
index 7ac4b82..2b42169 100644
--- a/rel-eng/packages/spacecmd
+++ b/rel-eng/packages/spacecmd
@@ -1 +1 @@
-2.1.24-1 spacecmd/
+2.1.25-1 spacecmd/
diff --git a/spacecmd/spacecmd.spec b/spacecmd/spacecmd.spec
index 388d05e..30b28c0 100644
--- a/spacecmd/spacecmd.spec
+++ b/spacecmd/spacecmd.spec
@@ -4,7 +4,7 @@
%endif
Name: spacecmd
-Version: 2.1.24
+Version: 2.1.25
Release: 1%{?dist}
Summary: Command-line interface to Spacewalk and Satellite servers
@@ -64,6 +64,9 @@ touch %{buildroot}/%{python_sitelib}/spacecmd/__init__.py
%doc %{_mandir}/man1/spacecmd.1.gz
%changelog
+* Fri Feb 21 2014 Milan Zazrivec <mzazrivec(a)redhat.com> 2.1.25-1
+- 1060746 - make file_needs_b64_enc work for both str and unicode inputs
+
* Tue Jan 14 2014 Matej Kollar <mkollar(a)redhat.com> 2.1.24-1
- Automatic commit of package [spacecmd] release [2.1.23-1].
commit 6daf599d669ec8b2f835991f0e30ac341e7f1d41
Author: Milan Zazrivec <mzazrivec(a)redhat.com>
Date: Fri Feb 21 16:44:03 2014 +0100
1060746 - make file_needs_b64_enc work for both str and unicode inputs
This is to fix the following TB:
Traceback (most recent call last):
File "/usr/bin/spacecmd", line 133, in <module>
shell.print_result(shell.onecmd( precmd ), precmd)
File "/usr/lib64/python2.6/cmd.py", line 219, in onecmd
return func(arg)
File "/usr/lib/python2.6/site-packages/spacecmd/configchannel.py",
line 976, in do_configchannel_import
if self.import_configchannel_fromdetails(ccdetails) != True:
File "/usr/lib/python2.6/site-packages/spacecmd/configchannel.py",
line 1029, in import_configchannel_fromdetails
elif self.file_needs_b64_enc(filedetails['contents']):
File "/usr/lib/python2.6/site-packages/spacecmd/utils.py", line 742,
in file_needs_b64_enc
return float(len(contents.translate(_null_trans, text_characters))) /
len(contents) > 0.3
TypeError: translate() takes exactly one argument (2 given)
diff --git a/spacecmd/src/lib/utils.py b/spacecmd/src/lib/utils.py
index 5bd341c..91eb5da 100644
--- a/spacecmd/src/lib/utils.py
+++ b/spacecmd/src/lib/utils.py
@@ -736,9 +736,12 @@ def file_needs_b64_enc(self, contents):
return False
text_characters = "".join(map(chr, range(32, 127)) +
list("\n\r\t\b"))
- _null_trans = string.maketrans("", "")
-
# More than 30% non-text characters -> considered a binary file
- return float(len(contents.translate(_null_trans, text_characters))) / len(contents)
> 0.3
+ if isinstance(contents, unicode):
+ translate_table = dict((ord(char), None) for char in text_characters)
+ return float(len(contents.translate(translate_table))) / len(contents) > 0.3
+ if isinstance(contents, str):
+ translate_table = string.maketrans("", "")
+ return float(len(contents.translate(translate_table, text_characters))) /
len(contents) > 0.3
# vim:ts=4:expandtab:
Show replies by date