Browse Source

Move stuff into a submodule. Calling it "chutney" for now. Add launcher script

Nick Mathewson 13 years ago
parent
commit
70e35e2249
4 changed files with 21 additions and 7 deletions
  1. 6 0
      chutney
  2. 0 0
      lib/chutney/Templating.py
  3. 13 7
      lib/chutney/TorNet.py
  4. 2 0
      lib/chutney/__init__.py

+ 6 - 0
chutney

@@ -0,0 +1,6 @@
+#!/bin/sh
+
+
+PYTHONPATH="`dirname $0`/lib":${PYTHONPATH}
+export PYTHONPATH
+python -m chutney.TorNet $*

+ 0 - 0
lib/templating.py → lib/chutney/Templating.py


+ 13 - 7
lib/TorNet.py → 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)
 

+ 2 - 0
lib/chutney/__init__.py

@@ -0,0 +1,2 @@
+
+