beanstalk: use loaders.safe_load instead of yaml.load
lgz committed
Jul 27, 2018 at 18:14 UTC
9809d0ebc71e4b8da52df55dd4f6712f9530e6ee
2 files changed
+2
-12
python.d/README.md
-1
@@ -131,7 +131,6 @@ Module provides server and tube level statistics:
131
132
**Requirements:**
133
* `python-beanstalkc`
134
- * `python-yaml`
134
135
**Server statistics:**
136
python.d/beanstalk.chart.py
+2
-11
@@ -9,13 +9,8 @@ try:
9
except ImportError:
10
BEANSTALKC = False
11
12
-try:
13
- import yaml
14
- YAML = True
15
-except ImportError:
16
- YAML = False
17
-
12
from bases.FrameworkServices.SimpleService import SimpleService
13
+from bases.loaders import safe_load
14
15
# default module values (can be overridden per job in `config`)
16
# update_every = 2
@@ -177,10 +172,6 @@ class Service(SimpleService):
172
self.error("'beanstalkc' module is needed to use beanstalk.chart.py")
173
return False
174
180
- if not YAML:
181
- self.error("'yaml' module is needed to use beanstalk.chart.py")
182
- return False
183
-
175
self.conn = self.connect()
176
177
return True if self.conn else False
@@ -232,7 +223,7 @@ class Service(SimpleService):
223
return beanstalkc.Connection(host=host,
224
port=port,
225
connect_timeout=timeout,
235
- parse_yaml=yaml.load)
226
+ parse_yaml=safe_load)
227
except beanstalkc.SocketError as error:
228
self.error('Connection to {0}:{1} failed: {2}'.format(host, port, error))
229
return None