当前位置: 首页>>代码示例>>Python>>正文


Python rollbar.report_exc_info方法代码示例

本文整理汇总了Python中rollbar.report_exc_info方法的典型用法代码示例。如果您正苦于以下问题:Python rollbar.report_exc_info方法的具体用法?Python rollbar.report_exc_info怎么用?Python rollbar.report_exc_info使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在rollbar的用法示例。


在下文中一共展示了rollbar.report_exc_info方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: execute

# 需要导入模块: import rollbar [as 别名]
# 或者: from rollbar import report_exc_info [as 别名]
def execute(self, user):
        """Send out emails for `user`

        One `user` may receive one or many emails
        """
        recipient = user
        email_batches_data = self.get_recipient_email_batches_data(recipient)
        for email_batch_data in email_batches_data:
            try:
                if self.has_email_batch_cooldown(recipient, **email_batch_data):
                    pass
                else:
                    self.send_email(recipient, **email_batch_data)
                    self.reset_email_batch_cooldown(recipient, **email_batch_data)
            except:
                extra_data = {
                    'user' : user,
                    'email_batch_data' : email_batch_data,
                }
                rollbar.report_exc_info(extra_data=extra_data) 
开发者ID:hacktoolkit,项目名称:django-htk,代码行数:22,代码来源:emails.py

示例2: default

# 需要导入模块: import rollbar [as 别名]
# 或者: from rollbar import report_exc_info [as 别名]
def default(self, obj):
        from django.contrib.auth import get_user_model
        UserModel = get_user_model()

        if isinstance(obj, datetime.datetime):
            value = int(mktime(obj.timetuple()))
        elif isinstance(obj, HtkBaseModel):
            value = obj.json_encode()
        elif isinstance(obj, UserModel):
            user = obj
            value = user.profile.json_encode()
        elif hasattr(obj, 'json_encode'):
            value = obj.json_encode()
        else:
            try:
                value = super(HtkJSONEncoder, self).default(obj)
            except:
                rollbar.report_exc_info(extra_data={'obj': obj,})
                value = -3.14159 # return an absurd value so that we know the object wasn't serializable
        return value 
开发者ID:hacktoolkit,项目名称:django-htk,代码行数:22,代码来源:utils.py

示例3: handle_event

# 需要导入模块: import rollbar [as 别名]
# 或者: from rollbar import report_exc_info [as 别名]
def handle_event(event):
    """Processes a validated webhook request from Slack

    https://api.slack.com/outgoing-webhooks

    Returns a payload if applicable, else None
    """
    event_handler = get_event_handler(event)
    if event_handler:
        try:
            payload = event_handler(event)
        except:
            payload = {
                'text' : """Oops, I couldn't process that.""",
            }
            rollbar.report_exc_info(extra_data={
                'event' : event,
                'event_handler' : event_handler.__name__,
            })
    else:
        payload = None
    return payload 
开发者ID:hacktoolkit,项目名称:django-htk,代码行数:24,代码来源:utils.py

示例4: get_friends_ids

# 需要导入模块: import rollbar [as 别名]
# 或者: from rollbar import report_exc_info [as 别名]
def get_friends_ids(screen_name):
    api = get_tweepy_api()
    ids = []
    is_first = True
    try:
        for page in tweepy.Cursor(api.friends_ids, screen_name=screen_name, count=5000).pages():
            if not is_first:
                time.sleep(60)
            else:
                is_first = False
            ids.extend(page)
    except tweepy.RateLimitError:
        extra_data = {
            'screen_name' : screen_name,
        }
        rollbar.report_exc_info(extra_data=extra_data)
    return ids 
开发者ID:hacktoolkit,项目名称:django-htk,代码行数:19,代码来源:utils.py

示例5: _fetch

# 需要导入模块: import rollbar [as 别名]
# 或者: from rollbar import report_exc_info [as 别名]
def _fetch(self):
        url = Zestimate.ZESTIMATE_URL
        params = {
            'zws-id' : self.zwsid,
            'zpid' : self.zpid,
        }
        try:
            response = requests.get(url, params=params)
            if response.status_code == 200:
                self.xml = response.content
            else:
                self.xml = None
        except:
            self.xml = None
            extra_data = self._rollbar_extra_data()
            extra_data.update({
                'url' : url,
                'params' : params,
            })
            rollbar.report_exc_info(extra_data=extra_data) 
