summaryrefslogtreecommitdiffstats
path: root/src/lib/Bcfg2Py3k.py
diff options
context:
space:
mode:
authorChris St. Pierre <chris.a.st.pierre@gmail.com>2011-10-27 08:49:09 -0400
committerChris St. Pierre <chris.a.st.pierre@gmail.com>2011-10-27 08:49:09 -0400
commitfff865e8f428f93c7718b9932552ea0261a95500 (patch)
treef2a2d5db8b46b37c17292b5828f6ae4f81c66cec /src/lib/Bcfg2Py3k.py
parente2261d351c8f11a9cef4b47b6db9774761b4dd5b (diff)
downloadbcfg2-fff865e8f428f93c7718b9932552ea0261a95500.tar.gz
bcfg2-fff865e8f428f93c7718b9932552ea0261a95500.tar.bz2
bcfg2-fff865e8f428f93c7718b9932552ea0261a95500.zip
Add a number of features to SSHbase:
* Support for group-specific host keys * Support for fully static host- and group-specific ssh_known_hosts * (Support for totally generic host keys and ssh_known_hosts, too, but that's pretty useless.) * Support for info.xml, info, and :info files; only info.xml is likely to be useful, with the <Path> directive
Diffstat (limited to 'src/lib/Bcfg2Py3k.py')
-rw-r--r--src/lib/Bcfg2Py3k.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/lib/Bcfg2Py3k.py b/src/lib/Bcfg2Py3k.py
index 4803bf8b2..ee05b7e41 100644
--- a/src/lib/Bcfg2Py3k.py
+++ b/src/lib/Bcfg2Py3k.py
@@ -63,11 +63,17 @@ except ImportError:
import http.client as httplib
# print to file compatibility
-def u_str(string):
+def u_str(string, encoding=None):
if sys.hexversion >= 0x03000000:
- return string
+ if encoding is not None:
+ return string.encode(encoding)
+ else:
+ return string
else:
- return unicode(string)
+ if encoding is not None:
+ return unicode(string, encoding)
+ else:
+ return unicode(string)
"""
In order to use the new syntax for printing to a file, we need to do