Skip to content

Commit

Permalink
style: format code with Autopep8, Black, ClangFormat, dotnet-format, …
Browse files Browse the repository at this point in the history
…Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf

This commit fixes the style issues introduced in d5cec43 according to the output
from Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java
Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt,
Scalafmt, StandardJS, StandardRB, swift-format and Yapf.

Details: None
  • Loading branch information
deepsource-autofix[bot] authored May 11, 2024
1 parent d5cec43 commit 15e0843
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions models/device_drivers/device_communication.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
# Import necessary libraries
import paho.mqtt.client as mqtt
import coapthon.client as coap
import paho.mqtt.client as mqtt
import requests

# Define a class for device communication


class DeviceCommunication:
def __init__(self, device_config):
# Initialize device communication protocol
self.protocol = device_config['protocol']
self.host = device_config['host']
self.port = device_config['port']
self.topic = device_config['topic']
self.protocol = device_config["protocol"]
self.host = device_config["host"]
self.port = device_config["port"]
self.topic = device_config["topic"]

def mqtt_publish(self, message):
# Publish a message using MQTT protocol
Expand All @@ -36,14 +38,18 @@ def on_message(client, userdata, msg):
def coap_get(self, resource):
# Get a resource using CoAP protocol
client = coap.Client()
client.uri_format = 'coap://{host}:{port}/{resource}'.format(host=self.host, port=self.port, resource=resource)
client.uri_format = "coap://{host}:{port}/{resource}".format(
host=self.host, port=self.port, resource=resource
)
response = client.get()
return response.payload

def coap_put(self, resource, payload):
# Put a payload to a resource using CoAP protocol
client = coap.Client()
client.uri_format = 'coap://{host}:{port}/{resource}'.format(host=self.host, port=self.port, resource=resource)
client.uri_format = "coap://{host}:{port}/{resource}".format(
host=self.host, port=self.port, resource=resource
)
response = client.put(payload)
return response.payload

Expand Down

0 comments on commit 15e0843

Please sign in to comment.