[or-cvs] r20799: {projects} Fix some utils routines (in projects/gettor: . gettor)

kaner at seul.org kaner at seul.org
Sun Oct 18 10:34:52 UTC 2009


Author: kaner
Date: 2009-10-18 06:34:51 -0400 (Sun, 18 Oct 2009)
New Revision: 20799

Modified:
   projects/gettor/GetTor.py
   projects/gettor/gettor/utils.py
Log:
Fix some utils routines


Modified: projects/gettor/GetTor.py
===================================================================
--- projects/gettor/GetTor.py	2009-10-17 03:19:18 UTC (rev 20798)
+++ projects/gettor/GetTor.py	2009-10-18 10:34:51 UTC (rev 20799)
@@ -55,7 +55,7 @@
     print "Options: ", options
     # Order matters!
     if options.insttrans:
-        gettor.utils.installTrans(conf, options.i18ndir)
+        m = gettor.utils.installTranslations(conf, options.i18ndir)
     if options.fetchpackages:
         gettor.utils.fetchPackages(conf, options.mirror)
     if options.preppackages:
@@ -63,15 +63,15 @@
     if options.installcron:
         gettor.utils.installCron()
     if options.whitelist:
-        gettor.utils.addWhitelistEntry(options.whitelist)
+        gettor.utils.addWhitelistEntry(conf, options.whitelist)
     if options.blacklist:
-        gettor.utils.addBlacklistEntry(options.blacklist)
+        gettor.utils.addBlacklistEntry(conf, options.blacklist)
     if options.lookup:
-        gettor.utils.lookupAddress(options.lookup)
+        gettor.utils.lookupAddress(conf, options.lookup)
     if options.clearwl:
-        gettor.utils.clearWhitelist()
+        gettor.utils.clearWhitelist(conf)
     if options.clearbl:
-        gettor.utils.clearBlacklist()
+        gettor.utils.clearBlacklist(conf)
 
 def main():
     # Parse command line, setup config and logging

Modified: projects/gettor/gettor/utils.py
===================================================================
--- projects/gettor/gettor/utils.py	2009-10-17 03:19:18 UTC (rev 20798)
+++ projects/gettor/gettor/utils.py	2009-10-18 10:34:51 UTC (rev 20799)
@@ -12,6 +12,7 @@
 '''
 
 import os
+import subprocess
 
 import gettor.gtlog
 import gettor.blacklist
@@ -29,7 +30,7 @@
         return False
     return True
 
-def installTrans(conf, dir):
+def installTranslations(conf, localeSrcdir):
     """Install all translation files to 'dir'"""
     log.info("Installing translation files..")
     hasDirs = None
@@ -68,7 +69,7 @@
                 if not os.path.isdir(targetDir):
                     log.info("Not a directory: %s" % targetDir)
                     if not createDir(targetDir):
-                        log.error(_("Giving up on %s" % targetDir))
+                        log.error("Giving up on %s" % targetDir)
                         return False
                 if installMo(poFile, targetDir) == False:
                     log.error("Installing .mo files failed.")
@@ -126,35 +127,35 @@
     cronProc.communicate()[0]
     return cronProc.returncode
 
-def addWhitelistEntry(address):
+def addWhitelistEntry(conf, address):
     log.info("Adding address to whitelist: %s" % address)
     try:
         whiteList = gettor.blacklist.BWList(conf.getWlStateDir())
     except IOError, e:
         log.error("Whitelist error: %s" % e)
         return False
-    if not whiteList.createListEntry(options.whitelist):
+    if not whiteList.createListEntry(address):
         log.error("Creating whitelist entry failed.")
         return False
     else:
         log.info("Creating whitelist entry ok.")
         return True
 
-def addBlacklistEntry(address):
+def addBlacklistEntry(conf, address):
     log.info("Adding address to blacklist: %s" % address)
     try:
         blackList = gettor.blacklist.BWList(conf.getBlStateDir())
     except IOError, e:
         log.error("Blacklist error: %s" % e)
         return False
-    if not blackList.createListEntry(options.whitelist):
+    if not blackList.createListEntry(address):
         log.error("Creating blacklist entry failed.")
         return False
     else:
         log.info("Creating whitelist entry ok.")
         return True
 
-def lookupAddress(address):
+def lookupAddress(conf, address):
     log.info("Lookup address: %s" % address)
     found = False
     try:
@@ -169,13 +170,14 @@
     if blackList.lookupListEntry(address):
         log.info("Address '%s' is present in the blacklist." % address)
         found = True
-    if not success:
+    if not found:
         log.info("Address '%s' neither in blacklist or whitelist." % address)
         found = True
 
+    # Always True
     return found
 
-def clearWhitelist():
+def clearWhitelist(conf):
     try:
         whiteList = gettor.blacklist.BWList(conf.getWlStateDir())
     except IOError, e:
@@ -189,7 +191,7 @@
         log.info("Deleting whitelist done.")
         return True
 
-def clearBlacklist():
+def clearBlacklist(conf):
     log.info("Clearing blacklist..")
     try:
         blackList = gettor.blacklist.BWList(conf.getBlStateDir())



More information about the tor-commits mailing list