[tor-commits] [chutney/master] check none exist network file
nickm at torproject.org
nickm at torproject.org
Thu Oct 9 14:49:03 UTC 2014
commit 489bc2b46362d8d3644d4c7862b3fe8d982d9742
Author: Qingping Hou <dave2008713 at gmail.com>
Date: Thu Mar 27 21:59:24 2014 -0400
check none exist network file
---
lib/chutney/TorNet.py | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/lib/chutney/TorNet.py b/lib/chutney/TorNet.py
index 154cb71..042610c 100644
--- a/lib/chutney/TorNet.py
+++ b/lib/chutney/TorNet.py
@@ -717,6 +717,11 @@ def usage(network):
"Known commands are: %s" % (
" ".join(x for x in dir(network) if not x.startswith("_")))])
+def exit_on_error(err_msg):
+ print "Error: {0}\n".format(err_msg)
+ print usage(_THE_NETWORK)
+ sys.exit(1)
+
def runConfigFile(verb, f):
_GLOBALS = dict(_BASE_ENVIRON= _BASE_ENVIRON,
Node=Node,
@@ -735,10 +740,9 @@ def runConfigFile(verb, f):
def parseArgs():
if len(sys.argv) < 3:
- print usage(_THE_NETWORK)
- print "Error: Not enough arguments given."
- sys.exit(1)
-
+ exit_on_error("Not enough arguments given.")
+ if not os.path.isfile(sys.argv[2]):
+ exit_on_error("Cannot find networkfile: {0}.".format(sys.argv[2]))
return {'network_cfg': sys.argv[2], 'action': sys.argv[1]}
def main():
More information about the tor-commits
mailing list