BOSWatch 3
Python Script to receive and decode German BOS Information with rtl_fm and multimon-NG
 
Loading...
Searching...
No Matches
plugin.http.BoswatchPlugin Class Reference

Description of the Plugin. More...

Public Member Functions

def __init__ (self, config)
 Do not change anything here!
 
def fms (self, bwPacket)
 Called on FMS alarm.
 
def pocsag (self, bwPacket)
 Called on POCSAG alarm.
 
def zvei (self, bwPacket)
 Called on ZVEI alarm.
 
def msg (self, bwPacket)
 Called on MSG packet.
 
- Public Member Functions inherited from plugin.pluginBase.PluginBase
def __init__ (self, pluginName, config)
 init preload some needed locals and then call onLoad() directly
 
def onLoad (self)
 Called by import of the plugin can be inherited.
 
def setup (self)
 Called before alarm can be inherited.
 
def fms (self, bwPacket)
 Called on FMS alarm can be inherited.
 
def pocsag (self, bwPacket)
 Called on POCSAG alarm can be inherited.
 
def zvei (self, bwPacket)
 Called on ZVEI alarm can be inherited.
 
def msg (self, bwPacket)
 Called on MSG packet can be inherited.
 
def teardown (self)
 Called after alarm can be inherited.
 
def onUnload (self)
 Called on shutdown of boswatch can be inherited.
 
def parseWildcards (self, msg)
 Return the message with parsed wildcards.
 

Protected Member Functions

def _makeRequests (self, urls)
 
def _asyncRequests (self, urls)
 
def _fetch (self, url, session)
 
- Protected Member Functions inherited from plugin.pluginBase.PluginBase
def _cleanup (self)
 Cleanup routine calls onUnload() directly.
 
def _run (self, bwPacket)
 start an complete running turn of an plugin.
 
def _getStatistics (self)
 Returns statistical information's from last plugin run.
 

Additional Inherited Members

- Data Fields inherited from plugin.pluginBase.PluginBase
 config
 
- Protected Attributes inherited from plugin.pluginBase.PluginBase
 _pluginName
 
 _bwPacket
 
 _sumTime
 
 _cumTime
 
 _setupTime
 
 _alarmTime
 
 _teardownTime
 
 _runCount
 
 _setupErrorCount
 
 _alarmErrorCount
 
 _teardownErrorCount
 
- Static Protected Attributes inherited from plugin.pluginBase.PluginBase
list _pluginsActive = []
 

Detailed Description

Description of the Plugin.

Constructor & Destructor Documentation

◆ __init__()

def plugin.http.BoswatchPlugin.__init__ (   self,
  config 
)

Do not change anything here!

Reimplemented from plugin.pluginBase.PluginBase.

31 def __init__(self, config):
32 r"""!Do not change anything here!"""
33 super().__init__(__name__, config) # you can access the config class on 'self.config'
34

Member Function Documentation

◆ fms()

def plugin.http.BoswatchPlugin.fms (   self,
  bwPacket 
)

Called on FMS alarm.

    @param bwPacket: bwPacket instance
    Remove if not implemented

Reimplemented from plugin.pluginBase.PluginBase.

35 def fms(self, bwPacket):
36 r"""!Called on FMS alarm
37
38 @param bwPacket: bwPacket instance
39 Remove if not implemented"""
40 urls = self.config.get("fms")
41 self._makeRequests(urls)
42

◆ pocsag()

def plugin.http.BoswatchPlugin.pocsag (   self,
  bwPacket 
)

Called on POCSAG alarm.

    @param bwPacket: bwPacket instance
    Remove if not implemented

Reimplemented from plugin.pluginBase.PluginBase.

43 def pocsag(self, bwPacket):
44 r"""!Called on POCSAG alarm
45
46 @param bwPacket: bwPacket instance
47 Remove if not implemented"""
48 urls = self.config.get("pocsag")
49 self._makeRequests(urls)
50

◆ zvei()

def plugin.http.BoswatchPlugin.zvei (   self,
  bwPacket 
)

Called on ZVEI alarm.

    @param bwPacket: bwPacket instance
    Remove if not implemented

Reimplemented from plugin.pluginBase.PluginBase.

51 def zvei(self, bwPacket):
52 r"""!Called on ZVEI alarm
53
54 @param bwPacket: bwPacket instance
55 Remove if not implemented"""
56 urls = self.config.get("zvei")
57 self._makeRequests(urls)
58

◆ msg()

def plugin.http.BoswatchPlugin.msg (   self,
  bwPacket 
)

Called on MSG packet.

    @param bwPacket: bwPacket instance
    Remove if not implemented

Reimplemented from plugin.pluginBase.PluginBase.

59 def msg(self, bwPacket):
60 r"""!Called on MSG packet
61
62 @param bwPacket: bwPacket instance
63 Remove if not implemented"""
64 urls = self.config.get("msg")
65 self._makeRequests(urls)
66

◆ _makeRequests()

def plugin.http.BoswatchPlugin._makeRequests (   self,
  urls 
)
protected
Parses wildcard urls and handles asynchronus requests

@param urls: array of urls
67 def _makeRequests(self, urls):
68 """Parses wildcard urls and handles asynchronus requests
69
70 @param urls: array of urls"""
71 urls = [self.parseWildcards(url) for url in urls]
72
73 loop = asyncio.get_event_loop()
74
75 future = asyncio.ensure_future(self._asyncRequests(urls))
76 loop.run_until_complete(future)
77

◆ _asyncRequests()

def plugin.http.BoswatchPlugin._asyncRequests (   self,
  urls 
)
protected
Handles asynchronus requests

@param urls: array of urls to send requests to
78 async def _asyncRequests(self, urls):
79 """Handles asynchronus requests
80
81 @param urls: array of urls to send requests to"""
82 tasks = []
83
84 async with ClientSession() as session:
85 for url in urls:
86 task = asyncio.ensure_future(self._fetch(url, session))
87 tasks.append(task)
88
89 responses = asyncio.gather(*tasks)
90 await responses
91

◆ _fetch()

def plugin.http.BoswatchPlugin._fetch (   self,
  url,
  session 
)
protected
Fetches requests

@param url: url

@param session: Clientsession instance
92 async def _fetch(self, url, session):
93 """Fetches requests
94
95 @param url: url
96
97 @param session: Clientsession instance"""
98 async with session.get(url) as response:
99 logging.info("{} returned [{}]".format(response.url, response.status))
100 return await response.read()