[tor-commits] [fallback-scripts/master] script: Make check_existing mode configurable with env vars

teor at torproject.org teor at torproject.org
Thu Aug 1 06:41:01 UTC 2019


commit 25368f480d9a23a69a50625bcc638d20f5327a4b
Author: teor <teor at torproject.org>
Date:   Thu Jun 27 14:47:35 2019 +1000

    script: Make check_existing mode configurable with env vars
    
    Tested with:
    $ TOR_FB_MAX_FALLBACK_COUNT=10 ./updateFallbackDirs.py check_existing
    $ TOR_FB_MODE=check_existing TOR_FB_MAX_FALLBACK_COUNT=10 ./updateFallbackDirs.py
    
    Part of 29100.
---
 updateFallbackDirs.py | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/updateFallbackDirs.py b/updateFallbackDirs.py
index 229967f..23991ad 100755
--- a/updateFallbackDirs.py
+++ b/updateFallbackDirs.py
@@ -3,11 +3,10 @@
 # Usage:
 #
 # Regenerate the list:
-# $ TOR_FB_MODE=""
 # $ TOR_FB_DATE=`date -u "+%Y-%m-%d-%H-%M-%S"`
 # $ TOR_FB_COUNTRY=ZZ
 # $ TOR_FB_COMMIT=`git rev-parse --short=16 HEAD`
-# $ ./updateFallbackDirs.py $TOR_FB_MODE \
+# $ ./updateFallbackDirs.py \
 #     > fallback_dirs_"$TOR_FB_DATE"_"$TOR_FB_COUNTRY"_"$TOR_FB_COMMIT".inc \
 #     2> fallback_dirs_"$TOR_FB_DATE"_"$TOR_FB_COUNTRY"_"$TOR_FB_COMMIT".log
 # $ cp fallback_dirs_*.inc ../tor/src/app/config/fallback_dirs.inc
@@ -105,6 +104,13 @@ FALLBACK_FORMAT_VERSION = '2.0.0'
 SECTION_SEPARATOR_BASE = '====='
 SECTION_SEPARATOR_COMMENT = '/* ' + SECTION_SEPARATOR_BASE + ' */'
 
+## Mode Settings
+
+# Use "check_existing" to check existing fallbacks, or anything else to create
+# a new list. Overridden by the command-line argument "check_existing".
+MODE = getenv_conf('TOR_FB_MODE',
+                   '', str)
+
 # Output all candidate fallbacks, or only output selected fallbacks?
 OUTPUT_CANDIDATES = getenv_conf('TOR_FB_OUTPUT_CANDIDATES',
                                 False, bool)
@@ -2324,7 +2330,7 @@ def get_command():
   if len(sys.argv) == 2:
     return sys.argv[1]
   else:
-    return None
+    return MODE
 
 def log_excluded(msg, *args):
   if get_command() == 'check_existing':





More information about the tor-commits mailing list