7009: endless exception loop starting w/o DISPLAY
Reapplied my fix to has_display from gramps40. svn: r22910
This commit is contained in:
parent
72c2cff790
commit
ffa6b33db8
@ -132,15 +132,15 @@ def has_display():
|
|||||||
temp, sys.argv = sys.argv, sys.argv[:1]
|
temp, sys.argv = sys.argv, sys.argv[:1]
|
||||||
try:
|
try:
|
||||||
from gi.repository import Gtk
|
from gi.repository import Gtk
|
||||||
|
from gi.repository import Gdk
|
||||||
except:
|
except:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
try:
|
try:
|
||||||
test = Gtk.init_check(temp)
|
test = Gtk.init_check(temp) and \
|
||||||
|
Gdk.Display.get_default()
|
||||||
sys.argv = temp
|
sys.argv = temp
|
||||||
if test:
|
return bool(test)
|
||||||
return True
|
|
||||||
else:
|
|
||||||
return False
|
|
||||||
except:
|
except:
|
||||||
sys.argv = temp
|
sys.argv = temp
|
||||||
return False
|
return False
|
||||||
|
46
gramps/gen/test/constfunc_test.py
Normal file
46
gramps/gen/test/constfunc_test.py
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
#
|
||||||
|
# Gramps - a GTK+/GNOME based genealogy program
|
||||||
|
#
|
||||||
|
# Copyright (C) 2013 Vassilii Khachaturov <vassilii@tarunz.org>
|
||||||
|
#
|
||||||
|
# This program 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; either version 2 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program 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 this program; if not, write to the Free Software
|
||||||
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
#
|
||||||
|
|
||||||
|
# $Id$
|
||||||
|
|
||||||
|
""" Unittest for constfunc.py """
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
|
import unittest
|
||||||
|
from .. import constfunc
|
||||||
|
|
||||||
|
from os import environ as env
|
||||||
|
|
||||||
|
class Test_has_display(unittest.TestCase):
|
||||||
|
def setUp(self):
|
||||||
|
self.has = constfunc.has_display()
|
||||||
|
self.display_nonempty = env.has_key('DISPLAY') and bool(env['DISPLAY'])
|
||||||
|
|
||||||
|
@unittest.skipUnless(constfunc.lin(), "Written for Linux only...")
|
||||||
|
def test_consistent_with_DISPLAY_env(self):
|
||||||
|
assert self.has == self.display_nonempty, \
|
||||||
|
"has_display(): {}, $DISPLAY: {}".format(
|
||||||
|
self.has, env['DISPLAY'] if env.has_key('DISPLAY') \
|
||||||
|
else "(unset)")
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
unittest.main()
|
Loading…
Reference in New Issue
Block a user