2008-08-15 19:31:51 +02:00
|
|
|
# -*- coding:utf-8 -*-
|
2008-08-15 05:20:23 +02:00
|
|
|
## src/gajim.py
|
2003-11-30 23:40:24 +01:00
|
|
|
##
|
2014-01-02 09:33:54 +01:00
|
|
|
## Copyright (C) 2003-2014 Yann Leboulanger <asterix AT lagaule.org>
|
2008-08-15 05:20:23 +02:00
|
|
|
## Copyright (C) 2004-2005 Vincent Hanquez <tab AT snarc.org>
|
|
|
|
## Copyright (C) 2005 Alex Podaras <bigpod AT gmail.com>
|
|
|
|
## Norman Rasmussen <norman AT rasmussen.co.za>
|
2008-08-15 19:31:51 +02:00
|
|
|
## Stéphan Kochen <stephan AT kochen.nl>
|
2008-08-15 05:20:23 +02:00
|
|
|
## Copyright (C) 2005-2006 Dimitur Kirov <dkirov AT gmail.com>
|
|
|
|
## Alex Mauer <hawke AT hawkesnest.net>
|
|
|
|
## Copyright (C) 2005-2007 Travis Shirk <travis AT pobox.com>
|
|
|
|
## Nikos Kouremenos <kourem AT gmail.com>
|
2008-08-15 19:31:51 +02:00
|
|
|
## Copyright (C) 2006 Junglecow J <junglecow AT gmail.com>
|
2008-08-15 05:20:23 +02:00
|
|
|
## Stefan Bethge <stefan AT lanpartei.de>
|
|
|
|
## Copyright (C) 2006-2008 Jean-Marie Traissard <jim AT lapin.org>
|
|
|
|
## Copyright (C) 2007 Lukas Petrovicky <lukas AT petrovicky.net>
|
|
|
|
## James Newton <redshodan AT gmail.com>
|
|
|
|
## Copyright (C) 2007-2008 Brendan Taylor <whateley AT gmail.com>
|
|
|
|
## Julien Pivotto <roidelapluie AT gmail.com>
|
|
|
|
## Stephan Erb <steve-e AT h3c.de>
|
|
|
|
## Copyright (C) 2008 Jonathan Schleifer <js-gajim AT webkeks.org>
|
2003-11-30 23:40:24 +01:00
|
|
|
##
|
2007-12-12 09:44:46 +01:00
|
|
|
## This file is part of Gajim.
|
|
|
|
##
|
|
|
|
## Gajim is free software; you can redistribute it and/or modify
|
2003-11-30 23:40:24 +01:00
|
|
|
## it under the terms of the GNU General Public License as published
|
2007-12-12 09:44:46 +01:00
|
|
|
## by the Free Software Foundation; version 3 only.
|
2003-11-30 23:40:24 +01:00
|
|
|
##
|
2007-12-12 09:44:46 +01:00
|
|
|
## Gajim is distributed in the hope that it will be useful,
|
2003-11-30 23:40:24 +01:00
|
|
|
## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2008-08-15 05:20:23 +02:00
|
|
|
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2003-11-30 23:40:24 +01:00
|
|
|
## GNU General Public License for more details.
|
|
|
|
##
|
2007-12-12 09:44:46 +01:00
|
|
|
## You should have received a copy of the GNU General Public License
|
2008-08-15 05:20:23 +02:00
|
|
|
## along with Gajim. If not, see <http://www.gnu.org/licenses/>.
|
2007-12-12 09:44:46 +01:00
|
|
|
##
|
2005-11-13 15:55:52 +01:00
|
|
|
|
2011-09-12 23:52:22 +02:00
|
|
|
import sys
|
2016-12-30 18:22:47 +01:00
|
|
|
import os
|
2016-12-22 20:02:32 +01:00
|
|
|
|
|
|
|
if '--version' in sys.argv or '-V' in sys.argv:
|
|
|
|
from common.defs import version
|
|
|
|
print(version)
|
|
|
|
sys.exit(0)
|
|
|
|
|
2016-12-30 18:22:47 +01:00
|
|
|
WINDEV = False
|
|
|
|
if '--windev' in sys.argv or '-w' in sys.argv:
|
|
|
|
WINDEV = True
|
2011-09-12 23:52:22 +02:00
|
|
|
|
2016-12-30 18:22:47 +01:00
|
|
|
if os.name == 'nt' and not WINDEV:
|
2016-12-30 22:51:46 +01:00
|
|
|
import warnings
|
2011-09-12 23:52:22 +02:00
|
|
|
log_path = os.path.join(os.environ['APPDATA'], 'Gajim')
|
|
|
|
if not os.path.exists(log_path):
|
2013-01-01 19:36:56 +01:00
|
|
|
os.mkdir(log_path, 0o700)
|
2011-09-12 23:52:22 +02:00
|
|
|
log_file = os.path.join(log_path, 'gajim.log')
|
|
|
|
|
2016-12-30 18:22:47 +01:00
|
|
|
class MyStd(object):
|
|
|
|
_file = None
|
|
|
|
_error = None
|
|
|
|
|
|
|
|
def write(self, text):
|
|
|
|
if self._file is None and self._error is None:
|
|
|
|
try:
|
|
|
|
self._file = open(log_file, 'a')
|
|
|
|
except Exception as details:
|
|
|
|
self._error = details
|
|
|
|
if self._file is not None:
|
|
|
|
self._file.write(text)
|
|
|
|
self._file.flush()
|
|
|
|
|
|
|
|
def flush(self):
|
|
|
|
if self._file is not None:
|
|
|
|
self._file.flush()
|
|
|
|
|
|
|
|
def isatty(self):
|
|
|
|
return False
|
|
|
|
|
|
|
|
outerr = MyStd()
|
|
|
|
sys.stdout = outerr
|
|
|
|
sys.stderr = outerr
|
2016-12-30 22:51:46 +01:00
|
|
|
warnings.filterwarnings(action='ignore')
|
2016-12-30 18:22:47 +01:00
|
|
|
|
2011-09-12 23:52:22 +02:00
|
|
|
|
2017-01-03 23:08:32 +01:00
|
|
|
# Test here for all required versions so we dont have to
|
|
|
|
# test multiple times in every module. nbxmpp also needs GLib.
|
|
|
|
import gi
|
|
|
|
gi.require_version('GLib', '2.0')
|
|
|
|
gi.require_version('Gio', '2.0')
|
|
|
|
gi.require_version('Gtk', '3.0')
|
|
|
|
gi.require_version('Gdk', '3.0')
|
|
|
|
gi.require_version('GObject', '2.0')
|
|
|
|
gi.require_version('Pango', '1.0')
|
|
|
|
|
2015-07-20 19:47:30 +02:00
|
|
|
MIN_NBXMPP_VER = "0.5.3"
|
2017-01-03 23:08:32 +01:00
|
|
|
|
2012-12-09 21:37:51 +01:00
|
|
|
try:
|
|
|
|
import nbxmpp
|
|
|
|
except ImportError:
|
2013-01-01 19:36:56 +01:00
|
|
|
print('Gajim needs python-nbxmpp to run. Quiting...')
|
2017-01-03 22:13:27 +01:00
|
|
|
sys.exit(1)
|
2014-04-09 18:02:30 +02:00
|
|
|
|
2017-01-03 22:13:27 +01:00
|
|
|
from distutils.version import LooseVersion as V
|
|
|
|
if V(nbxmpp.__version__) < V(MIN_NBXMPP_VER):
|
2014-11-14 22:31:18 +01:00
|
|
|
print('Gajim needs python-nbxmpp >= %s to run. Quiting...' % MIN_NBXMPP_VER)
|
2017-01-03 22:13:27 +01:00
|
|
|
sys.exit(1)
|
2013-12-23 16:56:58 +01:00
|
|
|
|
2016-12-22 19:48:48 +01:00
|
|
|
from application import GajimApplication
|
|
|
|
|
|
|
|
app = GajimApplication()
|
|
|
|
app.run(sys.argv)
|