[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [gettor/master] More directory moving to make GetTor more standard compliant
commit fc340152a35c026e73b0336d3d8cc3b0bc2c129e
Author: Christian Fromme <kaner@xxxxxxxxxx>
Date: Sat Mar 3 07:49:07 2012 +0100
More directory moving to make GetTor more standard compliant
---
GetTor.py | 5 +++--
lib/gettor/i18n.py | 2 +-
lib/gettor/packages.py | 7 ++++---
lib/gettor/responses.py | 21 ++++++++++++++-------
lib/gettor/utils.py | 16 ++++++++--------
5 files changed, 30 insertions(+), 21 deletions(-)
diff --git a/GetTor.py b/GetTor.py
index d9c378d..106a2a3 100644
--- a/GetTor.py
+++ b/GetTor.py
@@ -30,7 +30,7 @@ def initializeLogging(cfg):
level = getattr(logging, level)
extra = {}
logfileName = cfg.LOGFILE + "-" + strftime("%Y-%m-%d") + ".log"
- logDir = os.path.join(cfg.BASEDIR, "log")
+ logDir = os.path.join(cfg.BASEDIR, 'var', 'log')
if not gettor.utils.createDir(logDir):
# Fall back to /tmp in case of an error
logDir="/tmp"
@@ -54,7 +54,8 @@ def processFail(conf, rawMessage, failedAction, e=None):
if conf.DUMPFILE != "":
# Keep a copy of the failed email for later reference
logging.info("We'll keep a record of this mail.")
- dumpFile = os.path.join(conf.BASEDIR, conf.DUMPFILE)
+ dumpFile = os.path.join(conf.BASEDIR, 'var', 'cache', 'gettor',
+ conf.DUMPFILE)
gettor.utils.dumpMessage(dumpFile, rawMessage)
def processMail(conf):
diff --git a/lib/gettor/i18n.py b/lib/gettor/i18n.py
index 45b95a5..b88d932 100644
--- a/lib/gettor/i18n.py
+++ b/lib/gettor/i18n.py
@@ -10,7 +10,7 @@ def getLang(lang, config):
"""Return the Translation instance for a given language. If no Translation
instance is found, return the one for 'en'
"""
- localeDir = os.path.join(config.BASEDIR, "i18n")
+ localeDir = os.path.join(config.BASEDIR, 'share', 'i18n')
fallback = config.DEFAULT_LOCALE
return gettext.translation("gettor", localedir=localeDir,
languages=[lang], fallback=fallback)
diff --git a/lib/gettor/packages.py b/lib/gettor/packages.py
index 9388361..124c1a5 100644
--- a/lib/gettor/packages.py
+++ b/lib/gettor/packages.py
@@ -59,9 +59,10 @@ class Packages:
def __init__(self, config, silent=False):
self.packageList = {}
- self.distDir = os.path.join(config.BASEDIR, "dist")
- self.packDir = os.path.join(config.BASEDIR, "packages")
- self.docDir = os.path.join(config.BASEDIR, "doc")
+ cache_dir = os.path.join(config.BASEDIR, 'var', 'cache', 'gettor')
+ self.distDir = os.path.join(cache_dir, 'dist')
+ self.packDir = os.path.join(cache_dir, 'packages')
+ self.docDir = os.path.join(cache_dir, 'doc')
self.initRsync(config.RSYNC_MIRROR, silent)
self.packageList = config.PACKAGES
diff --git a/lib/gettor/responses.py b/lib/gettor/responses.py
index dc3e73f..7ab6704 100644
--- a/lib/gettor/responses.py
+++ b/lib/gettor/responses.py
@@ -190,8 +190,10 @@ class Response:
self.t = i18n.getLang(self.reqInfo['locale'], config)
# Init black & whitelists
- wlStateDir = os.path.join(self.config.BASEDIR, "wl")
- blStateDir = os.path.join(self.config.BASEDIR, "bl")
+ wlStateDir = os.path.join(self.config.BASEDIR, 'var', 'cache',
+ 'gettor', 'wl')
+ blStateDir = os.path.join(self.config.BASEDIR, 'var', 'cache',
+ 'gettor', 'bl')
self.wList = gettor.blacklist.BWList(wlStateDir, config.BLACKLIST_THRES)
self.bList = gettor.blacklist.BWList(blStateDir, config.BLACKLIST_THRES)
@@ -224,7 +226,8 @@ class Response:
return True
try:
- package_path = os.path.join(self.config.BASEDIR, "packages", package + ".z")
+ package_path = os.path.join(self.config.BASEDIR, 'var', 'cache',
+ 'gettor', 'packages', package + ".z")
package_size = os.path.getsize(package_path)
if package_size <= max_attach:
return True
@@ -278,7 +281,8 @@ class Response:
# Don't send anything
return False
logging.info("Sending out %s." % (pack))
- f = os.path.join(self.config.BASEDIR, "packages", pack + ".z")
+ f = os.path.join(self.config.BASEDIR, 'var', 'cache', 'gettor',
+ 'packages', pack + ".z")
txt = getPackageMsg(self.t)
msg = self.makeMsg(txt, to, fileName=f)
msg = self.addUserManual(msg, self.reqInfo['locale'])
@@ -299,7 +303,8 @@ class Response:
fwd = self.reqInfo['forward']
to = self.reqInfo['user']
logging.info("Sending out %s." % (pack))
- f = os.path.join(self.config.BASEDIR, "packages", pack + ".z")
+ f = os.path.join(self.config.BASEDIR, 'var', 'cache', 'gettor',
+ 'packages', pack + ".z")
text = getPackageMsg(self.t)
msg = self.makeMsg(text, fwd, fileName=f)
try:
@@ -339,7 +344,8 @@ class Response:
# `package.split' -- this is stupid because we let the user configure
# split package names in gettor.conf.
splitpack = self.reqInfo['package'] + ".split"
- splitDir = os.path.join(self.config.BASEDIR, "packages", splitpack)
+ splitDir = os.path.join(self.config.BASEDIR, 'var', 'cache', 'gettor',
+ 'packages', splitpack)
fileList = os.listdir(splitDir)
# Sort the files, so we can send 01 before 02 and so on..
@@ -468,7 +474,8 @@ class Response:
def addUserManual(self, message, lang="en"):
"""Add the short user manual to an existing message.
"""
- docDir = os.path.join(self.config.BASEDIR, "doc")
+ docDir = os.path.join(self.config.BASEDIR, 'var', 'cache', 'gettor',
+ 'doc')
mName = "short-user-manual_" + lang + ".xhtml"
docName = os.path.join(docDir, mName)
if not os.access(docName, os.R_OK):
diff --git a/lib/gettor/utils.py b/lib/gettor/utils.py
index cc4cc2f..509f90d 100644
--- a/lib/gettor/utils.py
+++ b/lib/gettor/utils.py
@@ -110,7 +110,7 @@ def installCron():
def addWhitelistEntry(conf, address):
"""Add an entry to the global whitelist
"""
- wlStateDir = conf.BASEDIR + "/wl"
+ wlStateDir = os.path.join(conf.BASEDIR, 'var', 'cache', 'gettor', 'wl')
logging.debug("Adding address to whitelist: %s" % address)
try:
whiteList = gettor.blacklist.BWList(wlStateDir, conf.BLACKLIST_THRES)
@@ -128,7 +128,7 @@ def addBlacklistEntry(conf, address):
"""Add an entry to the global blacklist
"""
logging.debug("Adding address to blacklist: %s" % address)
- blStateDir = conf.BASEDIR + "/bl"
+ blStateDir = os.path.join(conf.BASEDIR, 'var', 'cache', 'gettor', 'bl')
try:
blackList = gettor.blacklist.BWList(blStateDir, conf.BLACKLIST_THRES)
except IOError, e:
@@ -146,8 +146,8 @@ def lookupAddress(conf, address):
"""
logging.debug("Lookup address: %s" % address)
found = False
- wlStateDir = conf.BASEDIR + "/wl"
- blStateDir = conf.BASEDIR + "/bl"
+ wlStateDir = os.path.join(conf.BASEDIR, 'var', 'cache', 'gettor', 'wl')
+ blStateDir = os.path.join(conf.BASEDIR, 'var', 'cache', 'gettor', 'bl')
try:
whiteList = gettor.blacklist.BWList(wlStateDir, conf.BLACKLIST_THRES)
blackList = gettor.blacklist.BWList(blStateDir, conf.BLACKLIST_THRES)
@@ -170,7 +170,7 @@ def lookupAddress(conf, address):
def clearWhitelist(conf):
"""Delete all entries in the global whitelist
"""
- wlStateDir = conf.BASEDIR + "/wl"
+ wlStateDir = os.path.join(conf.BASEDIR, 'var', 'cache', 'gettor', 'wl')
try:
whiteList = gettor.blacklist.BWList(wlStateDir, conf.BLACKLIST_THRES)
except IOError, e:
@@ -189,7 +189,7 @@ def clearBlacklist(conf, olderThanDays):
'olderThanDays' days
"""
logging.debug("Clearing blacklist..")
- blStateDir = conf.BASEDIR + "/bl"
+ blStateDir = os.path.join(conf.BASEDIR, 'var', 'cache', 'gettor', 'bl')
try:
blackList = gettor.blacklist.BWList(blStateDir, conf.BLACKLIST_THRES)
except IOError, e:
@@ -209,7 +209,7 @@ def setCmdPassword(conf, password):
logging.debug("Setting command password")
passwordHash = str(hashlib.sha1(password).hexdigest())
# Be nice: Create dir if it's not there
- passFile = os.path.join(conf.BASEDIR, conf.PASSFILE)
+ passFile = os.path.join(conf.BASEDIR, 'etc', 'gettor', conf.PASSFILE)
try:
fd = open(passFile, 'w')
fd.write(passwordHash)
@@ -227,7 +227,7 @@ def verifyPassword(conf, password):
"""
candidateHash = str(hashlib.sha1(password).hexdigest())
try:
- passFile = os.path.join(conf.BASEDIR, conf.PASSFILE)
+ passFile = os.path.join(conf.BASEDIR, 'etc', 'gettor', conf.PASSFILE)
fd = open(passFile, 'r')
passwordHash = fd.read()
fd.close
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits