torrentclient.py 文件源码

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

项目:Seedbox-Statistics-For-InfluxDB 作者: barrycarey 项目源码 文件源码
def _make_request(self, req, genmsg='', fail_msg='', abort_on_fail=None):
        """
        Make the web request.  Doing it here avoids a lot of duplicate exception handling
        :param gen_msg: Message we can print to console or logs so we know about the request
        :param fail_msg: Message we can print to console or logs on failure
        :param abort_on_fail: Exit on failed request
        :return: Response
        """

        if genmsg:
            self.send_log(genmsg, 'info')

        try:
            res = urlopen(req)
        except URLError as e:

            if fail_msg:
                msg = fail_msg
            else:
                msg = 'Failed to make request'

            if abort_on_fail:
                self.send_log(msg, 'critical')
                self.send_log('Aborting', 'critical')
                sys.exit(1)
            else:
                self.send_log(msg, 'error')

            return None

        return res
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号