Unified code for finding source code location

It is already used in 3 places so I put it into a function
master
mailchuck 7 years ago committed by Peter Surda
parent ceda22ec94
commit 25cc1dc287

@ -67,13 +67,7 @@ def _translate(context, text):
def change_translation(locale):
global qtranslator
qtranslator = QtCore.QTranslator()
if shared.frozen == "macosx_app":
translationpath = os.environ.get("RESOURCEPATH")
elif shared.frozen: # windows
translationpath = sys._MEIPASS
else:
translationpath = os.path.dirname(os.path.dirname(__file__))
translationpath = os.path.join (translationpath, 'translations', 'bitmessage_' + locale)
translationpath = os.path.join (shared.codePath(), 'translations', 'bitmessage_' + locale)
qtranslator.load(translationpath)
QtGui.QApplication.installTranslator(qtranslator)

@ -4,18 +4,12 @@
import hashlib
from struct import unpack, pack
import sys
from shared import config, frozen
from shared import config, frozen, codePath
import shared
import openclpow
import os
import ctypes
if frozen == "macosx_app":
curdir = os.environ.get("RESOURCEPATH")
elif frozen: # windows
curdir = sys._MEIPASS
else:
curdir = os.path.dirname(__file__)
bitmsglib = 'bitmsghash.so'
if "win32" == sys.platform:
if ctypes.sizeof(ctypes.c_voidp) == 4:
@ -23,12 +17,12 @@ if "win32" == sys.platform:
else:
bitmsglib = 'bitmsghash64.dll'
try:
bso = ctypes.WinDLL(os.path.join(curdir, "bitmsghash", bitmsglib))
bso = ctypes.WinDLL(os.path.join(codePath(), "bitmsghash", bitmsglib))
except:
bso = None
else:
try:
bso = ctypes.CDLL(os.path.join(curdir, "bitmsghash", bitmsglib))
bso = ctypes.CDLL(os.path.join(codePath(), "bitmsghash", bitmsglib))
except:
bso = None
if bso:

@ -217,6 +217,15 @@ def lookupAppdataFolder():
pass
dataFolder = dataFolder + '/'
return dataFolder
def codePath():
if frozen == "macosx_app":
codePath = os.environ.get("RESOURCEPATH")
elif frozen: # windows
codePath = sys._MEIPASS
else:
codePath = os.path.dirname(__file__)
return codePath
def isAddressInMyAddressBook(address):
queryreturn = sqlQuery(

Loading…
Cancel
Save