forked from graphite-project/graphite-web
-
Notifications
You must be signed in to change notification settings - Fork 0
/
check-dependencies.py
executable file
·161 lines (126 loc) · 4.77 KB
/
check-dependencies.py
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
#!/usr/bin/env python
import sys
# Simple python version test
major,minor = sys.version_info[:2]
py_version = sys.version.split()[0]
if major != 2 or minor < 7:
# SystemExit defaults to returning 1 when printing a string to stderr
raise SystemExit("You are using python %s, but version 2.7 or greater is required" % py_version)
required = 0
optional = 0
# Test for whisper
try:
import whisper
except ImportError:
# No? test for ceres
try:
import ceres
# We imported ceres, but not whisper so it's an optional dependency
sys.stderr.write("[OPTIONAL] Unable to import the 'whisper' module. Without it the webapp will be unable to read .wsp files\n")
optional += 1
except ImportError:
sys.stderr.write("[REQUIRED] Unable to import the 'whisper' or 'ceres' modules, please download this package from the Graphite project page and install it.\n")
required += 1
# Test for pycairo or cairocffi
try:
import cairo
except ImportError:
try:
import cairocffi as cairo
except ImportError:
sys.stderr.write("[REQUIRED] Unable to import the 'cairo' module, do you have pycairo installed for python %s?\n" % py_version)
cairo = None
required += 1
# Test that pycairo has the PNG backend
try:
if cairo:
surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, 10, 10)
del surface
except Exception:
sys.stderr.write("[REQUIRED] Failed to create an ImageSurface with cairo, you probably need to recompile cairo with PNG support\n")
required += 1
# Test that cairo can find fonts
try:
if cairo:
surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, 10, 10)
context = cairo.Context(surface)
context.font_extents()
del surface, context
except Exception:
sys.stderr.write("[REQUIRED] Failed to create text with cairo, this probably means cairo cant find any fonts. Install some system fonts and try again\n")
# Test for django
try:
import django
except ImportError:
sys.stderr.write("[REQUIRED] Unable to import the 'django' module, do you have Django installed for python %s?\n" % py_version)
django = None
required += 1
# Test for pytz
try:
import pytz
except ImportError:
sys.stderr.write("[REQUIRED] Unable to import the 'pytz' module, do you have pytz module installed for python %s?\n" % py_version)
required += 1
# Test for pyparsing
try:
import pyparsing
except ImportError:
sys.stderr.write("[REQUIRED] Unable to import the 'pyparsing' module, do you have pyparsing module installed for python %s?\n" % py_version)
required += 1
# Test for django-tagging
try:
import tagging
except ImportError:
sys.stderr.write("[REQUIRED] Unable to import the 'tagging' module, do you have django-tagging installed for python %s?\n" % py_version)
required += 1
if django and django.VERSION[:2] < (1,4):
sys.stderr.write("[REQUIRED] You have django version %s installed, but version 1.4 or greater is required\n" % django.get_version())
required += 1
# Test for a json module
try:
import json
except ImportError:
try:
import simplejson
except ImportError:
sys.stderr.write("[REQUIRED] Unable to import either the 'json' or 'simplejson' module, at least one is required.\n")
required += 1
# Test for python-memcached
try:
import memcache
except ImportError:
sys.stderr.write("[OPTIONAL] Unable to import the 'memcache' module, do you have python-memcached installed for python %s? This feature is not required but greatly improves performance.\n" % py_version)
optional += 1
# Test for python-ldap
try:
import ldap
except ImportError:
sys.stderr.write("[OPTIONAL] Unable to import the 'ldap' module, do you have python-ldap installed for python %s? Without python-ldap, you will not be able to use LDAP authentication in the graphite webapp.\n" % py_version)
optional += 1
# Test for txamqp
try:
import txamqp
except ImportError:
sys.stderr.write("[OPTIONAL] Unable to import the 'txamqp' module, this is required if you want to use AMQP as an input to Carbon. Note that txamqp requires python 2.5 or greater.\n")
optional += 1
# Test for python-rrdtool
try:
import rrdtool
except ImportError:
sys.stderr.write("[OPTIONAL] Unable to import the 'python-rrdtool' module, this is required for reading RRD.\n")
optional += 1
# Test for whitenoise
try:
import whitenoise
except ImportError:
sys.stderr.write("[OPTIONAL] Unable to import the 'whitenoise' module. This is useful for serving static files.\n")
optional += 1
if optional:
sys.stderr.write("%d optional dependencies not met. Please consider the optional items before proceeding.\n" % optional)
else:
print "All optional dependencies are met."
if required:
sys.stderr.write("%d necessary dependencies not met. Graphite will not function until these dependencies are fulfilled.\n" % required)
sys.exit(1)
else:
print "All necessary dependencies are met."