Skip to content

Commit

Permalink
Linting fixes + actions fix
Browse files Browse the repository at this point in the history
  • Loading branch information
durera committed Jun 1, 2024
1 parent d7d5d5f commit bd5ddb1
Show file tree
Hide file tree
Showing 12 changed files with 40 additions and 81 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
flake8 src --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
env:
ONE_JOB_ONLY_TESTS: ${{ secrets[matrix.primary-config] }}
ONE_JOB_ONLY_TESTS: ${{ matrix.primary-config }}
WIOTP_API_KEY: ${{ secrets.WIOTP_API_KEY }}
WIOTP_API_TOKEN: ${{ secrets.WIOTP_API_TOKEN }}
WIOTP_ORG_ID: ${{ secrets.WIOTP_ORG_ID }}
Expand Down
11 changes: 5 additions & 6 deletions src/wiotp/sdk/api/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

from wiotp.sdk.exceptions import ConfigurationException


class ApiClient:
def __init__(self, config, logger=None):
self._config = config
Expand Down Expand Up @@ -263,7 +262,7 @@ def updatedBy(self):


"""
This should be instantiated as a class property,
This should be instantiated as a class property,
it uses the instance parameter to access instance specific values TBD describe!!!
"""

Expand Down Expand Up @@ -360,11 +359,11 @@ def __iter__(self, *args, **kwargs):
def find(self, query_params={}):
"""
Gets the list of Schemas, they are used to call specific business logic when data in Watson IoT Platform changes.
Parameters:
- queryParams(dict) - Filter the results by the key-value pairs in the dictionary
Throws APIException on failure.
"""
return self._listToCast(self._apiClient, self._baseUrl, filters=query_params)
Expand Down Expand Up @@ -394,7 +393,7 @@ def __delitem__(self, key):

