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.
This commit is contained in:
Avery Pennarun 2010-05-12 13:48:37 -04:00
parent 2d4f6a4308
commit a8b3d69856

8
ssh.py
View File

@ -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):