From 1d0fcc05f8b9bd92a91dd50d67c6f72e7bf6461a Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 12 Apr 2008 09:16:14 +0530 Subject: [PATCH] Don't die if setting C locale fails --- src/calibre/__init__.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/calibre/__init__.py b/src/calibre/__init__.py index e842bf4fbb..858bc21508 100644 --- a/src/calibre/__init__.py +++ b/src/calibre/__init__.py @@ -24,9 +24,12 @@ terminal_controller = TerminalController(sys.stdout) iswindows = 'win32' in sys.platform.lower() or 'win64' in sys.platform.lower() isosx = 'darwin' in sys.platform.lower() -islinux = not(iswindows or isosx) +islinux = not(iswindows or isosx) -locale.setlocale(locale.LC_ALL, '') +try: + locale.setlocale(locale.LC_ALL, '') +except: + pass def osx_version(): if isosx: @@ -249,7 +252,7 @@ def fit_image(width, height, pwidth, pheight): scaled = height > pheight or width > pwidth if height > pheight: corrf = pheight/float(height) - width, height = floor(corrf*width), pheight + width, height = floor(corrf*width), pheight if width > pwidth: corrf = pwidth/float(width) width, height = pwidth, floor(corrf*height) @@ -257,7 +260,7 @@ def fit_image(width, height, pwidth, pheight): corrf = pheight/float(height) width, height = floor(corrf*width), pheight - return scaled, int(width), int(height) + return scaled, int(width), int(height) def set_translator(): # To test different translations invoke as