# -*- coding:utf-8 -*- ## src/gajim.py ## ## Copyright (C) 2003-2014 Yann Leboulanger ## Copyright (C) 2004-2005 Vincent Hanquez ## Copyright (C) 2005 Alex Podaras ## Norman Rasmussen ## Stéphan Kochen ## Copyright (C) 2005-2006 Dimitur Kirov ## Alex Mauer ## Copyright (C) 2005-2007 Travis Shirk ## Nikos Kouremenos ## Copyright (C) 2006 Junglecow J ## Stefan Bethge ## Copyright (C) 2006-2008 Jean-Marie Traissard ## Copyright (C) 2007 Lukas Petrovicky ## James Newton ## Copyright (C) 2007-2008 Brendan Taylor ## Julien Pivotto ## Stephan Erb ## Copyright (C) 2008 Jonathan Schleifer ## ## This file is part of Gajim. ## ## Gajim is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published ## by the Free Software Foundation; version 3 only. ## ## Gajim is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with Gajim. If not, see . ## import sys import os if '--version' in sys.argv or '-V' in sys.argv: from common.defs import version print(version) sys.exit(0) WINDEV = False if '--windev' in sys.argv or '-w' in sys.argv: WINDEV = True if os.name == 'nt' and not WINDEV: log_path = os.path.join(os.environ['APPDATA'], 'Gajim') if not os.path.exists(log_path): os.mkdir(log_path, 0o700) log_file = os.path.join(log_path, 'gajim.log') 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 # 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') MIN_NBXMPP_VER = "0.5.3" try: import nbxmpp except ImportError: print('Gajim needs python-nbxmpp to run. Quiting...') sys.exit(1) from distutils.version import LooseVersion as V if V(nbxmpp.__version__) < V(MIN_NBXMPP_VER): print('Gajim needs python-nbxmpp >= %s to run. Quiting...' % MIN_NBXMPP_VER) sys.exit(1) from application import GajimApplication app = GajimApplication() app.run(sys.argv)