Esempio n. 1
0
def not_implemented(e):
    status_code = 501
    response = jsonify({
        'status': status_code,
        'message': 'Not Implemented Yet'
    })
    response.status_code = status_code
    app_log.error(repr(response), extra={'sender': 'DataSource'})
    return response
Esempio n. 2
0
def general_err(e):
    status_code = 500
    response = jsonify({
        "status": status_code,
        "message": ("{0}: {1}").format(
            type(e).__name__,
            repr(e))
    })
    response.status_code = status_code
    app_log.error(repr(response), extra={'sender': 'DataSource'})
    return response
Esempio n. 3
0
 def get_labels():
     """
     Get label list
     :return: Object
     """
     try:
         result = Label.query.all()
         return result
     except Exception as e:
         app_log.error(repr(e), extra={'sender': 'DataSource'})
         raise e
Esempio n. 4
0
 def get_categories():
     """
     Get categories list
     :return: Object
     """
     try:
         result = Categories.query.all()
         return result
     except Exception as e:
         app_log.error(repr(e), extra={'sender': 'DataSource'})
         raise e
Esempio n. 5
0
 def set_category(name, desc=None):
     """
      Add a categories
     :param obj:{name:"",desc:""}
     :return:True/False
     """
     try:
         ca = Categories(name, desc)
         db.session.add(ca)
         db.session.commit()
     except Exception as e:
         db.session.rollback()
         app_log.error(repr(e), extra={'sender': 'DataSource'})
         raise e
Esempio n. 6
0
def handle_custom_err(error):
    response = jsonify(error.to_dict())
    response.status_code = error.status_code
    app_log.error(repr(response), extra={'sender': 'DataSource'})
    return response