开发者ID:hacktoolkit,项目名称:django-htk,代码行数:22,代码来源:utils.py

示例6: get_meal_today

# 需要导入模块: import rollbar [as 别名]
# 或者: from rollbar import report_exc_info [as 别名]
def get_meal_today(self):
        """Retrieves today's meal from Zesty API
        """
        url = self.get_url('meal_today')
        response = requests.get(url)
        meals = None
        if response.status_code == 200:
            try:
                meals_data = response.json()
                meals = ZestyMeals(self, meals_data)
            except:
                extra_data = {
                    'zesty_id' : self.zesty_id,
                }
                rollbar.report_exc_info(extra_data=extra_data)
        else:
            pass
        return meals 
开发者ID:hacktoolkit,项目名称:django-htk,代码行数:20,代码来源:classes.py

示例7: get_meals

# 需要导入模块: import rollbar [as 别名]
# 或者: from rollbar import report_exc_info [as 别名]
def get_meals(self):
        """Retrieves meals from Zesty API
        """
        url = self.get_url('meals')
        response = requests.get(url)
        meals = None
        if response.status_code == 200:
            try:
                meals_data = response.json()
                meals = ZestyMeals(self, meals_data)
            except:
                extra_data = {
                    'zesty_id' : self.zesty_id,
                }
                rollbar.report_exc_info(extra_data=extra_data)
        else:
            pass
        return meals 
开发者ID:hacktoolkit,项目名称:django-htk,代码行数:20,代码来源:classes.py

示例8: get_meal

# 需要导入模块: import rollbar [as 别名]
# 或者: from rollbar import report_exc_info [as 别名]
def get_meal(self, meal_id):
        """Retrieves one meal from Zesty API by `meal_id`
        """
        meal = None
        kwargs = {
            'meal_id' : meal_id,
        }
        url = self.get_url('meal', **kwargs)
        response = requests.get(url)
        if response.status_code == 200:
            try :
                meal_data = response.json()
                meal = ZestyMeal(self, meal_data)
            except:
                extra_data = {
                    'zesty_id' : self.zesty_id,
                    'meal_id' : meal_id,
                }
                rollbar.report_exc_info(extra_data=extra_data)
        else:
            pass
        return meal 
开发者ID:hacktoolkit,项目名称:django-htk,代码行数:24,代码来源:classes.py

示例9: get_person

# 需要导入模块: import rollbar [as 别名]
# 或者: from rollbar import report_exc_info [as 别名]
def get_person(self, email):
        """
        https://www.fullcontact.com/developer/docs/person/
        """
        person = None
        params = {
            'email' : email,
        }
        response = self.get('person', params)
        if response.status_code == 200:
            try:
                data = response.json()
                FullContactPerson = resolve_method_dynamically(htk_setting('HTK_FULLCONTACT_PERSON_CLASS'))
                person = FullContactPerson(email, data, version='v2')
            except:
                rollbar.report_exc_info(extra_data={'response' : response,})
        else:
            pass
        return person 
开发者ID:hacktoolkit,项目名称:django-htk,代码行数:21,代码来源:api.py

示例10: default_event_type_resolver

# 需要导入模块: import rollbar [as 别名]
# 或者: from rollbar import report_exc_info [as 别名]
def default_event_type_resolver(event):
    """The Hacktoolkit-flavored default event type resolver for Alexa webhook events
    """
    event_handlers = get_event_handlers(event)

    try:
        request = event.get('request', {})
        request_type = request.get('type')
        if request_type == 'LaunchRequest':
            intent_name = 'launch'
        elif request_type == 'IntentRequest':
            intent_name = event['request'].get('intent', {}).get('name', None)
        else:
            intent_name = None
    except:
        from htk.utils.request import get_current_request
        request = get_current_request()
        extra_data = { 'event' : event, }
        rollbar.report_exc_info(request=request, extra_data=extra_data)

    event_type = intent_name if intent_name in event_handlers else 'default'
    return event_type 
