[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [bridgedb/master] Change runner.generateDescriptors() to not need whole options class.
commit 384775613778ae6994ccedb365530ca14491b9bb
Author: Isis Lovecruft <isis@xxxxxxxxxxxxxx>
Date: Tue Nov 5 08:39:46 2013 +0000
Change runner.generateDescriptors() to not need whole options class.
* CHANGE the parameters to bridgedb.runner.generateDescriptors() function to
only need specific settings, rather than needing the whole instance of the
MainOptions class.
---
lib/bridgedb/Main.py | 3 ++-
lib/bridgedb/runner.py | 7 ++++---
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/lib/bridgedb/Main.py b/lib/bridgedb/Main.py
index 2ab1f5a..4f5203f 100644
--- a/lib/bridgedb/Main.py
+++ b/lib/bridgedb/Main.py
@@ -472,7 +472,8 @@ def runSubcommand(options, config):
logging.debug("Running BridgeDB command: '%s'" % options.subCommand)
if 'descriptors' in options.subOptions:
- runner.generateDescriptors(options)
+ runner.generateDescriptors(options.subOptions['descriptors'],
+ config.RUNDIR)
if options.subCommand == 'test':
if options.subOptions['trial']:
diff --git a/lib/bridgedb/runner.py b/lib/bridgedb/runner.py
index 425c0e8..b477c35 100644
--- a/lib/bridgedb/runner.py
+++ b/lib/bridgedb/runner.py
@@ -19,7 +19,7 @@ from __future__ import print_function
import sys
-def generateDescriptors(options):
+def generateDescriptors(count=None, rundir=None):
"""Run a script which creates fake bridge descriptors for testing purposes.
This will run scripts/gen_bridge_descriptors to create a bridge router
@@ -31,11 +31,12 @@ def generateDescriptors(options):
:returns: The process returncode from the gen_bridge_descriptors script.
"""
import subprocess
+ import os.path
proc = None
- rundir = options['rundir']
script = 'gen_bridge_descriptors'
- count = options.subOptions['descriptors']
+ rundir = rundir if os.path.isdir(rundir) else None
+ count = count if count else 3
try:
proc = subprocess.Popen([script, '-n', str(count)],
close_fds=True, cwd=rundir)
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits