Skip to content

Commit

Permalink
no setlocale on Windows (issue #1)
Browse files Browse the repository at this point in the history
  • Loading branch information
Cornelius Ratsch committed Aug 20, 2014
1 parent fe00b5a commit 7ad4d03
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 15 deletions.
7 changes: 0 additions & 7 deletions eurest_lunch_menu/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ def initialize(cls, url=None):
cls._toggleMessages = cls.loadMessagesForLocale(cls._messages["toggleLocale"])

try:
locale.setlocale(locale.LC_TIME, (cls.defaultLocaleString,"UTF-8"))
cls._lunchMenus, cls._additives = cls.readLunchMenus(cls.defaultLocaleString, cls._messages)
except Exception as e:
log_exception(u"Error reading lunch menus")
Expand All @@ -144,19 +143,13 @@ def initialize(cls, url=None):
pass

try:
locale.setlocale(locale.LC_TIME, (cls._messages['toggleLocale'],"UTF-8"))
cls._toggleLunchMenus, cls._toggleAdditives = cls.readLunchMenus(cls._messages['toggleLocale'], cls._toggleMessages)
except Exception as e:
cls._toggleLunchMenus = []
for _ in range(5):
cls._toggleLunchMenus.append(e)
pass

try:
locale.setlocale(locale.LC_TIME, (cls.defaultLocaleString,"UTF-8"))
except:
pass

cls._allLunchMenus = cls._lunchMenus + cls._toggleLunchMenus
cls._lastUpdate = datetime.datetime.now()

Expand Down
14 changes: 6 additions & 8 deletions eurest_lunch_menu_gui/lunch_menu_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,8 @@
import subprocess
from PyQt4.QtGui import QLabel, QWidget, QHBoxLayout, QVBoxLayout, QPushButton, QComboBox, QTextEdit, QStackedWidget, QToolButton, QFont, QMessageBox, QSizePolicy, QTextListFormat
from PyQt4.QtCore import Qt, QSize, QEvent, QPoint

try:
from lunchinator import log_exception, log_debug, convert_string
except ImportError:
sys.path.insert(0, os.getenv("HOME") + "/.lunchinator-dist-sap")
from lunchinator import log_exception, log_debug, convert_string
from lunchinator import log_exception, log_debug, convert_string
from lunchinator.utilities import getPlatform, PLATFORM_WINDOWS

try:
from eurest_lunch_menu import LunchMenu
Expand Down Expand Up @@ -316,7 +312,8 @@ def createNotebook(self):
for index in range(10):
if index == 5:
try:
locale.setlocale(locale.LC_TIME, (self.messages["toggleLocale"],"UTF-8"))
if getPlatform() != PLATFORM_WINDOWS:
locale.setlocale(locale.LC_TIME, (self.messages["toggleLocale"],"UTF-8"))
except:
log_exception("error setting locale")
curMessages = self.toggleMessages
Expand All @@ -342,7 +339,8 @@ def createNotebook(self):

self.menuNotebook.addWidget(pageWidget)
try:
locale.setlocale(locale.LC_TIME, (LunchMenu.defaultLocaleString,"UTF-8"))
if getPlatform() != PLATFORM_WINDOWS:
locale.setlocale(locale.LC_TIME, (LunchMenu.defaultLocaleString,"UTF-8"))
except:
log_exception("error setting locale")

Expand Down

0 comments on commit 7ad4d03

Please sign in to comment.