Skip to content

Commit

Permalink
adding module on_start to improve how poll callbacks are loaded
Browse files Browse the repository at this point in the history
  • Loading branch information
petersilva committed May 22, 2024
1 parent 09a28f0 commit 3920fca
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions sarracenia/flow/poll.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,6 @@ def __init__(self, options):
if not 'scheduled' in ','.join(self.plugins['load']):
self.plugins['load'].append('sarracenia.flowcb.scheduled.poll.Poll')

if not 'flowcb.poll.Poll' in ','.join(self.plugins['load']):
logger.info( f"adding poll plugin, because missing from: {self.plugins['load']}" )
self.plugins['load'].append('sarracenia.flowcb.poll.Poll')

if options.vip:
self.plugins['load'].insert( 0, 'sarracenia.flowcb.gather.message.Message')

Expand All @@ -80,3 +76,14 @@ def __init__(self, options):
if not features['ftppoll']['present']:
if hasattr( self.o, 'pollUrl' ) and ( self.o.pollUrl.startswith('ftp') ):
logger.critical( f"attempting to configure an FTP poll pollUrl={self.o.pollUrl}, but missing python modules: {' '.join(features['ftppoll']['modules_needed'])}" )

def on_start(self):

if 'poll' not in self.plugins or not self.plugins['poll']:
logger.info( f"adding built-in poll plugin, because no other poll provided from: {self.plugins['load']}" )

self.plugins['load'].append('sarracenia.flowcb.poll.Poll')
plugin = sarracenia.flowcb.load_library("sarracenia.flowcb.poll.Poll", self.o)
self.plugins['poll'] = [ getattr(plugin, 'poll') ]
else:
logger.info( f"not adding built-in poll, because already present: {self.plugins['poll']} " )

0 comments on commit 3920fca

Please sign in to comment.