Unified code for finding source code location
It is already used in 3 places so I put it into a function
This commit is contained in:
parent
ceda22ec94
commit
25cc1dc287
|
@ -67,13 +67,7 @@ def _translate(context, text):
|
||||||
def change_translation(locale):
|
def change_translation(locale):
|
||||||
global qtranslator
|
global qtranslator
|
||||||
qtranslator = QtCore.QTranslator()
|
qtranslator = QtCore.QTranslator()
|
||||||
if shared.frozen == "macosx_app":
|
translationpath = os.path.join (shared.codePath(), 'translations', 'bitmessage_' + locale)
|
||||||
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)
|
|
||||||
qtranslator.load(translationpath)
|
qtranslator.load(translationpath)
|
||||||
QtGui.QApplication.installTranslator(qtranslator)
|
QtGui.QApplication.installTranslator(qtranslator)
|
||||||
|
|
||||||
|
|
|
@ -4,18 +4,12 @@
|
||||||
import hashlib
|
import hashlib
|
||||||
from struct import unpack, pack
|
from struct import unpack, pack
|
||||||
import sys
|
import sys
|
||||||
from shared import config, frozen
|
from shared import config, frozen, codePath
|
||||||
import shared
|
import shared
|
||||||
import openclpow
|
import openclpow
|
||||||
import os
|
import os
|
||||||
import ctypes
|
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'
|
bitmsglib = 'bitmsghash.so'
|
||||||
if "win32" == sys.platform:
|
if "win32" == sys.platform:
|
||||||
if ctypes.sizeof(ctypes.c_voidp) == 4:
|
if ctypes.sizeof(ctypes.c_voidp) == 4:
|
||||||
|
@ -23,12 +17,12 @@ if "win32" == sys.platform:
|
||||||
else:
|
else:
|
||||||
bitmsglib = 'bitmsghash64.dll'
|
bitmsglib = 'bitmsghash64.dll'
|
||||||
try:
|
try:
|
||||||
bso = ctypes.WinDLL(os.path.join(curdir, "bitmsghash", bitmsglib))
|
bso = ctypes.WinDLL(os.path.join(codePath(), "bitmsghash", bitmsglib))
|
||||||
except:
|
except:
|
||||||
bso = None
|
bso = None
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
bso = ctypes.CDLL(os.path.join(curdir, "bitmsghash", bitmsglib))
|
bso = ctypes.CDLL(os.path.join(codePath(), "bitmsghash", bitmsglib))
|
||||||
except:
|
except:
|
||||||
bso = None
|
bso = None
|
||||||
if bso:
|
if bso:
|
||||||
|
|
|
@ -218,6 +218,15 @@ def lookupAppdataFolder():
|
||||||
dataFolder = dataFolder + '/'
|
dataFolder = dataFolder + '/'
|
||||||
return 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):
|
def isAddressInMyAddressBook(address):
|
||||||
queryreturn = sqlQuery(
|
queryreturn = sqlQuery(
|
||||||
'''select address from addressbook where address=?''',
|
'''select address from addressbook where address=?''',
|
||||||
|
|
Loading…
Reference in New Issue
Block a user