From 657005c72abdd478d1f4809e9984d401cbbbb845 Mon Sep 17 00:00:00 2001 From: Kali Kaneko Date: Wed, 5 Aug 2015 18:54:58 -0700 Subject: [feat] add util function fo find location when frozen --- src/leap/bitmask/util/__init__.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/leap') diff --git a/src/leap/bitmask/util/__init__.py b/src/leap/bitmask/util/__init__.py index e8eddd64..9853803a 100644 --- a/src/leap/bitmask/util/__init__.py +++ b/src/leap/bitmask/util/__init__.py @@ -20,6 +20,7 @@ Some small and handy functions. import datetime import itertools import os +import sys from leap.bitmask.config import flags from leap.common.config import get_path_prefix as common_get_path_prefix @@ -154,3 +155,14 @@ def flags_to_dict(): values = dict((i, getattr(flags, i)) for i in items) return values + +def here(module=None): + if getattr(sys, 'frozen', False): + # we are running in a |PyInstaller| bundle + return sys._MEIPASS + else: + dirname = os.path.dirname + if module: + return dirname(module.__file__) + else: + return dirname(__file__) -- cgit v1.2.3