gajim-plural/test/lib/__init__.py
tmolitor 065d08cebf Honor profile given on commandline for plugin dir and history db and more.
Also added new property 'additional_data' to message event objects. Changes to this attribute (a dict) are passed on from event to event and are also written to the history db as json string (reading of those values isn't implemented yet).
2016-09-05 00:01:29 +02:00

52 lines
1.3 KiB
Python

import sys
import os
import getopt
use_x = True
shortargs = 'hnv:'
longargs = 'help no-x verbose='
opts, args = getopt.getopt(sys.argv[1:], shortargs, longargs.split())
for o, a in opts:
if o in ('-n', '--no-x'):
use_x = False
gajim_root = os.path.join(os.path.abspath(os.path.dirname(__file__)), '../..')
# look for modules in the CWD, then gajim/test/lib, then gajim/src,
# then everywhere else
sys.path.insert(1, gajim_root + '/src')
sys.path.insert(1, gajim_root + '/test/lib')
# a temporary version of ~/.gajim for testing
configdir = gajim_root + '/test/tmp'
# plugins config dir
pluginsconfigdir = configdir + '/pluginsconfig'
# define _ for i18n
import __builtin__
__builtin__._ = lambda x: x
def setup_env():
# wipe config directory
if os.path.isdir(configdir):
import shutil
shutil.rmtree(configdir)
os.mkdir(configdir)
os.mkdir(pluginsconfigdir)
import common.configpaths
common.configpaths.gajimpaths.init(configdir)
# for some reason common.gajim needs to be imported before xmpppy?
from common import gajim
import logging
logging.basicConfig()
gajim.DATA_DIR = gajim_root + '/data'
gajim.use_x = use_x
if use_x:
import gtkgui_helpers
gtkgui_helpers.GUI_DIR = gajim_root + '/data/gui'