BOSWatch 3
Python Script to receive and decode German BOS Information with rtl_fm and multimon-NG
 
Loading...
Searching...
No Matches
boswatch.packet.Packet Class Reference

Class implementation of an BOSWatch packet. More...

Public Member Functions

def __init__ (self, bwPacket=None)
 Build a new BOSWatch packet or copy existing data in it.
 
def __str__ (self)
 Return the intern _packet dict as string.
 
def set (self, fieldName, value)
 Set a field in the intern _packet dict.
 
def get (self, fieldName)
 Returns the value from a single field.
 
def printInfo (self)
 Print a info message to the log on INFO level.
 

Protected Attributes

 _packet
 

Detailed Description

Class implementation of an BOSWatch packet.

Constructor & Destructor Documentation

◆ __init__()

def boswatch.packet.Packet.__init__ (   self,
  bwPacket = None 
)

Build a new BOSWatch packet or copy existing data in it.

    @param bwPacket: Existing data to copy
26 def __init__(self, bwPacket=None):
27 r"""!Build a new BOSWatch packet or copy existing data in it
28
29 @param bwPacket: Existing data to copy"""
30 if bwPacket is None:
31 logging.debug("create new bwPacket")
32 self._packet = {"timestamp": time.time()}
33 else:
34 logging.debug("create bwPacket from string")
35 self._packet = eval(str(bwPacket.strip()))
36

Member Function Documentation

◆ __str__()

def boswatch.packet.Packet.__str__ (   self)

Return the intern _packet dict as string.

37 def __str__(self):
38 r"""!Return the intern _packet dict as string"""
39 return str(self._packet)
40

◆ set()

def boswatch.packet.Packet.set (   self,
  fieldName,
  value 
)

Set a field in the intern _packet dict.

    @param fieldName: Name of the data to set
    @param value: Value to set
41 def set(self, fieldName, value):
42 r"""!Set a field in the intern _packet dict
43
44 @param fieldName: Name of the data to set
45 @param value: Value to set"""
46 self._packet[fieldName] = str(value)
47

◆ get()

def boswatch.packet.Packet.get (   self,
  fieldName 
)

Returns the value from a single field.

If field not existing None is returned

Parameters
fieldNameName of the field
Returns
Value or None
48 def get(self, fieldName):
49 r"""!Returns the value from a single field.
50 If field not existing `None` is returned
51
52 @param fieldName: Name of the field
53 @return Value or None"""
54 try:
55 return str(self._packet[fieldName])
56 except:
57 logging.warning("field not found: %s", fieldName)
58 return None
59

◆ printInfo()

def boswatch.packet.Packet.printInfo (   self)

Print a info message to the log on INFO level.

Contains the most useful info about this packet.

Todo:
not complete yet - must be edit to print nice formatted messages on console
60 def printInfo(self):
61 r"""!Print a info message to the log on INFO level.
62 Contains the most useful info about this packet.
63 @todo not complete yet - must be edit to print nice formatted messages on console
64 """
65 logging.info("[%s]", self.get("mode"))

Field Documentation

◆ _packet

boswatch.packet.Packet._packet
protected