Skip to content
This repository was archived by the owner on Aug 15, 2022. It is now read-only.

Commit f12a90a

Browse files
author
Jeff Ammons
committed
Fix missing debug context in Job
1 parent 4c7fa8b commit f12a90a

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

rtmbot/core.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,15 @@ def load_plugins(self):
121121
class Plugin(object):
122122

123123
def __init__(self, name, plugin_config=None):
124+
'''
125+
A plugin in initialized with:
126+
- name (str)
127+
- plugin config (dict) - (from the yaml config)
128+
Values in config:
129+
- DEBUG (bool) - this will be overridden if debug is set in config for this plugin
130+
'''
124131
if plugin_config is None:
125-
plugin_config = {} # TODO: is this variable necessary?
132+
plugin_config = {}
126133
self.name = name
127134
self.jobs = []
128135
self.module = __import__(name)
@@ -136,7 +143,7 @@ def __init__(self, name, plugin_config=None):
136143
def register_jobs(self):
137144
if 'crontable' in dir(self.module):
138145
for interval, function in self.module.crontable:
139-
self.jobs.append(Job(interval, eval("self.module." + function)))
146+
self.jobs.append(Job(interval, eval("self.module." + function), self.debug))
140147
logging.info(self.module.crontable)
141148
self.module.crontable = []
142149
else:
@@ -177,10 +184,11 @@ def do_output(self):
177184

178185

179186
class Job(object):
180-
def __init__(self, interval, function):
187+
def __init__(self, interval, function, debug):
181188
self.function = function
182189
self.interval = interval
183190
self.lastrun = 0
191+
self.debug = debug
184192

185193
def __str__(self):
186194
return "{} {} {}".format(self.function, self.interval, self.lastrun)
@@ -190,11 +198,11 @@ def __repr__(self):
190198

191199
def check(self):
192200
if self.lastrun + self.interval < time.time():
193-
if not debug: # TODO: This isn't in scope any more
201+
if self.debug is False:
194202
try:
195203
self.function()
196204
except:
197-
self._dbg("problem")
205+
logging.debug("Problem in job check")
198206
else:
199207
self.function()
200208
self.lastrun = time.time()

0 commit comments

Comments
 (0)