summaryrefslogtreecommitdiffstats
path: root/src/lib/Client
diff options
context:
space:
mode:
authorNarayan Desai <desai@mcs.anl.gov>2008-06-30 15:59:01 +0000
committerNarayan Desai <desai@mcs.anl.gov>2008-06-30 15:59:01 +0000
commite32bbfbca5233d4ad7a5bee74698d614ff0b1f24 (patch)
tree5f6b08da35732532f2b3d8761bd7f26a61ce8aab /src/lib/Client
parent477603f8f0680f40781559ec1cee8f85c2d76913 (diff)
downloadbcfg2-e32bbfbca5233d4ad7a5bee74698d614ff0b1f24.tar.gz
bcfg2-e32bbfbca5233d4ad7a5bee74698d614ff0b1f24.tar.bz2
bcfg2-e32bbfbca5233d4ad7a5bee74698d614ff0b1f24.zip
Unicode support (from stousignant) (Resolves Ticket #549)
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@4731 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src/lib/Client')
-rw-r--r--src/lib/Client/Tools/POSIX.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/lib/Client/Tools/POSIX.py b/src/lib/Client/Tools/POSIX.py
index ec7d3383d..df8558e1d 100644
--- a/src/lib/Client/Tools/POSIX.py
+++ b/src/lib/Client/Tools/POSIX.py
@@ -320,11 +320,15 @@ class POSIX(Bcfg2.Client.Tools.Tool):
self.logger.error("Cannot verify incomplete ConfigFile %s" % (entry.get('name')))
return False
tempdata = entry.text
+ if type(tempdata) == unicode:
+ tempdata = tempdata.encode(self.setup['encoding'])
try:
content = open(entry.get('name')).read()
except IOError, error:
self.logger.error("Failed to read %s: %s" % (error.filename, error.strerror))
return False
+ # comparaison should be done with figerprints or md5sum so it would be faster
+ # for big binary files
contentStatus = content == tempdata
if not contentStatus:
if tbin or not isString(content):
@@ -348,7 +352,8 @@ class POSIX(Bcfg2.Client.Tools.Tool):
break
if do_diff:
diff = '\n'.join(rawdiff)
- entry.set("current_bdiff", binascii.b2a_base64(diff))
+# entry.set("current_bdiff", binascii.b2a_base64(diff))
+# entry.set("current_diff", diff)
udiff = '\n'.join([x for x in \
difflib.unified_diff(content.split('\n'), \
tempdata.split('\n'))])
@@ -356,6 +361,7 @@ class POSIX(Bcfg2.Client.Tools.Tool):
eudiff = udiff.encode('ascii')
except:
eudiff = "Binary file: no diff printed"
+
nqtext = entry.get('qtext', '')
if nqtext:
@@ -417,7 +423,10 @@ class POSIX(Bcfg2.Client.Tools.Tool):
elif entry.get('empty', 'false') == 'true':
filedata = ''
else:
- filedata = entry.text
+ if type(entry.text) == unicode:
+ filedata = entry.text.encode(self.setup['encoding'])
+ else:
+ filedata = entry.text
newfile.write(filedata)
newfile.close()
try: