commit 1e8e85e46e98439af01eb2a737746cc9e39b4383 Author: Nick Mathewson nickm@torproject.org Date: Thu Sep 25 14:36:15 2014 -0400
add the ability to require a particular version from the command line --- lib/trunnel/__init__.py | 2 +- lib/trunnel/__main__.py | 20 +++++++++++++++++--- 2 files changed, 18 insertions(+), 4 deletions(-)
diff --git a/lib/trunnel/__init__.py b/lib/trunnel/__init__.py index 0ed28df..0c823dd 100644 --- a/lib/trunnel/__init__.py +++ b/lib/trunnel/__init__.py @@ -3,5 +3,5 @@ # a package. #
-__version__ = "1.1-dev" +__version__ = "1.1.dev3"
diff --git a/lib/trunnel/__main__.py b/lib/trunnel/__main__.py index 99b7fd4..eece20a 100644 --- a/lib/trunnel/__main__.py +++ b/lib/trunnel/__main__.py @@ -9,12 +9,14 @@ if __name__ == '__main__': import trunnel.CodeGen import getopt
- opts, args = getopt.gnu_getopt(sys.argv[1:], "O:", - ["option=","write-c-files","target-dir="]) + opts, args = getopt.gnu_getopt( + sys.argv[1:], "O:", + ["option=","write-c-files","target-dir=","require-version="])
more_options = [] target_dir = None write_c_files = None + need_version = None
for (k, v) in opts: if k in ('-O', '--option'): @@ -23,8 +25,20 @@ if __name__ == '__main__': write_c_files = True elif k == '--target-dir': target_dir = v + elif k == '--require-version': + need_version = v
- if len(args) < 1 and not write_c_files: + if need_version is not None: + try: + from distutils.version import LooseVersion + me,it=trunnel.__version__ ,need_version + if LooseVersion(me) < LooseVersion(it): + sys.stderr.write("I'm %s; you asked for %s\n"%(me,it)) + sys.exit(1) + except ImportError: + print "Can't import" + + if len(args) < 1 and not write_c_files and not need_version: sys.stderr.write("Syntax: python -m trunnel <fname>\n") sys.exit(1)