gajim-plural/test/lib/__init__.py

47 lines
1.1 KiB
Python
Raw Normal View History

import os
2018-11-11 01:31:50 +01:00
from tempfile import gettempdir
2008-06-12 05:56:30 +02:00
# a temporary version of ~/.gajim for testing
2018-11-11 01:31:50 +01:00
configdir = os.path.join(gettempdir(), 'gajim')
os.makedirs(configdir, exist_ok=True)
2010-08-27 11:47:38 +02:00
# plugins config dir
pluginsconfigdir = configdir + '/pluginsconfig'
2018-11-11 01:31:50 +01:00
# theme config directory
themedir = configdir + '/theme'
2008-06-12 05:56:30 +02:00
# define _ for i18n
2016-10-10 15:22:51 +02:00
import builtins
builtins._ = lambda x: x
2008-06-12 05:56:30 +02:00
2017-09-15 15:11:55 +02:00
from gajim.common.contacts import LegacyContactsAPI
2018-11-11 01:31:50 +01:00
def setup_env(use_x=True):
# wipe config directory
if os.path.isdir(configdir):
import shutil
shutil.rmtree(configdir)
2008-06-12 05:56:30 +02:00
os.mkdir(configdir)
2010-08-27 11:47:38 +02:00
os.mkdir(pluginsconfigdir)
2018-11-11 01:31:50 +01:00
os.mkdir(themedir)
2008-06-12 05:56:30 +02:00
from gajim.common import configpaths
configpaths.set_config_root(configdir)
configpaths.init()
2008-06-12 05:56:30 +02:00
# for some reason gajim.common.app needs to be imported before xmpppy?
from gajim.common import app
2008-06-12 05:56:30 +02:00
import logging
logging.basicConfig()
app.use_x = use_x
2017-09-15 15:11:55 +02:00
app.contacts = LegacyContactsAPI()
app.connections = {}
2008-06-29 07:25:59 +02:00
if use_x:
2018-08-18 19:11:26 +02:00
from gajim.application import GajimApplication
app.app = GajimApplication()