summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKali Kaneko <kali@leap.se>2015-08-05 18:54:58 -0700
committerIvan Alejandro <ivanalejandro0@gmail.com>2015-08-07 19:02:24 -0300
commit657005c72abdd478d1f4809e9984d401cbbbb845 (patch)
treee9572880f02624bab24f2e01cead83153d815abf /src
parent877e92d8698510b243b32d45e9c46f25e6f04615 (diff)
[feat] add util function fo find location when frozen
Diffstat (limited to 'src')
-rw-r--r--src/leap/bitmask/util/__init__.py12
1 files changed, 12 insertions, 0 deletions
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__)