mirror of
https://github.com/nicolargo/glances.git
synced 2024-12-23 01:01:31 +03:00
Use enum instead of int for callback API version.
This commit is contained in:
parent
cc7eeb2931
commit
f3b8b55ade
@ -64,11 +64,17 @@ class Export(GlancesExport):
|
|||||||
# Get the current callback api version
|
# Get the current callback api version
|
||||||
self.callback_api_version = int(self.callback_api_version) or 2
|
self.callback_api_version = int(self.callback_api_version) or 2
|
||||||
|
|
||||||
|
# Set enum for connection
|
||||||
|
if self.callback_api_version == 1:
|
||||||
|
self.callback_api_version = paho.CallbackAPIVersion.VERSION1
|
||||||
|
else:
|
||||||
|
self.callback_api_version = paho.CallbackAPIVersion.VERSION2
|
||||||
|
|
||||||
"""Init the connection to the MQTT server."""
|
"""Init the connection to the MQTT server."""
|
||||||
if not self.export_enable:
|
if not self.export_enable:
|
||||||
return None
|
return None
|
||||||
try:
|
try:
|
||||||
client = paho.Client(client_id='glances_' + self.devicename, clean_session=False)
|
client = paho.Client(callback_api_version=self.callback_api_version, client_id='glances_' + self.devicename, clean_session=False)
|
||||||
client.username_pw_set(username=self.user, password=self.password)
|
client.username_pw_set(username=self.user, password=self.password)
|
||||||
if self.tls:
|
if self.tls:
|
||||||
client.tls_set(certifi.where())
|
client.tls_set(certifi.where())
|
||||||
|
Loading…
Reference in New Issue
Block a user