1# https://pyrocko.org - GPLv3 

2# 

3# The Pyrocko Developers, 21st Century 

4# ---|P------/S----------~Lg---------- 

5 

6try: 

7 from .info import * # noqa 

8 __version__ = version # noqa 

9except ImportError: 

10 pass # not available in dev mode 

11 

12grumpy = 0 # noqa 

13 

14 

15def get_logger(): 

16 from .util import logging 

17 return logging.getLogger('pyrocko') 

18 

19 

20class ExternalProgramMissing(Exception): 

21 pass 

22 

23 

24def make_squirrel(*args, **kwargs): 

25 from pyrocko.squirrel import Squirrel 

26 return Squirrel(*args, **kwargs) 

27 

28 

29def sparrow(*args, **kwargs): 

30 ''' 

31 Start Sparrow. 

32 

33 Calls :py:func:`pyrocko.gui.sparrow.main`. 

34 ''' 

35 

36 check_have_vtk() 

37 

38 from pyrocko.gui.sparrow.main import main 

39 return main(*args, **kwargs) 

40 

41 

42class DependencyMissing(Exception): 

43 pass 

44 

45 

46class DependencyMissingVTK(DependencyMissing): 

47 pass 

48 

49 

50def check_have_vtk(): 

51 import sys 

52 

53 try: 

54 import vtk # noqa 

55 except ImportError: 

56 message = '''VTK is not available. 

57 

58Either VTK is not installed or it does not support the currently running 

59version of Python (Python%i).''' % sys.version_info.major 

60 

61 raise DependencyMissingVTK(message) 

62 

63 try: 

64 from vtk.qt.QVTKRenderWindowInteractor \ 

65 import QVTKRenderWindowInteractor 

66 

67 QVTKRenderWindowInteractor 

68 except ImportError: 

69 message = 'The installed version of VTK is incompatible with Qt5.' 

70 raise DependencyMissing(message)