1# https://pyrocko.org - GPLv3
2#
3# The Pyrocko Developers, 21st Century
4# ---|P------/S----------~Lg----------
6try:
7 from .info import * # noqa
8 __version__ = version # noqa
9except ImportError:
10 pass # not available in dev mode
12grumpy = 0 # noqa
15def get_logger():
16 from .util import logging
17 return logging.getLogger('pyrocko')
20class ExternalProgramMissing(Exception):
21 pass
24def make_squirrel(*args, **kwargs):
25 from pyrocko.squirrel import Squirrel
26 return Squirrel(*args, **kwargs)
29def sparrow(*args, **kwargs):
30 '''
31 Start Sparrow.
33 Calls :py:func:`pyrocko.gui.sparrow.main`.
34 '''
36 check_have_vtk()
38 from pyrocko.gui.sparrow.main import main
39 return main(*args, **kwargs)
42class DependencyMissing(Exception):
43 pass
46class DependencyMissingVTK(DependencyMissing):
47 pass
50def check_have_vtk():
51 import sys
53 try:
54 import vtk # noqa
55 except ImportError:
56 message = '''VTK is not available.
58Either VTK is not installed or it does not support the currently running
59version of Python (Python%i).''' % sys.version_info.major
61 raise DependencyMissingVTK(message)
63 try:
64 from vtk.qt.QVTKRenderWindowInteractor \
65 import QVTKRenderWindowInteractor
67 QVTKRenderWindowInteractor
68 except ImportError:
69 message = 'The installed version of VTK is incompatible with Qt5.'
70 raise DependencyMissing(message)