Fix non ascii chars in the html export causing a crash

This commit is contained in:
sakari
2012-08-08 17:43:14 +02:00
parent 31065f3437
commit 89b3c8dc87

View File

@@ -64,19 +64,19 @@ class exportHtmlThread(threading.Thread):
self.categoryList = list(sMarket.getShipRoot()) self.categoryList = list(sMarket.getShipRoot())
self.categoryList.sort(key=lambda ship: ship.name) self.categoryList.sort(key=lambda ship: ship.name)
for shipType in self.categoryList: for shipType in self.categoryList:
ships = sMarket.getShipList(shipType.ID) ships = sMarket.getShipList(shipType.ID)
for ship in ships: for ship in ships:
HTMLship = '<li><h2>' + ship.name + '</h2><ul>' HTMLship = '<li><h2>' + ship.name + '</h2><ul>'
fits = sFit.getFitsWithShip(ship.ID) fits = sFit.getFitsWithShip(ship.ID)
for fit in fits: for fit in fits:
if self.stopRunning: if self.stopRunning:
return; return;
dnaFit = sFit.exportDna(fit[0]) dnaFit = sFit.exportDna(fit[0])
HTMLship += "<li><a href=\"javascript:CCPEVE.showFitting('" + dnaFit + "');\" >" + fit[1] + "</a></li>" HTMLship += "<li><a href=\"javascript:CCPEVE.showFitting('" + dnaFit + "');\" >" + fit[1] + "</a></li>"
HTMLship += "</ul></li>" HTMLship += "</ul></li>"
if len(fits) > 0: if len(fits) > 0:
HTML += HTMLship HTML += HTMLship
HTML += """ HTML += """
</ul> </ul>
@@ -87,7 +87,7 @@ class exportHtmlThread(threading.Thread):
try: try:
FILE = open(settings.getPath(), "w") FILE = open(settings.getPath(), "w")
FILE.write(HTML); FILE.write(HTML.encode('utf-8'));
FILE.close(); FILE.close();
except IOError: except IOError:
print "Failed to write to " + settings.getPath() print "Failed to write to " + settings.getPath()