[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [flashproxy/master] Use sys.executable to get script directory when frozen.
commit a3f93c2335c22ed5002a6e4825d35e6c7055e89b
Author: Alexandre Allaire <alexandre.allaire@xxxxxxxxxxxxxx>
Date: Tue Mar 12 20:00:54 2013 -0700
Use sys.executable to get script directory when frozen.
py2exe overwrites sys.path[0], and the paths to the registration
helpers end up wrong. If we are frozen, use dirname(sys.executable)
instead of sys.path[0].
---
flashproxy-client | 8 ++++++--
1 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/flashproxy-client b/flashproxy-client
index e9795fa..22ce072 100755
--- a/flashproxy-client
+++ b/flashproxy-client
@@ -945,8 +945,12 @@ def proxy_loop():
report_pending()
def build_register_command(method):
- # sys.path[0] is initialized to the directory containing the Python script file.
- script_dir = sys.path[0]
+ # sys.path[0] usually contains the directory the script is located in.
+ # py2exe overwrites this for bundled executables.
+ if getattr(sys, "frozen", False):
+ script_dir = os.path.dirname(sys.executable)
+ else:
+ script_dir = sys.path[0]
if not script_dir:
# Maybe the script was read from stdin; in any case don't guess at the directory.
raise ValueError("Can't find executable directory for registration helpers")
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits