summaryrefslogtreecommitdiffstats
path: root/pyload.py
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2013-01-25 18:43:53 +0100
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2013-01-25 18:43:53 +0100
commit4b75ae96097741576f5dacd4a366119e56501700 (patch)
treecb9200229aa23fefbb396fac3b3b01cb263c78e9 /pyload.py
parentrefractored icons, + generation task (diff)
downloadpyload-4b75ae96097741576f5dacd4a366119e56501700.tar.xz
fallback when no system locale can be retrieved
Diffstat (limited to 'pyload.py')
-rwxr-xr-xpyload.py24
1 files changed, 15 insertions, 9 deletions
diff --git a/pyload.py b/pyload.py
index 43d091a36..cc5295860 100755
--- a/pyload.py
+++ b/pyload.py
@@ -500,15 +500,21 @@ class Core(object):
def init_logger(self, level):
console = logging.StreamHandler(sys.stdout)
- # change current locale to default if it is not set
- current_locale = locale.getlocale()
- if current_locale == (None, None):
- current_locale = locale.setlocale(locale.LC_ALL, '')
-
- # We use timeformat provided by locale when available
- if current_locale != (None, None):
- tfrm = locale.nl_langinfo(locale.D_FMT) + " " + locale.nl_langinfo(locale.T_FMT)
- else: # normally this case should not be entered
+ # try to get a time formatting depending on system locale
+ tfrm = None
+ try: # change current locale to default if it is not set
+ current_locale = locale.getlocale()
+ if current_locale == (None, None):
+ current_locale = locale.setlocale(locale.LC_ALL, '')
+
+ # We use timeformat provided by locale when available
+ if current_locale != (None, None):
+ tfrm = locale.nl_langinfo(locale.D_FMT) + " " + locale.nl_langinfo(locale.T_FMT)
+ except: # something did go wrong, locale is heavily platform dependant
+ pass
+
+ # default formatting when no ne was obtained
+ if not tfrm:
tfrm = "%d.%m.%Y %H:%M:%S"
frm = logging.Formatter("%(asctime)s %(levelname)-8s %(message)s", tfrm)