Ticket #549: unicode_support.diff
File unicode_support.diff, 5.5 KB (added by [email protected]…, 15 years ago) |
---|
-
src/lib/Server/Plugins/Cfg.py
77 77 if entry.get('encoding') == 'base64': 78 78 entry.text = binascii.b2a_base64(data) 79 79 else: 80 entry.text = data80 entry.text = unicode(data, "utf-8") 81 81 if entry.text in ['', None]: 82 82 entry.set('empty', 'true') 83 83 -
src/lib/Server/Plugins/TCheetah.py
34 34 self.template.path = entry.get('realname', entry.get('name')) 35 35 36 36 try: 37 entry.text = str(self.template)37 entry.text = unicode(str(self.template),'UTF-8') 38 38 except: 39 39 (a, b, c) = sys.exc_info() 40 40 msg = traceback.format_exception(a, b, c, limit=2)[-1][:-1] -
src/lib/Client/Tools/POSIX.py
320 320 self.logger.error("Cannot verify incomplete ConfigFile %s" % (entry.get('name'))) 321 321 return False 322 322 tempdata = entry.text 323 if type(tempdata) == unicode: 324 tempdata = tempdata.encode('UTF-8') 323 325 try: 324 326 content = open(entry.get('name')).read() 325 327 except IOError, error: 326 328 self.logger.error("Failed to read %s: %s" % (error.filename, error.strerror)) 327 329 return False 330 # comparaison should be done with figerprints or md5sum so it would be faster 331 # for big binary files 328 332 contentStatus = content == tempdata 329 333 if not contentStatus: 330 334 if tbin or not isString(content): … … 348 352 break 349 353 if do_diff: 350 354 diff = '\n'.join(rawdiff) 351 entry.set("current_bdiff", binascii.b2a_base64(diff)) 355 # entry.set("current_bdiff", binascii.b2a_base64(diff)) 356 # entry.set("current_diff", diff) 352 357 udiff = '\n'.join([x for x in \ 353 358 difflib.unified_diff(content.split('\n'), \ 354 359 tempdata.split('\n'))]) … … 356 361 eudiff = udiff.encode('ascii') 357 362 except: 358 363 eudiff = "Binary file: no diff printed" 364 359 365 nqtext = entry.get('qtext', '') 360 366 361 367 if nqtext: … … 417 423 elif entry.get('empty', 'false') == 'true': 418 424 filedata = '' 419 425 else: 420 filedata = entry.text 426 if type(entry.text) == unicode: 427 filedata = entry.text.encode('UTF-8') 428 else: 429 filedata = entry.text 421 430 newfile.write(filedata) 422 431 newfile.close() 423 432 try: -
src/sbin/bcfg2-server
103 103 for plugin in self.Core.plugins.values(): 104 104 for probe in plugin.GetProbes(meta): 105 105 resp.append(probe) 106 return tostring(resp) 106 data = "<?xml version='1.0' encoding='UTF-8' ?>\n" 107 data += tostring(resp, encoding='UTF-8') 108 return data 107 109 except Bcfg2.Server.Plugins.Metadata.MetadataConsistencyError: 108 110 warning = 'Client metadata resolution error for %s' % address[0] 109 111 self.logger.warning(warning) … … 157 159 '''Build config for a client''' 158 160 try: 159 161 client = self.Core.metadata.resolve_client(address) 160 return tostring(self.Core.BuildConfiguration(client)) 162 return "<?xml version='1.0' encoding='UTF-8' ?>\n" + \ 163 tostring(self.Core.BuildConfiguration(client), encoding='UTF-8') 161 164 except Bcfg2.Server.Plugins.Metadata.MetadataConsistencyError: 162 165 self.logger.warning("Metadata consistency failure for %s" % (address)) 163 166 raise Fault, (6, "Metadata consistency failure") -
src/sbin/bcfg2-info
97 97 if len(args.split()) == 2: 98 98 client, ofile = args.split() 99 99 output = open(ofile, 'w') 100 data = lxml.etree.tostring(self.BuildConfiguration(client)) 100 output.write("<?xml version='1.0' encoding='UTF-8'?>") 101 data = lxml.etree.tostring(self.BuildConfiguration(client), encoding='UTF-8') 101 102 output.write(data) 102 103 output.close() 103 104 else: … … 121 122 entry = lxml.etree.Element('ConfigFile', name=fname) 122 123 metadata = self.metadata.get_metadata(client) 123 124 self.Bind(entry, metadata) 124 print lxml.etree.tostring(entry )125 print lxml.etree.tostring(entry, encoding="UTF-8") 125 126 else: 126 127 print 'Usage: buildfile filename hostname' 127 128