1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

# https://pyrocko.org - GPLv3 

# 

# The Pyrocko Developers, 21st Century 

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

 

from __future__ import absolute_import, print_function, division 

 

from .info import * # noqa 

__version__ = version # noqa 

 

grumpy = False # noqa 

 

 

def get_logger(): 

from .util import logging 

return logging.getLogger('pyrocko') 

 

 

class ExternalProgramMissing(Exception): 

pass 

 

 

def sparrow(*args, **kwargs): 

''' 

Start Sparrow. 

 

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

''' 

 

check_have_vtk() 

 

from pyrocko.gui.sparrow.main import main 

return main(*args, **kwargs) 

 

 

class DependencyMissing(Exception): 

pass 

 

 

class DependencyMissingVTK(DependencyMissing): 

pass 

 

 

def check_have_vtk(): 

import sys 

try: 

from pyrocko.gui.qt_compat import use_pyqt5 

except ImportError: 

raise DependencyMissing('Qt is not available') 

 

try: 

import vtk # noqa 

except ImportError: 

message = '''VTK is not available. 

 

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

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

 

raise DependencyMissingVTK(message) 

 

if use_pyqt5: # noqa 

 

try: 

from vtk.qt.QVTKRenderWindowInteractor \ 

import QVTKRenderWindowInteractor 

 

QVTKRenderWindowInteractor 

except ImportError: 

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

 

Try using Qt4 by changing the following setting in the config file of Pyrocko 

(~/.pyrocko/config.pf): 

 

gui_toolkit: qt4 

''' 

raise DependencyMissing(message) 

 

else: 

try: 

from vtk.qt4.QVTKRenderWindowInteractor \ 

import QVTKRenderWindowInteractor 

 

QVTKRenderWindowInteractor 

except Exception as e: 

message = '''A problem with your Qt/VTK installation occurred. 

 

%s''' % str(e) 

raise DependencyMissing(message)