2009-01-11 14:49:03 +01:00
|
|
|
import os
|
2008-08-27 09:55:06 +02:00
|
|
|
|
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):
|
2010-02-08 15:08:40 +01:00
|
|
|
# wipe config directory
|
|
|
|
if os.path.isdir(configdir):
|
|
|
|
import shutil
|
|
|
|
shutil.rmtree(configdir)
|
2008-06-12 05:56:30 +02:00
|
|
|
|
2010-02-08 15:08:40 +01: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
|
|
|
|
2018-04-21 12:44:10 +02:00
|
|
|
from gajim.common import configpaths
|
|
|
|
configpaths.set_config_root(configdir)
|
|
|
|
configpaths.init()
|
2008-06-12 05:56:30 +02:00
|
|
|
|
2017-08-13 13:18:56 +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
|
|
|
|
2010-02-08 15:08:40 +01:00
|
|
|
import logging
|
|
|
|
logging.basicConfig()
|
2009-01-11 14:49:03 +01:00
|
|
|
|
2017-08-13 13:18:56 +02:00
|
|
|
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
|
|
|
|
2010-02-08 15:08:40 +01:00
|
|
|
if use_x:
|
2018-08-18 19:11:26 +02:00
|
|
|
from gajim.application import GajimApplication
|
2017-08-13 13:18:56 +02:00
|
|
|
app.app = GajimApplication()
|