Cleanup Paths/DB creation and init
This commit is contained in:
parent
32604e99bf
commit
39ec724e45
2 changed files with 48 additions and 58 deletions
|
@ -84,6 +84,34 @@ class GajimApplication(Gtk.Application):
|
||||||
|
|
||||||
Gtk.Application.do_activate(self)
|
Gtk.Application.do_activate(self)
|
||||||
|
|
||||||
|
# Create and initialize Application Paths & Databases
|
||||||
|
import common.configpaths
|
||||||
|
common.configpaths.gajimpaths.init(
|
||||||
|
self.config_path, self.profile, self.profile_separation)
|
||||||
|
from common import gajim
|
||||||
|
from common import check_paths
|
||||||
|
from common import exceptions
|
||||||
|
from common import logger
|
||||||
|
from common import caps_cache
|
||||||
|
try:
|
||||||
|
gajim.logger = logger.Logger()
|
||||||
|
caps_cache.initialize(gajim.logger)
|
||||||
|
check_paths.check_and_possibly_create_paths()
|
||||||
|
except exceptions.DatabaseMalformed:
|
||||||
|
dlg = Gtk.MessageDialog(
|
||||||
|
None,
|
||||||
|
Gtk.DialogFlags.DESTROY_WITH_PARENT | Gtk.DialogFlags.MODAL,
|
||||||
|
Gtk.MessageType.ERROR,
|
||||||
|
Gtk.ButtonsType.OK,
|
||||||
|
_('Database Error'))
|
||||||
|
dlg.format_secondary_text(
|
||||||
|
_('The database file (%s) cannot be read. Try to repair it '
|
||||||
|
'(see http://trac.gajim.org/wiki/DatabaseBackup) or remove it '
|
||||||
|
'(all history will be lost).') % gajim.gajimpaths['LOG_DB'])
|
||||||
|
dlg.run()
|
||||||
|
dlg.destroy()
|
||||||
|
sys.exit()
|
||||||
|
|
||||||
if os.name == 'nt':
|
if os.name == 'nt':
|
||||||
import locale
|
import locale
|
||||||
import gettext
|
import gettext
|
||||||
|
@ -115,10 +143,6 @@ class GajimApplication(Gtk.Application):
|
||||||
|
|
||||||
import locale
|
import locale
|
||||||
|
|
||||||
import common.configpaths
|
|
||||||
common.configpaths.gajimpaths.init(
|
|
||||||
self.config_path, self.profile, self.profile_separation)
|
|
||||||
|
|
||||||
if os.name == 'nt':
|
if os.name == 'nt':
|
||||||
plugins_locale_dir = os.path.join(common.configpaths.gajimpaths[
|
plugins_locale_dir = os.path.join(common.configpaths.gajimpaths[
|
||||||
'PLUGINS_USER'], 'locale').encode(locale.getpreferredencoding())
|
'PLUGINS_USER'], 'locale').encode(locale.getpreferredencoding())
|
||||||
|
@ -127,21 +151,7 @@ class GajimApplication(Gtk.Application):
|
||||||
|
|
||||||
if Gtk.Widget.get_default_direction() == Gtk.TextDirection.RTL:
|
if Gtk.Widget.get_default_direction() == Gtk.TextDirection.RTL:
|
||||||
i18n.direction_mark = '\u200F'
|
i18n.direction_mark = '\u200F'
|
||||||
pritext = ''
|
|
||||||
|
|
||||||
from common import exceptions
|
|
||||||
try:
|
|
||||||
from common import gajim
|
|
||||||
except exceptions.DatabaseMalformed:
|
|
||||||
pritext = _('Database Error')
|
|
||||||
sectext = _('The database file (%s) cannot be read. Try to repair it (see '
|
|
||||||
'http://trac.gajim.org/wiki/DatabaseBackup) or remove it (all history '
|
|
||||||
'will be lost).') % common.logger.LOG_DB_PATH
|
|
||||||
else:
|
|
||||||
from common import logger
|
|
||||||
gajim.logger = logger.Logger()
|
|
||||||
from common import caps_cache
|
|
||||||
caps_cache.initialize(gajim.logger)
|
|
||||||
from common import dbus_support
|
from common import dbus_support
|
||||||
if dbus_support.supported:
|
if dbus_support.supported:
|
||||||
from music_track_listener import MusicTrackListener
|
from music_track_listener import MusicTrackListener
|
||||||
|
@ -163,26 +173,8 @@ class GajimApplication(Gtk.Application):
|
||||||
elif sysname in ('FreeBSD', 'OpenBSD', 'NetBSD'):
|
elif sysname in ('FreeBSD', 'OpenBSD', 'NetBSD'):
|
||||||
libc.setproctitle('gajim')
|
libc.setproctitle('gajim')
|
||||||
|
|
||||||
from common import check_paths
|
|
||||||
|
|
||||||
if pritext:
|
|
||||||
dlg = Gtk.MessageDialog(None,
|
|
||||||
Gtk.DialogFlags.DESTROY_WITH_PARENT | Gtk.DialogFlags.MODAL,
|
|
||||||
Gtk.MessageType.ERROR, Gtk.ButtonsType.OK, message_format = pritext)
|
|
||||||
|
|
||||||
dlg.format_secondary_text(sectext)
|
|
||||||
dlg.run()
|
|
||||||
dlg.destroy()
|
|
||||||
sys.exit()
|
|
||||||
|
|
||||||
del pritext
|
|
||||||
|
|
||||||
import signal
|
|
||||||
|
|
||||||
gajimpaths = common.configpaths.gajimpaths
|
|
||||||
|
|
||||||
# Seed the OpenSSL pseudo random number generator from file and initialize
|
# Seed the OpenSSL pseudo random number generator from file and initialize
|
||||||
RNG_SEED = gajimpaths['RNG_SEED']
|
RNG_SEED = gajim.gajimpaths['RNG_SEED']
|
||||||
PYOPENSSL_PRNG_PRESENT = False
|
PYOPENSSL_PRNG_PRESENT = False
|
||||||
try:
|
try:
|
||||||
import OpenSSL.rand
|
import OpenSSL.rand
|
||||||
|
@ -220,14 +212,13 @@ class GajimApplication(Gtk.Application):
|
||||||
def sigint_cb(num, stack):
|
def sigint_cb(num, stack):
|
||||||
sys.exit(5)
|
sys.exit(5)
|
||||||
# ^C exits the application normally
|
# ^C exits the application normally
|
||||||
|
import signal
|
||||||
signal.signal(signal.SIGINT, sigint_cb)
|
signal.signal(signal.SIGINT, sigint_cb)
|
||||||
signal.signal(signal.SIGTERM, sigint_cb)
|
signal.signal(signal.SIGTERM, sigint_cb)
|
||||||
|
|
||||||
log.info("Encodings: d:%s, fs:%s, p:%s", sys.getdefaultencoding(), \
|
log.info("Encodings: d:%s, fs:%s, p:%s", sys.getdefaultencoding(), \
|
||||||
sys.getfilesystemencoding(), locale.getpreferredencoding())
|
sys.getfilesystemencoding(), locale.getpreferredencoding())
|
||||||
|
|
||||||
check_paths.check_and_possibly_create_paths()
|
|
||||||
|
|
||||||
self.interface = Interface()
|
self.interface = Interface()
|
||||||
self.interface.run(self)
|
self.interface.run(self)
|
||||||
|
|
||||||
|
|
|
@ -43,10 +43,9 @@ from common import ged
|
||||||
|
|
||||||
import sqlite3 as sqlite
|
import sqlite3 as sqlite
|
||||||
|
|
||||||
from common import configpaths
|
LOG_DB_PATH = gajim.gajimpaths['LOG_DB']
|
||||||
LOG_DB_PATH = configpaths.gajimpaths['LOG_DB']
|
|
||||||
LOG_DB_FOLDER, LOG_DB_FILE = os.path.split(LOG_DB_PATH)
|
LOG_DB_FOLDER, LOG_DB_FILE = os.path.split(LOG_DB_PATH)
|
||||||
CACHE_DB_PATH = configpaths.gajimpaths['CACHE_DB']
|
CACHE_DB_PATH = gajim.gajimpaths['CACHE_DB']
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
log = logging.getLogger('gajim.c.logger')
|
log = logging.getLogger('gajim.c.logger')
|
||||||
|
|
Loading…
Add table
Reference in a new issue