SwarfarmLogger.py 文件源码

python
阅读 35 收藏 0 点赞 0 评论 0

项目:SWProxy-plugins 作者: lstern 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号