mirror of
https://github.com/BOSWatch/BW3-Core.git
synced 2026-04-07 07:14:10 +00:00
Avoid "DeprecationWarning: invalid escape sequence"
Without this change, many warnings like this will be generated while running pytest:
```
test/test_template.py:3
/build/source/test/test_template.py:3: DeprecationWarning: invalid escape sequence '\/'
"""!
```
This can also be seen when manually running python with warnings enabled.
This happens because the comment uses a multiline string and Python interprets the backslash in the logo as an escape character and complains that \/ is not a valid escape sequence. To fix this, prepend the string with the letter r to indicate that the backslash should be treated as a literal character, see https://docs.python.org/3/reference/lexical_analysis.html#index-20.
I also applied this change to all the comment strings since that shouldn't break anything and to establish it as a pattern for the future so this problem hopefully never happens again.
This is what I did specifically:
- Change the comment at the top of bw_client.py and bw_server.py to start with `"""!` since that seems to be the pattern here
- Search-and-Replace all occurances of `"""!` with `r"""!`
- Manually change the strings in `logoToLog()` in boswatch/utils/header.py
This commit is contained in:
parent
1b95474bc2
commit
d4dcc75711
50 changed files with 327 additions and 327 deletions
|
|
@ -1,6 +1,6 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
"""!
|
||||
r"""!
|
||||
____ ____ ______ __ __ __ _____
|
||||
/ __ )/ __ \/ ___/ | / /___ _/ /______/ /_ |__ /
|
||||
/ __ / / / /\__ \| | /| / / __ `/ __/ ___/ __ \ /_ <
|
||||
|
|
@ -26,10 +26,10 @@ logging.debug("- %s loaded", __name__)
|
|||
|
||||
|
||||
class InputBase(ABC):
|
||||
"""!Base class for handling inout sources"""
|
||||
r"""!Base class for handling inout sources"""
|
||||
|
||||
def __init__(self, inputQueue, inputConfig, decoderConfig):
|
||||
"""!Build a new InputSource class
|
||||
r"""!Build a new InputSource class
|
||||
|
||||
@param inputQueue: Python queue object to store input data
|
||||
@param inputConfig: ConfigYaml object with the inoutSource config
|
||||
|
|
@ -41,7 +41,7 @@ class InputBase(ABC):
|
|||
self._decoderConfig = decoderConfig
|
||||
|
||||
def start(self):
|
||||
"""!Start the input source thread"""
|
||||
r"""!Start the input source thread"""
|
||||
logging.debug("starting input thread")
|
||||
self._isRunning = True
|
||||
self._inputThread = threading.Thread(target=self._runThread, name="inputThread",
|
||||
|
|
@ -51,10 +51,10 @@ class InputBase(ABC):
|
|||
|
||||
@abstractmethod
|
||||
def _runThread(self, dataQueue, sdrConfig, decoderConfig):
|
||||
"""!Thread routine of the input source has to be inherit"""
|
||||
r"""!Thread routine of the input source has to be inherit"""
|
||||
|
||||
def shutdown(self):
|
||||
"""!Stop the input source thread"""
|
||||
r"""!Stop the input source thread"""
|
||||
if self._isRunning:
|
||||
logging.debug("wait for stopping the input thread")
|
||||
self._isRunning = False
|
||||
|
|
@ -62,7 +62,7 @@ class InputBase(ABC):
|
|||
logging.debug("input thread stopped")
|
||||
|
||||
def addToQueue(self, data):
|
||||
"""!Decode and add alarm data to the queue for further processing during boswatch client"""
|
||||
r"""!Decode and add alarm data to the queue for further processing during boswatch client"""
|
||||
bwPacket = Decoder.decode(data)
|
||||
if bwPacket is not None:
|
||||
self._inputQueue.put_nowait((bwPacket, time.time()))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue