[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [gettor/master] Move logfiles to their own subdir again, make the i18n use the actual config values as a fallback. Remove an over-verbose debug output



commit ce7a0674339fa7f3a1fec99a8706524c7c4255f8
Author: Christian Fromme <kaner@xxxxxxxxxx>
Date:   Thu Feb 24 12:07:06 2011 +0100

    Move logfiles to their own subdir again, make the i18n use the actual config values as a fallback. Remove an over-verbose debug output
---
 lib/GetTor.py           |    6 +++++-
 lib/gettor/i18n.py      |    8 +++++---
 lib/gettor/responses.py |    2 +-
 lib/gettor/utils.py     |    1 -
 4 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/lib/GetTor.py b/lib/GetTor.py
index 4c050b6..d7bda02 100644
--- a/lib/GetTor.py
+++ b/lib/GetTor.py
@@ -29,7 +29,11 @@ def initializeLogging(cfg):
     level = getattr(logging, level)
     extra = {}
     logfileName = cfg.LOGFILE + "-" +  strftime("%Y-%m-%d") + ".log"
-    extra['filename'] = os.path.join(cfg.BASEDIR, logfileName)
+    logDir = os.path.join(cfg.BASEDIR, "log")
+    if not gettor.utils.createDir(logDir):
+        # Fall back to /tmp in case of an error
+        logDir="/tmp"
+    extra['filename'] = os.path.join(logDir, logfileName)
 
     print "Logfile is %s" % extra['filename']
 
diff --git a/lib/gettor/i18n.py b/lib/gettor/i18n.py
index 9cb1239..7e5769f 100644
--- a/lib/gettor/i18n.py
+++ b/lib/gettor/i18n.py
@@ -6,12 +6,14 @@
 import os
 import gettext
 
-def getLang(lang, localedir=os.path.expanduser("~") + "/gettor/i18n"):
+def getLang(lang, config):
     """Return the Translation instance for a given language. If no Translation
        instance is found, return the one for 'en'
     """
-    return gettext.translation("gettor", localedir=localedir,
-                               languages=[lang], fallback="en")
+    localeDir = os.path.join(config.BASEDIR, "i18n")
+    fallback = config.DEFAULT_LOCALE
+    return gettext.translation("gettor", localedir=localeDir,
+                               languages=[lang], fallback=fallback)
 
 def _(text):
     """This is necessary because strings are translated when they're imported.
diff --git a/lib/gettor/responses.py b/lib/gettor/responses.py
index c9dba54..86e43f2 100644
--- a/lib/gettor/responses.py
+++ b/lib/gettor/responses.py
@@ -110,7 +110,7 @@ class Response:
         logging.info(str(self.reqInfo))
 
         # Initialize locale subsystem
-        self.t = i18n.getLang(self.reqInfo['locale'])
+        self.t = i18n.getLang(self.reqInfo['locale'], config)
 
         # Init black & whitelists
         wlStateDir = os.path.join(self.config.BASEDIR, "wl")
diff --git a/lib/gettor/utils.py b/lib/gettor/utils.py
index 958bfdb..0a51760 100644
--- a/lib/gettor/utils.py
+++ b/lib/gettor/utils.py
@@ -22,7 +22,6 @@ def createDir(path):
        already exists.
     """
     try:
-        logging.debug("Creating directory %s if it doesn't exist.." % path)
         os.makedirs(path)
     except OSError as e:
         if e.errno != errno.EEXIST:



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits