Skip to content

Commit

Permalink
Ruff removed unused imports...
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristianTremblay committed Jan 27, 2024
1 parent c9b058e commit a725d78
Show file tree
Hide file tree
Showing 38 changed files with 34 additions and 173 deletions.
8 changes: 1 addition & 7 deletions BAC0/core/devices/Points.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,13 +399,7 @@ async def write(self, value, *, prop="presentValue", priority=""):

try:
await self.properties.device.properties.network.write(
"{} {} {} {} {} {}".format(
Address(self.properties.device.properties.address),
ObjectIdentifier(self.properties.type, self.properties.address),
PropertyIdentifier(prop),
value,
priority,
),
f"{Address(self.properties.device.properties.address)} {ObjectIdentifier(self.properties.type, self.properties.address)} {PropertyIdentifier(prop)} {value} - {priority}",
vendor_id=self.properties.device.properties.vendor_id,
)
except NoResponseFromController:
Expand Down
2 changes: 0 additions & 2 deletions BAC0/core/devices/Trends.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,10 @@
except ImportError:
_PANDAS = False

import asyncio
from collections import namedtuple

from bacpypes3.primitivedata import Date, Time

from ...tasks.TaskManager import Task

# --- this application's modules ---
from ..utils.notes import note_and_log
Expand Down
6 changes: 3 additions & 3 deletions BAC0/core/devices/local/decorator.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from functools import wraps

from bacpypes3.basetypes import EngineeringUnits, PriorityValue
from bacpypes3.local.cmd import Commandable, PriorityArray
from bacpypes3.basetypes import EngineeringUnits
from bacpypes3.local.cmd import Commandable
from bacpypes3.local.oos import OutOfService
from bacpypes3.object import TrendLogObject, Object as _Object
from bacpypes3.object import TrendLogObject
from bacpypes3.primitivedata import CharacterString

_SHOULD_BE_COMMANDABLE = ["relinquishDefault", "outOfService", "lowLimit", "highLimit"]
Expand Down
7 changes: 3 additions & 4 deletions BAC0/core/devices/local/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,10 @@
from collections import namedtuple

from bacpypes3.basetypes import (
Boolean,
Date,
DateTime,
EventState,
LogRecord,
Polarity,
PriorityArray,
Reliability,
Time,
Unsigned,
)
Expand All @@ -30,6 +26,7 @@
MultiStateOutputObject,
MultiStateValueObject,
)
from bacpypes3.local.cov import COVIncrementCriteria
from bacpypes3.primitivedata import CharacterString

from colorama import Fore
Expand Down Expand Up @@ -156,6 +153,8 @@ def _create(objectType, instance, objectName, presentValue, description):
self.objects[objectName]._local = LocalTrendLog(
self.objects[objectName], datatype=_localTrendLogDataType
) # this will need to be fed by another process.
else:
self.objects[objectName]._cov_criteria = COVIncrementCriteria

