summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAvery Pennarun <apenwarr@gmail.com>2010-05-12 13:48:37 -0400
committerAvery Pennarun <apenwarr@gmail.com>2010-05-12 13:53:14 -0400
commita8b3d6985626abf8af60f9debb0cb4f0b63a7852 (patch)
tree99d27aca5093f4e351e480b1d57ced633ed2184c
parent2d4f6a4308eedc0ae39df5b1cbf8b2517e61f359 (diff)
ssh.py: try harder to find required *.py files.
Search the entire python sys.path, not just the directory that argv[0] is in. That way if you symlink the sshuttle binary into (for example) ~/bin, it'll be able to work correctly.
-rw-r--r--ssh.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/ssh.py b/ssh.py
index a6c3098..7a37c36 100644
--- a/ssh.py
+++ b/ssh.py
@@ -5,8 +5,12 @@ from helpers import *
def readfile(name):
basedir = os.path.dirname(os.path.abspath(sys.argv[0]))
- fullname = os.path.join(basedir, name)
- return open(fullname, 'rb').read()
+ path = [basedir] + sys.path
+ for d in path:
+ fullname = os.path.join(d, name)
+ if os.path.exists(fullname):
+ return open(fullname, 'rb').read()
+ raise Exception("can't find file %r in any of %r" % (name, path))
def empackage(z, filename):