class SuperdeskSentry: """Sentry proxy that will do nothing in case sentry is not configured.""" def __init__(self, app): if app.config.get(SENTRY_DSN): if "verify_ssl" not in app.config[SENTRY_DSN]: app.config[SENTRY_DSN] += "?verify_ssl=0" app.config.setdefault("SENTRY_NAME", app.config.get("SERVER_DOMAIN")) self.sentry = Sentry(app, register_signal=False, wrap_wsgi=False, logging=True, level=logging.WARNING) register_logger_signal(self.sentry.client) register_signal(self.sentry.client) else: self.sentry = None def captureException(self, exc_info=None, **kwargs): if self.sentry: self.sentry.captureException(exc_info, **kwargs) def captureMessage(self, message, **kwargs): if self.sentry: self.sentry.captureMessage(message, **kwargs)
class SuperdeskSentry(): """Sentry proxy that will do nothing in case sentry is not configured.""" def __init__(self, app): if app.config.get('SENTRY_DSN'): self.sentry = Sentry(app, register_signal=False, wrap_wsgi=False) else: self.sentry = None def captureException(self, exc_info=None, **kwargs): if self.sentry: self.sentry.captureException(exc_info, **kwargs) def captureMessage(self, message, **kwargs): if self.sentry: self.sentry.captureMessage(message, **kwargs)
class SuperdeskSentry(): """Sentry proxy that will do nothing in case sentry is not configured.""" def __init__(self, app): if app.config.get('SENTRY_DSN'): app.config.setdefault('SENTRY_NAME', app.config.get('SERVER_NAME')) self.sentry = Sentry(app, register_signal=False, wrap_wsgi=False) else: self.sentry = None def captureException(self, exc_info=None, **kwargs): if self.sentry: self.sentry.captureException(exc_info, **kwargs) def captureMessage(self, message, **kwargs): if self.sentry: self.sentry.captureMessage(message, **kwargs)
resp = { "qtnum": qtnum, "premium": premium, "discount": discount, "error": error } print('---> Quote Response:', resp) return jsonify(resp) #### END OF function # main function if __name__ == '__main__': ## DISABLE CERITIFACATE VERIFICATION FOR SSL.. some issue in Capgemini network.. ''' try: _create_unverified_https_context = ssl._create_unverified_context except AttributeError: # Legacy Python that doesn't verify HTTPS certificates by default pass else: # Handle target environment that doesn't support HTTPS verification ssl._create_default_https_context = _create_unverified_https_context ''' sentry.captureMessage('Started runnning API for Home Quote !!') #app.run(debug= True) app.run(debug=True, port=5100) #turnoff debug for production deployment
app = Flask(__name__) app.config['SECRET_KEY'] = '95cd8af52647b2a8e726d3badf339c' bcrypt = Bcrypt() sentry = Sentry( app, dsn="https://[email protected]/1297235") monkey.patch_all() try: conn = psycopg2.connect( "dbname='my_db' user='******' host='localhost' password='******'" ) except: print "I am ubable to connect to the database" sentry.captureMessage('I am ubable to connect to the database') exit() @app.route('/') def home(): user = None keys = ('email', 'author', 'title', 'content', 'date_posted') posts = [] dict_posts = [] with conn.cursor() as cur: cur.execute('''SELECT my_user.email, my_user.username, post.title,
#print(x, type(x)) y_prob = model.predict_proba(x) print('completed..', '\n\n') stat_code = 100 reason = 'successful' prob = round(y_prob[0, 1], 2) except Exception as e: stat_code = 500 reason = 'Oops, something went wrong, looks like it got tired!!' prob = 99 print(e) #printing all exceptions to the log finally: resp = {'INCPROB': prob, 'STATUS': stat_code, 'REASON': reason} print("The predicted probability is:", prob) return jsonify(resp) if __name__ == '__main__': sentry = Sentry( app, dsn= 'https://*****:*****@sentry.io/273115' ) sentry.captureMessage('Started runnning Safari app!!') app.run(debug=True, port=5100) #turnoff debug for production deployment
from datetime import datetime from flask import Flask, request, g, send_from_directory from flask_restful import Api, abort, reqparse, Resource from raven.contrib.flask import Sentry from .models import Annotation, db, init_tables app = Flask(__name__) app.config['ERROR_404_HELP'] = False sentry = None if not app.config['DEBUG']: sentry = Sentry(app) api = Api(app) if sentry: sentry.captureMessage('app started') @app.before_first_request def startup(): init_tables() print("database tables created") @app.before_request def before_request(): g.db = db # g.db.connect() @app.after_request
import logging from flask import Flask, request, current_app from bot import Osmbot from configobj import ConfigObj import os from raven.contrib.flask import Sentry import telegram application = Flask(__name__) application.debug = True Osmbot(application, '') config = ConfigObj('bot.conf') token = config['token'] telegram_api = telegram.Bot(config['token']) if 'sentry_dsn' in config: application.config['sentry_dsn'] = config['sentry_dsn'] sentry = Sentry(application, dsn=config['sentry_dsn']) sentry.captureMessage('OSMBot started', level=logging.INFO) application.sentry = sentry webhook = os.path.join(config['webhook'], config['token']) application.logger.debug('webhook:%s', config['webhook']) result = telegram_api.setWebhook(webhook) if result: application.logger.debug('Webhook set') if __name__ == '__main__': application.run(host='0.0.0.0', debug=True)
from flask import Flask, request, current_app from bot import Osmbot from configobj import ConfigObj import os from raven.contrib.flask import Sentry import telegram application = Flask(__name__) application.debug = True Osmbot(application, '') config = ConfigObj('bot.conf') token = config['token'] telegram_api = telegram.Bot(config['token']) if 'sentry_dsn' in config: application.config['sentry_dsn'] = config['sentry_dsn'] sentry = Sentry(application, dsn=config['sentry_dsn']) sentry.captureMessage('OSMBot started', level=logging.INFO) application.sentry = sentry webhook = os.path.join(config['webhook'], config['token']) application.logger.debug('webhook:%s', config['webhook']) result = telegram_api.setWebhook(webhook) if result: application.logger.debug('Webhook set') if __name__ == '__main__': application.run(host='0.0.0.0', debug=True)
# Due: https://www.python.org/dev/peps/pep-0476 import ssl try: _create_unverified_https_context = ssl._create_unverified_context except AttributeError: # Legacy Python that doesn't verify HTTPS certificates by default pass else: # Handle target environment that doesn't support HTTPS verification ssl._create_default_https_context = _create_unverified_https_context except ImportError: pass application = Flask(__name__) sentry = Sentry(application) sentry.captureMessage("Modul backend inicat", level=logging.INFO) Backend(application, url_prefix='/') required = [ 'openerp_server', 'openerp_database', ] config = config_from_environment('BACKEND', required, session_cookie_name=None) for k, v in config.items(): k = k.upper() print('CONFIG: {0}: {1}'.format(k, v)) if v is not None: application.config[k] = v if __name__ == "__main__": application.run(host='0.0.0.0', debug=True)
if request.method == 'POST': ret = incomingPOST(request) else: ret = incomingGET(request) if ret is None: jobj = {} jobj['status'] = -1 ret = json.dumps(jobj) #print ret except ZeroDivisionError: sentry.captureException() jobj = {} jobj['status'] = -1 ret = json.dumps(jobj) return ret @app.errorhandler(500) def internal_error(error): app.logger.error('Server Error: %s', (error)) return thread.start_new_thread(telegram_pooling, ( "Thread-Telegram", 10, )) sentry.captureMessage('Smart Home Started...') app.run(host='0.0.0.0', port=6001, debug=False)
print(e) sentry.captureMessage( message=e, level=logging.FATAL) #printing all exceptions to the log resp = { "messages": [ { "text": "An error occured while fetching the recall details for your vehicle - 103." }, ] } return jsonify(resp) if __name__ == '__main__': ## DISABLE CERITIFACATE VERIFICATION FOR SSL.. some issue in Capgemini network.. ''' try: _create_unverified_https_context = ssl._create_unverified_context except AttributeError: # Legacy Python that doesn't verify HTTPS certificates by default pass else: # Handle target environment that doesn't support HTTPS verification ssl._create_default_https_context = _create_unverified_https_context ''' sentry.captureMessage('Started runnning API for Recalls !!') app.run(debug=True, port=5100) #turnoff debug for production deployment
"messages": [ { "text": "An error occurred while fetching the details for your drivers license - 103." }, ] } print("--- Response -->", resp) return jsonify(resp) #### END OF function # main function if __name__ == '__main__': ## DISABLE CERITIFACATE VERIFICATION FOR SSL.. some issue in Capgemini network.. ''' try: _create_unverified_https_context = ssl._create_unverified_context except AttributeError: # Legacy Python that doesn't verify HTTPS certificates by default pass else: # Handle target environment that doesn't support HTTPS verification ssl._create_default_https_context = _create_unverified_https_context ''' sentry.captureMessage('Started runnning API for DL COR !!') #app.run(debug= True) app.run(debug=True, port=5100) #turnoff debug for production deployment