global switch use_local_modules

This commit is contained in:
thomasv 2013-03-15 13:00:59 +01:00
parent e3677eb0a0
commit 45c0880195
2 changed files with 8 additions and 5 deletions

View file

@ -34,17 +34,20 @@ except ImportError:
sys.exit("Error: AES does not seem to be installed. Try 'sudo pip install slowaes'")
is_local = os.path.dirname(os.path.realpath(__file__)) == os.getcwd()
is_android = 'ANDROID_DATA' in os.environ
import __builtin__
__builtin__.use_local_modules = is_local or is_android
# load local module as electrum
if os.path.exists("lib") or is_android:
if __builtin__.use_local_modules:
import imp
imp.load_module('electrum', *imp.find_module('lib'))
imp.load_module('electrum_gui', *imp.find_module('gui'))
from electrum import *
# get password routine
def prompt_password(prompt, confirm=True):
import getpass

View file

@ -346,11 +346,11 @@ class ElectrumWindow(QMainWindow):
# plugins
def init_plugins(self):
import imp, pkgutil
if os.path.exists("plugins"):
import imp, pkgutil, __builtin__
if __builtin__.use_local_modules:
fp, pathname, description = imp.find_module('plugins')
plugin_names = [name for a, name, b in pkgutil.iter_modules([pathname])]
imp.load_module('electrum_plugins', fp, pathname, description)
plugin_names = [name for a, name, b in pkgutil.iter_modules(['plugins'])]
self.plugins = map(lambda name: imp.load_source('electrum_plugins.'+name, os.path.join(pathname,name+'.py')), plugin_names)
else:
import electrum_plugins