def create(self, item):
"""
Create an Item for the organization in the Watson IoT Platform.
Create an Item for the organization in the Watson IoT Platform.
Parameters:
- name (string) - Name of the service
- type - must be webhook
Expand Down
26 changes: 13 additions & 13 deletions src/wiotp/sdk/api/registry/devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,36 +336,36 @@ def __init__(self, apiClient, typeId=None):

class Devices(defaultdict):
"""
Use the global unique identifier of a device, it's `clientId` to address devices.
Use the global unique identifier of a device, it's `clientId` to address devices.
# Delete
```python
del devices["d:orgId:typeId:deviceId"]
```
# Get
Use the global unique identifier of a device, it's `clientId`.
Use the global unique identifier of a device, it's `clientId`.
```python
device = devices["d:orgId:typeId:deviceId"]
print(device.clientId)
print(device)
# Is a device registered?
```python
if "d:orgId:typeId:deviceId" in devices:
print("The device exists")
```
# Iterate through all registered devices
```python
for device in devices:
print(device)
```
"""

# https://docs.python.org/2/library/collections.html#defaultdict-objects
Expand Down Expand Up @@ -456,9 +456,9 @@ def create(self, devices):
The response body will contain the generated authentication tokens for all devices.
You must make sure to record these tokens when processing the response.
We are not able to retrieve lost authentication tokens
It accepts accepts a list of devices (List of Dictionary of Devices), or a single device
If you provide a list as the parameter it will return a list in response
If you provide a singular device it will return a singular response
"""
Expand Down
4 changes: 0 additions & 4 deletions src/wiotp/sdk/api/state/eventTypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@
# http://www.eclipse.org/legal/epl-v10.html
# *****************************************************************************

from collections import defaultdict
import iso8601

from wiotp.sdk.exceptions import ApiException
from wiotp.sdk.api.common import IterableList
from wiotp.sdk.api.common import RestApiDict
from wiotp.sdk.api.common import RestApiItemBase
Expand Down
4 changes: 0 additions & 4 deletions src/wiotp/sdk/api/state/logicalInterfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,10 @@
# http://www.eclipse.org/legal/epl-v10.html
# *****************************************************************************

from collections import defaultdict
import iso8601

from wiotp.sdk.exceptions import ApiException
from wiotp.sdk.api.common import IterableList
from wiotp.sdk.api.common import RestApiDict
from wiotp.sdk.api.common import RestApiItemBase
from wiotp.sdk.api.common import RestApiDictReadOnly
from wiotp.sdk.api.state.rules import DraftRulesPerLI
from wiotp.sdk.api.state.rules import ActiveRulesPerLI

Expand Down
3 changes: 0 additions & 3 deletions src/wiotp/sdk/api/state/physicalInterfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,11 @@
# *****************************************************************************

from collections import defaultdict
import iso8601

from wiotp.sdk.exceptions import ApiException
from wiotp.sdk.api.common import IterableList
from wiotp.sdk.api.common import IterableSimpleList
from wiotp.sdk.api.common import RestApiDict
from wiotp.sdk.api.common import RestApiItemBase
from wiotp.sdk.api.common import RestApiDictReadOnly

# See docs @ https://orgid.internetofthings.ibmcloud.com/docs/v0002/state-mgmt.html#/Physical Interfaces

Expand Down
2 changes: 0 additions & 2 deletions src/wiotp/sdk/api/state/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@
# http://www.eclipse.org/legal/epl-v10.html
# *****************************************************************************

from collections import defaultdict
from requests_toolbelt.multipart.encoder import MultipartEncoder

from wiotp.sdk.api.common import IterableList
from wiotp.sdk.api.common import RestApiItemBase
from wiotp.sdk.api.common import RestApiDict
from wiotp.sdk.api.common import RestApiDictReadOnly
from wiotp.sdk.exceptions import ApiException

import json
Expand Down
3 changes: 0 additions & 3 deletions src/wiotp/sdk/api/state/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@
from collections import defaultdict
import iso8601
from wiotp.sdk.exceptions import ApiException
from wiotp.sdk.api.common import IterableList
from wiotp.sdk.api.common import RestApiDict
from wiotp.sdk.api.common import RestApiItemBase
from wiotp.sdk.api.common import RestApiDictReadOnly

# See docs @ https://orgid.internetofthings.ibmcloud.com/docs/v0002-beta/State-mgr-beta.html
Expand Down
14 changes: 7 additions & 7 deletions src/wiotp/sdk/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
class ConnectionException(Exception):
"""
Generic Connection exception
# Attributes
reason (string): The reason why the connection exception occured
"""
Expand All @@ -26,7 +26,7 @@ def __str__(self):
class ConfigurationException(Exception):
"""
Specific Connection exception where the configuration is invalid
# Attributes
reason (string): The reason why the configuration is invalid
"""
Expand All @@ -41,7 +41,7 @@ def __str__(self):
class UnsupportedAuthenticationMethod(ConnectionException):
"""
Specific Connection exception where the authentication method specified is not supported
# Attributes
method (string): The authentication method that is unsupported
"""
Expand All @@ -56,7 +56,7 @@ def __str__(self):
class InvalidEventException(Exception):
"""
Specific exception where an Event object can not be constructed
# Attributes
reason (string): The reason why the event could not be constructed
"""
Expand All @@ -71,7 +71,7 @@ def __str__(self):
class MissingMessageDecoderException(Exception):
"""
Specific exception where there is no message decoder defined for the message format being processed
# Attributes
format (string): The message format for which no encoder could be found
"""
Expand All @@ -86,7 +86,7 @@ def __str__(self):
class MissingMessageEncoderException(Exception):
"""
Specific exception where there is no message encoder defined for the message format being processed
# Attributes
format (string): The message format for which no encoder could be found
"""
Expand All @@ -101,7 +101,7 @@ def __str__(self):
class ApiException(Exception):
"""
Exception raised when any API call fails unexpectedly
# Attributes
response (requests.Response): See: http://docs.python-requests.org/en/master/api/#requests.Response
"""
Expand Down
17 changes: 1 addition & 16 deletions src/wiotp/sdk/gateway/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,10 @@
# http://www.eclipse.org/legal/epl-v10.html
# *****************************************************************************

import json
import re
import pytz
import uuid
import threading
import requests
import logging
import paho.mqtt.client as paho

from datetime import datetime

from wiotp.sdk import (
AbstractClient,
InvalidEventException,
UnsupportedAuthenticationMethod,
ConfigurationException,
ConnectionException,
MissingMessageEncoderException,
MissingMessageDecoderException,
InvalidEventException
)
from wiotp.sdk.device import DeviceClient
from wiotp.sdk.device.command import Command
Expand Down
11 changes: 1 addition & 10 deletions src/wiotp/sdk/gateway/managedClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,15 @@
# *****************************************************************************

import json
import re
import pytz
import uuid
import threading
import requests
import logging
import paho.mqtt.client as paho

from datetime import datetime

from wiotp.sdk import (
AbstractClient,
InvalidEventException,
UnsupportedAuthenticationMethod,
ConfigurationException,
ConnectionException,
MissingMessageEncoderException,
MissingMessageDecoderException,
InvalidEventException
)
from wiotp.sdk.device.managedClient import ManagedDeviceClient
from wiotp.sdk.device.deviceInfo import DeviceInfo
Expand Down
24 changes: 12 additions & 12 deletions src/wiotp/sdk/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ def decode(message):

class JsonCodec(MessageCodec):
"""
This is the default encoder used by clients for all messages sent with format
This is the default encoder used by clients for all messages sent with format
defined as "json". This default can be changed by reconfiguring your client:
deviceCli.setMessageCodec("json", myCustomEncoderModule)
"""

Expand All @@ -43,7 +43,7 @@ def encode(data=None, timestamp=None):
def decode(message):
"""
Convert a generic JSON message
* The entire message is converted to JSON and treated as the message data
* The timestamp of the message is the time that the message is RECEIVED
"""
Expand All @@ -60,9 +60,9 @@ def decode(message):

class RawCodec(MessageCodec):
"""
Support sending and receiving bytearray, useful for transmitting raw data files. This is the default encoder used by clients for all messages sent with format
Support sending and receiving bytearray, useful for transmitting raw data files. This is the default encoder used by clients for all messages sent with format
defined as "raw". This default can be changed by reconfiguring your client:
deviceCli.setMessageCodec("raw", myCustomEncoderModule)
"""

Expand All @@ -87,9 +87,9 @@ def decode(message):

class Utf8Codec(MessageCodec):
"""
Support sending and receiving simple UTF-8 strings. This is the default encoder used by clients for all messages sent with format
Support sending and receiving simple UTF-8 strings. This is the default encoder used by clients for all messages sent with format
defined as "utf8". This default can be changed by reconfiguring your client:
deviceCli.setMessageCodec("utf8", myCustomEncoderModule)
"""

Expand All @@ -115,14 +115,14 @@ def decode(message):

class Message:
"""
Represents an abstract message recieved over Mqtt. All implementations of
Represents an abstract message recieved over Mqtt. All implementations of
a Codec must return an object of this type.
# Attributes
data (dict): The message payload
timestamp (datetime): Timestamp intended to denote the time the message was sent,
or `None` if this information is not available.
timestamp (datetime): Timestamp intended to denote the time the message was sent,
or `None` if this information is not available.
"""

def __init__(self, data, timestamp=None):
Expand Down

0 comments on commit bd5ddb1

Please sign in to comment.