1
0
mirror of https://github.com/EDCD/EDMarketConnector.git synced 2025-04-14 16:27:13 +03:00

Fix for translated exception text.

This commit is contained in:
Jonathan Harris 2015-09-12 04:08:10 +01:00
parent 9273e1e3d7
commit 68ea048ce5
3 changed files with 17 additions and 12 deletions

View File

@ -168,16 +168,16 @@ class AppWindow:
flightlog.openlog()
except Exception as e:
if __debug__: print_exc()
self.status['text'] = str(e)
self.status['text'] = unicode(e)
except companion.VerificationRequired:
# don't worry about authentication now - prompt on query
self.status['text'] = ''
except companion.ServerError as e:
self.status['text'] = str(e)
self.status['text'] = unicode(e)
except Exception as e:
if __debug__: print_exc()
self.status['text'] = str(e)
self.status['text'] = unicode(e)
self.cooldown()
# callback after verification code
@ -186,7 +186,7 @@ class AppWindow:
self.session.verify(code)
except Exception as e:
if __debug__: print_exc()
self.status['text'] = str(e)
self.status['text'] = unicode(e)
else:
return self.getandsend() # try again
@ -298,7 +298,7 @@ class AppWindow:
# Companion API problem
except companion.ServerError as e:
self.status['text'] = str(e)
self.status['text'] = unicode(e)
if play_sound: hotkeymgr.play_bad()
except requests.exceptions.ConnectionError as e:
@ -313,7 +313,7 @@ class AppWindow:
except Exception as e:
if __debug__: print_exc()
self.status['text'] = str(e)
self.status['text'] = unicode(e)
if play_sound: hotkeymgr.play_bad()
self.cooldown()

View File

@ -99,12 +99,16 @@ def listify(thing):
class ServerError(Exception):
def __str__(self):
def __unicode__(self):
return _('Error: Server is down')
def __str__(self):
return unicode(self).encode('utf-8')
class CredentialsError(Exception):
def __str__(self):
def __unicode__(self):
return _('Error: Invalid Credentials')
def __str__(self):
return unicode(self).encode('utf-8')
class VerificationRequired(Exception):
pass

View File

@ -54,13 +54,14 @@ class Translations:
if __debug__:
def translate(self, x):
if x in self.translations:
return self.translations[x]
else:
if not self.translations.get(x):
print 'Missing translation: "%s"' % x
return x
else:
return self.translations.get(x) or x
else:
def translate(self, x):
return self.translations.get(x, x)
return self.translations.get(x, x) or x
# Returns list of available language codes
def available(self):