def __init__(self):
super(SwarfarmLogger, self).__init__()
self.plugin_enabled = True
config_name = 'swproxy.config'
if not os.path.exists(config_name):
self.config = {}
else:
with open(config_name) as f:
self.config = json.load(f)
self.plugin_enabled = not self.config.get('disable_swarfarm_logger', False)
if self.plugin_enabled:
# Get the list of accepted commands from the server
logger.info('SwarfarmLogger - Retrieving list of accepted log types from SWARFARM...')
try:
resp = urllib2.urlopen(self.commands_url)
self.accepted_commands = json.loads(resp.readline())
resp.close()
logger.info('SwarfarmLogger - Looking for the following commands to log:\r\n' + ', '.join(self.accepted_commands.keys()))
except urllib2.HTTPError:
logger.fatal('SwarfarmLogger - Unable to retrieve accepted log types. SWARFARM logging is disabled.')
self.plugin_enabled = False
评论列表
文章目录