@cryptotaxi247 / netdata-1 / commits / bdcea98ea

beanstalk fix

lgz committed Nov 3, 2017 at 02:24 UTC bdcea98eaddd801fdcd0d7fd49d5091f00185e26
1 file changed +12 -8
python.d/beanstalk.chart.py
+12 -8
@@ -3,7 +3,6 @@
3 # Author: l2isbad
4
5 from collections import defaultdict
6 -from sys import version_info
6
7 try:
8 import beanstalkc
@@ -11,12 +10,11 @@ try:
10 except ImportError:
11 BEANSTALKC = False
12
14 -
15 -if version_info[:2] > (3, 1):
16 - import pyyaml3 as yaml
17 -else:
18 - import pyyaml2 as yaml
19 -
13 +try:
14 + import yaml
15 + YAML = True
16 +except ImportError:
17 + YAML = False
18
19 from bases.FrameworkServices.SimpleService import SimpleService
20
@@ -168,7 +166,7 @@ class Service(SimpleService):
166 def __init__(self, configuration=None, name=None):
167 SimpleService.__init__(self, configuration=configuration, name=name)
168 self.configuration = configuration
171 - self.conn = self.connect()
169 + self.conn = None
170 self.order = ORDER[:]
171 self.definitions = dict(CHARTS)
172 self.alive = True
@@ -178,6 +176,12 @@ class Service(SimpleService):
176 self.error("'beanstalkc' module is needed to use beanstalk.chart.py")
177 return False
178
179 + if not YAML:
180 + self.error("'yaml' module is needed to use beanstalk.chart.py")
181 + return False
182 +
183 + self.conn = self.connect()
184 +
185 if not self.conn:
186 return False
187