开发者ID:hacktoolkit,项目名称:django-htk,代码行数:24,代码来源:event_resolvers.py

示例11: generate_sso_key

# 需要导入模块: import rollbar [as 别名]
# 或者: from rollbar import report_exc_info [as 别名]
def generate_sso_key(self):
        request_url = self.get_request_url(resource_path=DSS_321FORMS_API_RESOURCE_SSO_GENERATE)
        response = self.request_get(request_url)
        exception_reported = False

        try:
            data = response.json()
            sso_key = data.get('SSOKey')
        except:
            sso_key = None
            extra_data = self._get_rollbar_extra_data()
            extra_data.update({
                'response_text': response.text,
            })
            rollbar.report_exc_info(extra_data=extra_data)
            exception_reported = True

        if sso_key is None and not exception_reported:
            request = get_current_request()
            extra_data = self._get_rollbar_extra_data()
            extra_data.update({
                'response_text': response.text,
            })
            rollbar.report_message('Error generating 321Forms SSO key', request=request, extra_data=extra_data)
        return sso_key 
开发者ID:hacktoolkit,项目名称:django-htk,代码行数:27,代码来源:api.py

示例12: job_runner

# 需要导入模块: import rollbar [as 别名]
# 或者: from rollbar import report_exc_info [as 别名]
def job_runner(f):
    """Accepts any callable function and runs it

    Catches any exceptions and logs to Rollbar
    """
    result = None
    try:
        ensure_mysql_connection_usable()
        result = f()
    except MySQLdb.OperationalError as e:
        extra_data = {
            'caught_exception' : True,
            'attempt_reconnect' : True,
        }
        rollbar.report_exc_info(extra_data=extra_data)
        attempt_mysql_reconnect()
    except:
        rollbar.report_exc_info()
    finally:
        close_connection()
    return result 
开发者ID:hacktoolkit,项目名称:django-htk,代码行数:23,代码来源:utils.py

示例13: _build_meta_content

# 需要导入模块: import rollbar [as 别名]
# 或者: from rollbar import report_exc_info [as 别名]
def _build_meta_content(data):
    """Build page title and META description and keywords before rendering
    """
    if data is None:
        data = {}
    meta = data.get('meta', {})
    if meta and type(meta) == dict:
        for meta_type, config in meta.items():
            _add_static_meta_content(meta_type, data)
            try:
                inverted_content = config.get('inverted', [])
                config['content'] = config.get('join_value', '').join(inverted_content[::-1])
                config['value'] = inverted_content[-1] if len(inverted_content) else ''
            except:
                request = data.get('request', {}).get('request')
                rollbar.report_exc_info(request=request) 
开发者ID:hacktoolkit,项目名称:django-htk,代码行数:18,代码来源:view_helpers.py

示例14: __exit__

# 需要导入模块: import rollbar [as 别名]
# 或者: from rollbar import report_exc_info [as 别名]
def __exit__(self, exc_type, exc_value, traceback):
        """
        report any errors via rollbar and shut down
        :param exc_type:
        :param exc_value:
        :param traceback:
        :return:
        """
        if (exc_type is not None) and (self.environment == "production"):
            panoptes_file = open("/app/config/aggregation.yml","rb")
            api_details = yaml.load(panoptes_file)

            rollbar_token = api_details[self.environment]["rollbar"]
            rollbar.init(rollbar_token,self.environment)
            rollbar.report_exc_info()

        # calling the parent
        AggregationAPI.__exit__(self, exc_type, exc_value, traceback) 
开发者ID:zooniverse,项目名称:aggregation,代码行数:20,代码来源:text_aggregation.py

示例15: help

# 需要导入模块: import rollbar [as 别名]
# 或者: from rollbar import report_exc_info [as 别名]
def help(message):
    try :
        message.reply('Commands:')
        message.reply('\'generate\': Generates insult')
        message.reply('\'change_lang <lang>\': Change insult language')
        message.reply('\'list_lang\': Lists available languages')
        message.reply('\'help\': Lists available commands')
    except:
        rollbar.report_exc_info() 
开发者ID:EvilInsultGenerator,项目名称:slack-bot,代码行数:11,代码来源:eig_plugin.py


注:本文中的rollbar.report_exc_info方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。