@cryptotaxi247 / netdata-1 / commits / 0b946686b

fix some python codacy errors (#5331)

* debug error instead of continue * portcheck: remove unused variable * postgres: remove unused variable * SocketService: log error on disconnect instead of pass * SocketService: add ssl_version opt to ssl.wrap_socket call * minor

Ilya Mashchenko committed Feb 5, 2019 at 15:36 UTC 0b946686b3ad2170469d4228f849d15633a47fcc
4 files changed +11 -9
collectors/python.d.plugin/ipfs/ipfs.chart.py
+2 -2
@@ -127,6 +127,6 @@ class Service(UrlService):
127 for new_key, orig_key, xmute in cfg[suburl]:
128 try:
129 r[new_key] = xmute(in_json[orig_key])
130 - except Exception:
131 - continue
130 + except Exception as error:
131 + self.debug(error)
132 return r or None
collectors/python.d.plugin/portcheck/portcheck.chart.py
+1 -1
@@ -118,7 +118,7 @@ class Service(SimpleService):
118 :return: dict
119 """
120
121 - af, _, proto, _, sa = socket_config
121 + _, _, proto, _, sa = socket_config
122 port = str(sa[1])
123 try:
124 self.debug('Connecting socket to "{address}", port {port}'.format(address=sa[0], port=port))
collectors/python.d.plugin/postgres/postgres.chart.py
+2 -2
@@ -1068,7 +1068,7 @@ def add_replication_delta_chart(order, definitions, name, application_name):
1068 chart_name = '_'.join([application_name, name])
1069 position = order.index('database_size')
1070 order.insert(position, chart_name)
1071 - name, title, units, family, context, chart_type = chart_template['options']
1071 + name, title, units, _, context, chart_type = chart_template['options']
1072 definitions[chart_name] = {
1073 'options': [name, title + ': ' + application_name, units, 'replication delta', context, chart_type],
1074 'lines': create_lines(application_name, chart_template['lines'])}
@@ -1086,7 +1086,7 @@ def add_replication_slot_chart(order, definitions, name, slot_name):
1086 chart_name = '_'.join([slot_name, name])
1087 position = order.index('database_size')
1088 order.insert(position, chart_name)
1089 - name, title, units, family, context, chart_type = chart_template['options']
1089 + name, title, units, _, context, chart_type = chart_template['options']
1090 definitions[chart_name] = {
1091 'options': [name, title + ': ' + slot_name, units, 'replication slot files', context, chart_type],
1092 'lines': create_lines(slot_name, chart_template['lines'])}
collectors/python.d.plugin/python_modules/bases/FrameworkServices/SocketService.py
+6 -4
@@ -75,9 +75,11 @@ class SocketService(SimpleService):
75 keyfile=self.key,
76 certfile=self.cert,
77 server_side=False,
78 - cert_reqs=ssl.CERT_NONE)
78 + cert_reqs=ssl.CERT_NONE,
79 + ssl_version=ssl.PROTOCOL_TLS,
80 + )
81 except (socket.error, ssl.SSLError) as error:
80 - self.error('Failed to wrap socket.')
82 + self.error('failed to wrap socket : {0}'.format(error))
83 self._disconnect()
84 self.__socket_config = None
85 return False
@@ -169,8 +171,8 @@ class SocketService(SimpleService):
171 self.debug('closing socket')
172 self._sock.shutdown(2) # 0 - read, 1 - write, 2 - all
173 self._sock.close()
172 - except Exception:
173 - pass
174 + except Exception as error:
175 + self.error(error)
176 self._sock = None
177
178 def _send(self, request=None):