aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2011-03-01 20:19:35 -0500
committerNick Mathewson <nickm@torproject.org>2011-03-01 20:19:35 -0500
commit70e35e2249e9128d544e6617528097860c6c3358 (patch)
tree876e42258b8101c7c4b763e6b1835c85f015a767
parent1effffab2a161898dd916a14e92546990c970184 (diff)
downloadchutney-70e35e2249e9128d544e6617528097860c6c3358.tar
chutney-70e35e2249e9128d544e6617528097860c6c3358.tar.gz
Move stuff into a submodule. Calling it "chutney" for now. Add launcher script
-rwxr-xr-xchutney6
-rw-r--r--lib/chutney/Templating.py (renamed from lib/templating.py)0
-rw-r--r--lib/chutney/TorNet.py (renamed from lib/TorNet.py)20
-rw-r--r--lib/chutney/__init__.py2
4 files changed, 21 insertions, 7 deletions
diff --git a/chutney b/chutney
new file mode 100755
index 0000000..a8be2ff
--- /dev/null
+++ b/chutney
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+
+PYTHONPATH="`dirname $0`/lib":${PYTHONPATH}
+export PYTHONPATH
+python -m chutney.TorNet $*
diff --git a/lib/templating.py b/lib/chutney/Templating.py
index cc1463a..cc1463a 100644
--- a/lib/templating.py
+++ b/lib/chutney/Templating.py
diff --git a/lib/TorNet.py b/lib/chutney/TorNet.py
index 2835186..4930b17 100644
--- a/lib/TorNet.py
+++ b/lib/chutney/TorNet.py
@@ -8,7 +8,6 @@
from __future__ import with_statement
import os
-import templating
import signal
import subprocess
import sys
@@ -16,6 +15,9 @@ import re
import errno
import time
+import chutney.Templating
+
+
def mkdir_p(d):
try:
os.makedirs(d)
@@ -41,7 +43,8 @@ class Node:
# Users are NOT expected to call these:
def _getTorrcFname(self):
- return templating.Template("${torrc_fname}").format(self._fields)
+ t = chutney.Templating.Template("${torrc_fname}")
+ return t.format(self._fields)
def _createTorrcFile(self, checkOnly=False):
template = self._getTorrcTemplate()
@@ -58,7 +61,7 @@ class Node:
template_path = env['torrc_template_path']
t = "$${include:$torrc}"
- return templating.Template(t, includePath=template_path)
+ return chutney.Templating.Template(t, includePath=template_path)
def _getFreeVars(self):
template = self._getTorrcTemplate()
@@ -277,9 +280,9 @@ DEFAULTS = {
'core' : True,
}
-class TorEnviron(templating.Environ):
+class TorEnviron(chutney.Templating.Environ):
def __init__(self,parent=None,**kwargs):
- templating.Environ.__init__(self, parent=parent, **kwargs)
+ chutney.Templating.Environ.__init__(self, parent=parent, **kwargs)
def _get_orport(self, me):
return me['orport_base']+me['nodenum']
@@ -391,10 +394,9 @@ def ConfigureNodes(nodelist):
def runConfigFile(verb, f):
global _BASE_FIELDS
global _THE_NETWORK
- _BASE_FIELDS = TorEnviron(templating.Environ(**DEFAULTS))
+ _BASE_FIELDS = TorEnviron(chutney.Templating.Environ(**DEFAULTS))
_THE_NETWORK = Network(_BASE_FIELDS)
-
_GLOBALS = dict(_BASE_FIELDS= _BASE_FIELDS,
Node=Node,
ConfigureNodes=ConfigureNodes,
@@ -411,6 +413,10 @@ def runConfigFile(verb, f):
getattr(network,verb)()
if __name__ == '__main__':
+ if len(sys.argv) < 3:
+ print "Syntax: chutney {command} {networkfile}"
+ sys.exit(1)
+
f = open(sys.argv[2])
runConfigFile(sys.argv[1], f)
diff --git a/lib/chutney/__init__.py b/lib/chutney/__init__.py
new file mode 100644
index 0000000..139597f
--- /dev/null
+++ b/lib/chutney/__init__.py
@@ -0,0 +1,2 @@
+
+