def validate_instance(self, objectType, instance):
_warning = True
Expand Down
2 changes: 1 addition & 1 deletion BAC0/core/devices/local/legacy/object.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def __init__(
if not isinstance(presentValue, pv_datatype):
try:
presentValue = pv_datatype(presentValue)
except:
except Exception:
raise ValueError(
f"Wrong datatype provided for presentValue for {objectType} of type {type(objectType)}"
)
Expand Down
2 changes: 0 additions & 2 deletions BAC0/core/devices/local/object.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from bacpypes3.constructeddata import ArrayOf, ListOf
from bacpypes3.local.cov import COVIncrementCriteria
from bacpypes3.local.object import Object as _Object

from bacpypes3.object import CharacterStringValueObject as _CharacterStringValueObject
Expand Down
3 changes: 0 additions & 3 deletions BAC0/core/functions/Alias.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import asyncio
import typing as t

from bacpypes3.app import Application
from bacpypes3.pdu import Address
from bacpypes3.primitivedata import ObjectIdentifier

from BAC0.core.app.asyncApp import BAC0Application

Expand Down
4 changes: 1 addition & 3 deletions BAC0/core/functions/Calendar.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import datetime
import typing as t

from bacpypes3.apdu import SimpleAckPDU, WritePropertyRequest
from bacpypes3.apdu import WritePropertyRequest
from bacpypes3.app import Application
from bacpypes3.basetypes import CalendarEntry, DateRange
from bacpypes3.constructeddata import Any, ArrayOf
Expand All @@ -18,8 +18,6 @@

from ...core.app.asyncApp import BAC0Application
from ...core.utils.notes import note_and_log
from ..io.IOExceptions import NoResponseFromController
from ..io.Read import find_reason


@note_and_log
Expand Down
4 changes: 1 addition & 3 deletions BAC0/core/functions/EventEnrollment.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
from bacpypes3.apdu import SimpleAckPDU, WritePropertyRequest
from bacpypes3.apdu import WritePropertyRequest
from bacpypes3.app import Application
from bacpypes3.basetypes import DeviceObjectPropertyReference, EventParameter
from bacpypes3.constructeddata import Any
from bacpypes3.pdu import Address

from BAC0.core.app.asyncApp import BAC0Application

from ..io.IOExceptions import NoResponseFromController
from ..io.Read import find_reason


# this class follows the same design as schedule/calendar
Expand Down
4 changes: 1 addition & 3 deletions BAC0/core/functions/Schedule.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# --- standard Python modules ---
from datetime import time as dt_time

from bacpypes3.apdu import SimpleAckPDU, WritePropertyRequest
from bacpypes3.apdu import WritePropertyRequest
from bacpypes3.app import Application
from bacpypes3.basetypes import DailySchedule, TimeValue
from bacpypes3.constructeddata import Any, ArrayOf
Expand All @@ -20,8 +20,6 @@

from ...core.app.asyncApp import BAC0Application
from ...core.utils.notes import note_and_log
from ..io.IOExceptions import NoResponseFromController
from ..io.Read import find_reason


@note_and_log
Expand Down
5 changes: 1 addition & 4 deletions BAC0/core/functions/Text.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
import asyncio

from bacpypes3.apdu import SimpleAckPDU, WritePropertyRequest
from bacpypes3.apdu import WritePropertyRequest
from bacpypes3.app import Application
from bacpypes3.constructeddata import Any
from bacpypes3.pdu import Address
from bacpypes3.primitivedata import CharacterString

from BAC0.core.app.asyncApp import BAC0Application
from BAC0.core.io.IOExceptions import NoResponseFromController, WritePropertyException
from BAC0.core.io.Read import find_reason


class TextMixin:
Expand Down
1 change: 0 additions & 1 deletion BAC0/core/functions/TimeSync.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
TimeSync.py - creation of time synch requests
"""
import asyncio

# --- standard Python modules ---
import datetime as dt
Expand Down
4 changes: 2 additions & 2 deletions BAC0/core/functions/legacy/Discover.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ def whois_router_to_network(self, network=None, *, destination=None):
)
else:
request.pduDestination = LocalBroadcast()
except:
except Exception:
self._log.error("WhoIsRouterToNetwork : invalid arguments")
return
iocb = IOCB((self.this_application.nsap.local_adapter, request)) # make an IOCB
Expand All @@ -312,7 +312,7 @@ def init_routing_table(self, address):
try:
request = InitializeRoutingTable()
request.pduDestination = Address(address)
except:
except Exception:
self._log.error("invalid arguments")
return

Expand Down
21 changes: 5 additions & 16 deletions BAC0/core/io/Read.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,10 @@ def readMultiple()
"""

import asyncio
import re

# --- standard Python modules ---
import typing as t
from collections import namedtuple

# from bacpypes3.core import deferred
# from bacpypes.iocb import IOCB, TimeoutError
Expand All @@ -37,10 +35,7 @@ def readMultiple()
PropertyReference,
Range,
ReadAccessSpecification,
ReadPropertyACK,
ReadPropertyMultipleACK,
ReadPropertyMultipleRequest,
ReadPropertyRequest,
ReadRangeACK,
ReadRangeRequest,
RejectPDU,
Expand All @@ -49,20 +44,17 @@ def readMultiple()
from bacpypes3.app import Application
from bacpypes3.basetypes import (
DateTime,
LogRecord,
LogRecordLogDatum,
PropertyIdentifier,
RangeByPosition,
RangeBySequenceNumber,
RangeByTime,
)
from bacpypes3.constructeddata import AnyAtomic, Array
from bacpypes3.errors import ExecutionError, ObjectError, PropertyError
from bacpypes3.errors import ObjectError, PropertyError
from bacpypes3.object import get_vendor_info

# --- 3rd party modules ---
from bacpypes3.pdu import Address
from bacpypes3.primitivedata import Date, ObjectIdentifier, Tag, Time, Unsigned
from bacpypes3.primitivedata import Date, ObjectIdentifier, Tag, Time

from BAC0.core.app.asyncApp import BAC0Application

Expand All @@ -71,9 +63,6 @@ def readMultiple()
# --- this application's modules ---
from .IOExceptions import (
ApplicationNotStarted,
NoResponseFromController,
ReadPropertyException,
ReadPropertyMultipleException,
ReadRangeException,
SegmentationNotSupported,
UnknownObjectError,
Expand Down Expand Up @@ -151,13 +140,13 @@ async def read(
except ErrorRejectAbortNack as err:
response = err
self._log.error(f"Error : {err}")
except ObjectError as err:
except ObjectError:
raise UnknownObjectError(f"Unknown object {args}")

# except bufferOverflow
# except NoResponseFromController

except PropertyError as err:
except PropertyError:
if "description" in args:
self._log.warning(
"The description property is not implemented in the device. "
Expand Down Expand Up @@ -862,7 +851,7 @@ def cast_datatype_from_tag(propertyValue, obj_id, prop_id):
subtype_tag = propertyValue.tagList.tagList[0].tagList[0].tagNumber
datatype = ArrayOf(Tag._app_tag_class[subtype_tag])
value = {f"{obj_id}_{prop_id}": propertyValue.cast_out(datatype)}
except:
except Exception:
value = {f"{obj_id}_{prop_id}": propertyValue}
return value

Expand Down
9 changes: 0 additions & 9 deletions BAC0/core/io/Write.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,15 @@ def write()
SimpleAckPDU,
WriteAccessSpecification,
WritePropertyMultipleRequest,
WritePropertyRequest,
)
from bacpypes3.app import Application
from bacpypes3.basetypes import PropertyIdentifier, PropertyValue
from bacpypes3.constructeddata import Any, Array

# --- 3rd party modules ---
from bacpypes3.debugging import ModuleLogger
from bacpypes3.pdu import Address
from bacpypes3.primitivedata import (
Atomic,
Enumerated,
Integer,
Null,
ObjectIdentifier,
Real,
Unsigned,
)

from ..app.asyncApp import BAC0Application
Expand All @@ -52,7 +44,6 @@ def write()
from .IOExceptions import (
ApplicationNotStarted,
NoResponseFromController,
WritePropertyCastError,
WritePropertyException,
)
from .Read import find_reason
Expand Down
4 changes: 2 additions & 2 deletions BAC0/core/io/legacy/Read.py
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ def build_rpm_request(
)
else:
break
except:
except Exception:
break

elif prop_id not in (
Expand Down Expand Up @@ -862,7 +862,7 @@ def cast_datatype_from_tag(propertyValue, obj_id, prop_id):
subtype_tag = propertyValue.tagList.tagList[0].tagList[0].tagNumber
datatype = ArrayOf(Tag._app_tag_class[subtype_tag])
value = {"{}_{}".format(obj_id, prop_id): propertyValue.cast_out(datatype)}
except:
except Exception:
value = {"{}_{}".format(obj_id, prop_id): propertyValue}
return value

Expand Down
1 change: 0 additions & 1 deletion BAC0/core/proprietary_objects/jci.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from bacpypes3.local.analog import AnalogValueObject as _AnalogValueObject
from bacpypes3.local.device import DeviceObject as _DeviceObject
from bacpypes3.local.networkport import NetworkPortObject as _NetworkPortObject
from bacpypes3.vendor import VendorInfo
from bacpypes3.primitivedata import Boolean # Signed,
from bacpypes3.primitivedata import (
Atomic,
Expand Down
2 changes: 1 addition & 1 deletion BAC0/core/proprietary_objects/legacy/object.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
def create_proprietary_object(params: Dict[str, Any]) -> None:
try:
_validate_params(params)
except:
except Exception:
raise
# Prevent breaking change for existing code, since issue #311
try:
Expand Down
4 changes: 2 additions & 2 deletions BAC0/db/influxdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def connect_to_db(self):
)
try:
self.health
except:
except Exception:
raise ConnectionError("Error connecting to InfluxDB")

@property
Expand All @@ -82,7 +82,7 @@ def clean_value(self, object_type, val, units_state):
elif "binary" in object_type:
try:
_string_value = "{}".format(units_state[int(val.split(":"[0]))])
except:
except Exception:
_string_value = "{}".format(val.split(":")[1])
_value = int(val.split(":")[0])
else:
Expand Down
2 changes: 1 addition & 1 deletion BAC0/db/sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ def _df_to_backup():
try:
data = pd.read_sql("SELECT * FROM history", con)
df = pd.concat([data, df_to_backup], sort=True)
except:
except Exception:
df = df_to_backup

sql.to_sql(
Expand Down
Loading

0 comments on commit a725d78

Please sign in to comment.