def cli(ctx, env): ctx.obj = {} logging.basicConfig(format='%(message)s') logging.getLogger("gigalixir-cli").setLevel(logging.INFO) ROLLBAR_POST_CLIENT_ITEM = "40403cdd48904a12b6d8d27050b12343" if env == "prod": stripe.api_key = 'pk_live_45dmSl66k4xLy4X4yfF3RVpd' rollbar.init(ROLLBAR_POST_CLIENT_ITEM, 'production', enabled=True) host = "https://api.gigalixir.com" elif env == "dev": stripe.api_key = 'pk_test_6tMDkFKTz4N0wIFQZHuzOUyW' rollbar.init(ROLLBAR_POST_CLIENT_ITEM, 'development', enabled=False) host = "http://localhost:4000" else: raise Exception("Invalid GIGALIXIR_ENV") ctx.obj['host'] = host PLATFORM = call("uname -s").lower() # linux or darwin if PLATFORM == "linux": ctx.obj['router'] = LinuxRouter() elif PLATFORM == "darwin": ctx.obj['router'] = DarwinRouter() else: raise Exception("Unknown platform: %s" % PLATFORM)
def _rollbar_track_err(conf, cluster_id, err, exit_code): """ Report to rollbar. Synchronous. :param conf: dcos config file :type conf: Toml :param cluster_id: dcos cluster id to send to segment :type cluster_id: str :param err: stderr of tracked process :type err: str :param exit_code: exit code of tracked process :type exit_code: int :rtype: None """ rollbar.init(ROLLBAR_SERVER_POST_KEY, 'prod') props = _base_properties(conf, cluster_id) props['exit_code'] = exit_code lines = err.split('\n') if len(lines) >= 2: title = lines[-2] else: title = err props['stderr'] = err try: rollbar.report_message(title, 'error', extra_data=props) except Exception as e: logger.exception(e)
def wait_and_track(subproc): """ Run a command and report it to analytics services. :param subproc: Subprocess to capture :type subproc: Popen :returns: exit code of subproc :rtype: int """ rollbar.init(ROLLBAR_SERVER_POST_KEY, 'prod') conf = util.get_config() report = conf.get('core.reporting', True) with ThreadPoolExecutor(max_workers=2) as pool: if report: _segment_track_cli(pool, conf) exit_code, err = wait_and_capture(subproc) # We only want to catch exceptions, not other stderr messages # (such as "task does not exist", so we look for the 'Traceback' # string. This only works for python, so we'll need to revisit # this in the future when we support subcommands written in other # languages. if report and 'Traceback' in err: _track_err(pool, exit_code, err, conf) return exit_code
def init_rollbar(): rollbar.init(cfg["rollbar"]["token"], cfg["rollbar"]["environment"], root=os.path.dirname(os.path.realpath(__file__)), allow_logging_basic_config=False) got_request_exception.connect(rollbar.contrib.flask.report_exception, app)
def maybe_enable_rollbar(): if not ROLLBAR_API_KEY: log.info( "ROLLBAR_API_KEY environment variable empty, rollbar disabled") return application_environment = ("production" if os.getenv("NYLAS_ENV", "") == "prod" else "dev") rollbar.init( ROLLBAR_API_KEY, application_environment, allow_logging_basic_config=False, ) rollbar_handler = SyncEngineRollbarHandler() rollbar_handler.setLevel(logging.ERROR) logger = logging.getLogger() logger.addHandler(rollbar_handler) message_filters = get_message_filters() rollbar.events.add_payload_handler( functools.partial(payload_handler, message_filters)) log.info("Rollbar enabled")
def reportException(self, class_name, p_line_no, p_message, logger, to_print=True, to_raise=True): trace_len = len(trace()) err_msg = "\nSKYZE EXCEPTION: " + class_name err_msg += "::" + trace()[1].function err_msg += "::" + str(trace()[1].lineno) err_msg += "\n Called: " + trace()[trace_len - 1].function err_msg += " on line: " + str(trace()[trace_len - 1].lineno) err_msg += "\n code Context: " + \ str(trace()[trace_len - 1].code_context) err_msg += "\n ...." + p_message + " ... " + str(sys.exc_info()[0]) err_msg += "\n LOCALS ...." + str(sys.exc_info()[2].tb_frame.f_locals) # pprint(str(sys.exc_info()[2].tb_frame.f_locals)) # print(json.dumps(sys.exc_info()[2].tb_frame.f_locals, indent=4)) # Log it log_message = f"{class_name}: : reportException: : exception created\n{err_msg}" logger.log_info(log_message, to_print) # Rollbar it rollbar_on = True if rollbar_on: rollbar.init('8f67acbc427a4d6ba80c31516bd355da', 'Mike Laptop') # access_token, environment rollbar.report_message(log_message) if to_raise: raise self
def configure_error_handling(sender, **kargs): """Rollbar and Sentry integration Based on https://www.mattlayman.com/blog/2017/django-celery-rollbar/ """ if not bool(os.environ.get('CELERY_WORKER_RUNNING', False)): return from django.conf import settings if HAS_ROLLBAR and hasattr(settings, 'ROLLBAR'): rollbar.init(**settings.ROLLBAR) def celery_base_data_hook(request, data): data['framework'] = 'celery' rollbar.BASE_DATA_HOOK = celery_base_data_hook @task_failure.connect def handle_task_failure(**kw): rollbar.report_exc_info(extra_data=kw) if HAS_RAVEN and hasattr(settings, 'RAVEN_CONFIG'): client = Client(settings.RAVEN_CONFIG['dsn']) register_signal(client, ignore_expected=True) register_logger_signal(client, loglevel=logging.ERROR)
def setup(loglevel): f = DataFilter() log = logging.getLogger() log.setLevel(getattr(logging, loglevel)) local_logger = logging.StreamHandler() local_logger.setLevel(getattr(logging, loglevel)) # add formatter to local_logger local_logger.setFormatter( logging.Formatter('%(name)s %(levelname)s %(message)s %(data)s')) local_logger.addFilter(f) log.addHandler(local_logger) if settings.ROLLBAR_API_KEY: notify_log = logging.getLogger('notify') rollbar.init( settings.ROLLBAR_API_KEY, settings.ROLLBAR_ENVIRONMENT, scrub_fields=settings.ROLLBAR_SCRUB_FIELDS, ) # Send to rollbar all WARNING or higher logs rollbar_warn_logger = rollbar.logger.RollbarHandler() rollbar_warn_logger.setLevel(logging.WARNING) rollbar_warn_logger.addFilter(f) log.addHandler(rollbar_warn_logger) # Send to rollbar INFO or higher logs only from separate logger rollbar_info_logger = rollbar.logger.RollbarHandler() rollbar_info_logger.setLevel(logging.INFO) rollbar_info_logger.addFilter(f) notify_log.addHandler(rollbar_info_logger) else: log.warning('No Rollbar Api Key, logging locally only')
def configure_error_handling(sender, **kargs): """Rollbar and Sentry integration Based on https://www.mattlayman.com/blog/2017/django-celery-rollbar/ """ if not bool(os.environ.get('CELERY_WORKER_RUNNING', False)): return from django.conf import settings if HAS_ROLLBAR and hasattr(settings, 'ROLLBAR'): rollbar.init(**settings.ROLLBAR) def celery_base_data_hook(request, data): data['framework'] = 'celery' rollbar.BASE_DATA_HOOK = celery_base_data_hook @task_failure.connect def handle_task_failure(**kw): rollbar.report_exc_info(extra_data=kw) if HAS_RAVEN and hasattr(settings, 'RAVEN_CONFIG'): client = Client( settings.RAVEN_CONFIG['dsn'], release=settings.RAVEN_CONFIG.get('release'), environment=settings.RAVEN_CONFIG.get('environment'), ) register_signal(client, ignore_expected=True) register_logger_signal(client, loglevel=logging.ERROR)
def initialize_rollbar() -> None: config = get_config() rollbar.init( get_config().rollbar_id, environment=config.rollbar_environment_name, code_version=sneaky_client.__version__, )
def transform_and_roll_out(): logging.basicConfig(stream=sys.stdout, level=logging.INFO) sys.excepthook = uncaught_ex_handler parser = create_argparser() args = parser.parse_args() configuration = get_bot_defaults() if args.conf: with open(args.conf) as cfile: configuration.update(parse_config(cfile)) # Environment variables override configuration file settings env_config = get_environment_configuration() configuration.update(env_config) if ROLLBAR_ACCESS_TOKEN in configuration: rollbar.init(configuration[ROLLBAR_ACCESS_TOKEN], configuration[ROLLBAR_ENVIRONMENT]) rollbar_handler = RollbarHandler() rollbar_handler.setLevel(logging.ERROR) logging.getLogger('').addHandler(rollbar_handler) # This is hack-city, but since we're constructing the redis data # after the fact, we'll now bolt the database back into the baseclass walrus = Walrus(host=configuration[REDIS_URL], port=configuration[REDIS_PORT], password=configuration[REDIS_PASSWORD]) AutoBotBaseModel.set_database(walrus) bot = AutoBot(configuration) bot.run(args.forever, args.interval)
def main(): rollbar.init('ACCESS_TOKEN', environment='test', handler='twisted') """This runs the protocol on port 8000""" factory = protocol.ServerFactory() factory.protocol = Echo reactor.listenTCP(8000, factory) reactor.run()
def setUp(self): rollbar._initialized = False rollbar.SETTINGS = copy.deepcopy(_default_settings) rollbar.init(_test_access_token, locals={'enabled': True}, dummy_key='asdf', timeout=12345)
def init_rollbar(): rollbar.init(TOKEN, 'flasktest', root=os.path.dirname(os.path.realpath(__file__)), allow_logging_basic_config=True) got_request_exception.connect(rollbar.contrib.flask.report_exception, app)
def __s3_upload__(self): """ upload the file to s3 see http://boto.cloudhackers.com/en/latest/s3_tut.html :return: """ # s3 = boto3.resource('s3') s3, _ = self.__s3_connect__() aws_tar = self.__get_aws_tar_name__() b = s3.get_bucket('zooniverse-static') key_str = "panoptes-uploads.zooniverse.org/production/project_aggregations_export/" + aws_tar s3_key = Key(b) s3_key.key = key_str if not os.path.exists("/tmp/" + aws_tar): print( "warning the tar file does not exist - creating an temporary one." ) 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_message('the tar file does not exist', 'warning') with open("/tmp/" + aws_tar, "w") as f: f.write("") s3_key.set_contents_from_filename("/tmp/" + aws_tar)
def init_rollbar(): """Initialize Rollbar exception logging""" key = environ.get("LOG_KEY") if not (key and app.env == "production"): return rollbar.init(key, root="avwx_api", allow_logging_basic_config=False) got_request_exception.connect(report_exception, app, weak=False)
def init_logger(): # Remove all logger sinks. logger.remove() # Add filtered sys.stdout. logger.add(sys.stdout, filter=bittensor_log_filter, colorize=True, enqueue=True, backtrace=True, diagnose=True, format=bittensor_formatter) # Add filtered rollbar handler. rollbar_token = os.environ.get("ROLLBAR_TOKEN", False) rollbar_env = os.environ.get("BT_ENV", "production") rollbar_handler = RollbarHandler() if rollbar_token: # Rollbar is enabled. logger.info("Error reporting enabled using {}:{}", rollbar_token, rollbar_env) rollbar.init(rollbar_token, rollbar_env) logger.add( sink=rollbar_handler, level='WARNING', colorize=True, enqueue=True, backtrace=True, diagnose=True, ) # Return internal logger return logger.bind(internal=True)
def __init__(self): self.settings = getattr(settings, 'ROLLBAR', {}) if not self.settings.get('access_token'): raise MiddlewareNotUsed if not self._get_setting('enabled'): raise MiddlewareNotUsed self._ensure_log_handler() kw = self.settings.copy() access_token = kw.pop('access_token') environment = kw.pop('environment', 'development' if settings.DEBUG else 'production') kw.setdefault('exception_level_filters', DEFAULTS['exception_level_filters']) rollbar.init(access_token, environment, **kw) def hook(request, data): data['framework'] = 'django' if request: request.META['rollbar.uuid'] = data['uuid'] rollbar.BASE_DATA_HOOK = hook # monkeypatch debug module if self._get_setting('patch_debugview'): try: _patch_debugview(self._get_setting('web_base')) except Exception, e: log.error("Rollbar - unable to monkeypatch debugview to add 'View in Rollbar' link." " To disable, set `ROLLBAR['patch_debugview'] = False` in settings.py." " Exception was: %r", e)
def __init__(self, *args, **kwargs): if 'exception_level_filters' in kwargs: kwargs['exception_level_filters'].append((bottle.BaseResponse, 'ignored')) else: kwargs['exception_level_filters'] = [(bottle.BaseResponse, 'ignored')] rollbar.init(*args, **kwargs)
def test_fortune_collection(self): email = os.environ.get("email") password = os.environ.get("password") token = os.environ.get("rollbar") self.assert_true(email and password and token) try: rollbar.init(token) self.open("http://renren.com") self.wait_for_element("email", by=By.ID) self.wait_for_element("password", by=By.ID) self.type("email", email, by=By.ID) self.type("password", password, by=By.ID) self.click("login", by=By.ID) self.wait_for_element("assembleBtn", by=By.ID) self.click("assembleBtn", by=By.ID) # self.wait_for_element("forPopupBox", by=By.ID) self.assert_element_visible("forPopupBox", by=By.ID) except: rollbar.report_message("Test Erred") self.assert_true(False) else: rollbar.report_message("Test Passed")
def __s3_upload__(self): """ upload the file to s3 see http://boto.cloudhackers.com/en/latest/s3_tut.html :return: """ # s3 = boto3.resource('s3') s3,_ = self.__s3_connect__() aws_tar = self.__get_aws_tar_name__() b = s3.get_bucket('zooniverse-static') key_str = "panoptes-uploads.zooniverse.org/production/project_aggregations_export/"+aws_tar s3_key = Key(b) s3_key.key = key_str if not os.path.exists("/tmp/"+aws_tar): print("warning the tar file does not exist - creating an temporary one.") 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_message('the tar file does not exist', 'warning') with open("/tmp/"+aws_tar,"w") as f: f.write("") s3_key.set_contents_from_filename("/tmp/"+aws_tar)
def set_up_rollbar(): class CustomRequest(Request): @property def rollbar_person(self): if g.user: user = g.user return { 'id': user.id, 'username': user.get_username(), 'email': user.email } rollbar.init( app.config['ROLLBAR_ACCESS_TOKEN'], app.config['ROLLBAR_ENVIRONMENT'], root=app.config['ROLLBAR_ROOT'], handler='blocking', allow_logging_basic_config=False, timeout=5 ) got_request_exception.connect(report_exception, app) app.request_class = CustomRequest
def _init_rollbar(): global _ROLLBAR_IS_INIT token = (_ROLLBAR_TOKENS['prod'] if not is_development() else _ROLLBAR_TOKENS['dev']) rollbar.init(token) _ROLLBAR_IS_INIT = True
def setup_rollbar(): if ROLLBAR_ACCESS_TOKEN: rollbar.init(ROLLBAR_ACCESS_TOKEN, BRICKY_ENV, root=os.path.dirname(os.path.realpath(__file__)), allow_logging_basic_config=False) got_request_exception.connect(rollbar.contrib.flask.report_exception, app)
def init_rollbar(): rollbar.init( ROLLBAR_KEY, ROLLBAR_APP, root=os.path.dirname(os.path.realpath(__file__)), allow_logging_basic_config=False) got_request_exception.connect(rollbar.contrib.flask.report_exception, app) rollbar.report_message('App booted', 'warning')
def _init_rollbar(): api_key = config.ROLLBAR_API_KEY if not api_key: print('Rollbar is not configured') return False rollbar.init(api_key) return True
def init_rollbar(): """This app allows us to track errors in the Flask environment.""" rollbar.init( "4696f6afdcbc41399fd694550535b780", "development", root=os.path.dirname(os.path.realpath(__file__)), allow_logging_basic_config=False)
def main(): rollbar.init('ACCESS_TOKEN', environment='test', handler='twisted') """This runs the protocol on port 8000""" factory = protocol.ServerFactory() factory.protocol = Echo reactor.listenTCP(8000,factory) reactor.run()
def init_rollbar(): """init rollbar module""" rollbar.init('6b773c84e86041798a513ba8ef73bb74', 'petchat-flask', root=os.path.dirname(os.path.realpath(__file__)), allow_logging_basic_config=False) got_request_exception.connect(rollbar.contrib.flask.report_exception, app)
def rollbar_init(environment): rollbar.init( access_token=ROLLBAR_POST_ACCESS_TOKEN, environment=environment, code_version=get_git_sha(), # optional ) rollbar.report_message( f'Rollbar is configured correctly for {environment}')
def init_rollbar(app): from flask import got_request_exception rollbar.init(TOKEN, 'flasktest', root=os.path.dirname(os.path.realpath(__file__)), allow_logging_basic_config=True, capture_email=True, capture_username=True) got_request_exception.connect(rollbar.contrib.flask.report_exception, app)
def __enter__(self): if self.environment != "development": panoptes_file = open("/app/config/aggregation.yml","rb") api_details = yaml.load(panoptes_file) self.rollbar_token = api_details[self.environment]["rollbar"] rollbar.init(self.rollbar_token,self.environment) return self
def init_rollbar(): rollbar.init( cfg["rollbar"]["token"], cfg["rollbar"]["environment"], root=os.path.dirname(os.path.realpath(__file__)), allow_logging_basic_config=False ) got_request_exception.connect(rollbar.contrib.flask.report_exception, app)
def test_scrub_webob_request_data(self): rollbar._initialized = False rollbar.init(_test_access_token, locals={'enabled': True}, dummy_key='asdf', handler='blocking', timeout=12345, scrub_fields=rollbar.SETTINGS['scrub_fields'] + ['token', 'secret', 'cookies', 'authorization']) import webob request = webob.Request.blank( '/the/path?q=hello&password=hunter2', base_url='http://example.com', headers={ 'X-Real-Ip': '5.6.7.8', 'Cookies': 'name=value; password=hash;', 'Authorization': 'I am from NSA' }, POST='foo=bar&confirm_password=hunter3&token=secret') unscrubbed = rollbar._build_webob_request_data(request) self.assertEqual( unscrubbed['url'], 'http://example.com/the/path?q=hello&password=hunter2') self.assertEqual(unscrubbed['user_ip'], '5.6.7.8') self.assertDictEqual(unscrubbed['GET'], { 'q': 'hello', 'password': '******' }) self.assertDictEqual(unscrubbed['POST'], { 'foo': 'bar', 'confirm_password': '******', 'token': 'secret' }) self.assertEqual('5.6.7.8', unscrubbed['headers']['X-Real-Ip']) self.assertEqual('name=value; password=hash;', unscrubbed['headers']['Cookies']) self.assertEqual('I am from NSA', unscrubbed['headers']['Authorization']) scrubbed = rollbar._transform(unscrubbed) self.assertRegex( scrubbed['url'], r'http://example.com/the/path\?(q=hello&password=-+)|(password=-+&q=hello)' ) self.assertEqual(scrubbed['GET']['q'], 'hello') self.assertRegex(scrubbed['GET']['password'], r'\*+') self.assertEqual(scrubbed['POST']['foo'], 'bar') self.assertRegex(scrubbed['POST']['confirm_password'], r'\*+') self.assertRegex(scrubbed['POST']['token'], r'\*+') self.assertEqual('5.6.7.8', scrubbed['headers']['X-Real-Ip']) self.assertRegex(scrubbed['headers']['Cookies'], r'\*+') self.assertRegex(scrubbed['headers']['Authorization'], r'\*+')
def main(): """ Set up the context and connectors """ try: init() except custom_exceptions.NotConfigured: configure() init() # Adding this in case users are trying to run without adding a jira url. # I would like to take this out in a release or two. # TODO: REMOVE except (AttributeError, ConfigParser.NoOptionError): logging.error('It appears that your configuration is invalid, please reconfigure the app and try again.') configure() init() parser = argparse.ArgumentParser() # Now simply auto-discovering the methods listed in this module current_module = sys.modules[__name__] module_methods = [getattr(current_module, a, None) for a in dir(current_module) if isinstance(getattr(current_module, a, None), types.FunctionType) and a != 'main'] argh.add_commands(parser, module_methods) # Putting the error logging after the app is initialized because # we want to adhere to the user's preferences try: argh.dispatch(parser) # We don't want to report keyboard interrupts to rollbar except (KeyboardInterrupt, SystemExit): raise except Exception as e: if isinstance(e, jira.exceptions.JIRAError) and "HTTP 400" in e: logging.warning('It appears that your authentication with {0} is invalid. Please re-configure jtime: `jtime configure` with the correct credentials'.format(configuration.load_config['jira'].get('url'))) elif configured.get('jira').get('error_reporting', True): # Configure rollbar so that we report errors import rollbar from . import __version__ as version root_path = os.path.dirname(os.path.realpath(__file__)) rollbar.init('7541b8e188044831b6728fa8475eab9f', 'v%s' % version, root=root_path) logging.error('Sorry. It appears that there was an error when handling your command. ' 'This error has been reported to our error tracking system. To disable ' 'this reporting, please re-configure the app: `jtime config`.') extra_data = { # grab the command that we're running 'cmd': sys.argv[1], # we really don't want to see jtime in the args 'args': sys.argv[2:], # lets grab anything useful, python version? 'python': str(sys.version), } # We really shouldn't thit this line of code when running tests, so let's not cover it. rollbar.report_exc_info(extra_data=extra_data) # pragma: no cover else: logging.error('It appears that there was an error when handling your command.') raise
def register_rollbar(app): rollbar.init( access_token=app.config['ROLLBAR_ACCESS_TOKEN'], environment=app.config['ROLLBAR_ENV_NAME'], root=os.path.dirname(os.path.realpath(__file__)), allow_logging_basic_config=False, ) got_request_exception.connect(rollbar.contrib.flask.report_exception, app)
def init_rollbar(): """init rollbar module""" rollbar.init( 'c6393fb20bf5493bbd0cc0d667ccc863', 'local', root=os.path.dirname(os.path.realpath(__file__)), allow_logging_basic_config=False) got_request_exception.connect(rollbar.contrib.flask.report_exception, app)
def setup_rollbar(): """ Setup Rollbar uncaught exception handling. The Django application is automatically setup via Rollbar's middleware, but worker processes need to explicitly setup rollbar. """ import rollbar import os rollbar.init(os.environ.get('ROLLBAR_ACCESS_TOKEN', ''), 'development' if settings.DEBUG else 'production')
def init_rollbar(): if ROLLBAR_ACCESS_TOKEN: print("Initializing Rollbar.") rollbar.init( access_token=ROLLBAR_ACCESS_TOKEN, environment="production", root=str(MY_DIR), handler="blocking", )
def init_rollbar(self, app): rollbar.init( app.config['ROLLBAR_TOKEN'], app.config['FLASK_ENV'], root=os.path.dirname(os.path.realpath(__file__)), allow_logging_basic_config=False) got_request_exception.connect( rollbar.contrib.flask.report_exception, app)
def __exit__(self, exc_type, exc_value, traceback): # if another instance is already running - don't do anything, just exit # if no error happened - update the timestamp # else - the next run will start at the old time stamp (which we want) if self.rollbar_token is not None: rollbar.init(self.rollbar_token,"production") if exc_type is None: rollbar.report_message("csv output worked corrected","info") else: rollbar.report_exc_info()
def test_(): rollbar.init(os.environ.get('rollbar')) email = os.environ.get('email') password = os.environ.get('password') assert email and password wait_time = int(os.environ.get('wait', default_wait)) try: options = webdriver.ChromeOptions() options.add_argument('--headless') driver = webdriver.Chrome(chrome_options=options) driver.get(renren) input_email = WebDriverWait(driver, wait_time).until( EC.presence_of_element_located((By.ID, 'email')) ) input_password = WebDriverWait(driver, wait_time).until( EC.presence_of_element_located((By.ID, 'password')) ) btn_login = WebDriverWait(driver, wait_time).until( EC.presence_of_element_located((By.ID, 'login')) ) input_email.clear() input_password.clear() input_email.send_keys(email) input_password.send_keys(password) driver.execute_script('arguments[0].click()', btn_login) btn_fortune = WebDriverWait(driver, wait_time).until( EC.presence_of_element_located((By.ID, 'assembleBtn')) ) driver.execute_script('arguments[0].click()', btn_fortune) popup = WebDriverWait(driver, wait_time).until( EC.visibility_of_element_located((By.ID, 'forPopupBox')) ) passed = popup.value_of_css_property('display') == 'block' if not passed: rollbar.report_message('Test Failed') assert passed except WebDriverException: rollbar.report_message('Test Errored') assert False else: rollbar.report_message('Test Passed') assert True finally: driver.quit()
def rollbar_handler(job, exc_type, exc_value, traceback): try: panoptes_file = open("config/aggregation.yml","rb") except IOError: panoptes_file = open(base_directory+"/Databases/aggregation.yml","rb") api_details = yaml.load(panoptes_file) if "rollbar" in api_details["default"]: rollbar_token = api_details["default"]["rollbar"] rollbar.init(rollbar_token,"production") rollbar.report_exc_info()
def __init__(self, config): self._config = config self._min_level = self.LEVELS[self._config.min_log_level] # We need to set the handler blocking (synchronous) because # spawn a thread from plpython interpreter don't work if self._rollbar_activated(): rollbar.init(self._config.rollbar_api_key, self._config.environment, handler='blocking') if self._log_file_activated(): self._file_logger = self._setup_file_logger( self._config.log_file_path)
def init_rollbar(): token = app.config.get('ROLLBAR_ACCESS_TOKEN') if token is None: return rollbar.init( token, 'production', root=os.path.dirname(os.path.realpath(__file__)), allow_logging_basic_config=False ) got_request_exception.connect(rollbar.contrib.flask.report_exception, app)
def __init__(self, get_response=None): super(RollbarNotifierMiddleware, self).__init__(get_response) self.settings = getattr(settings, 'ROLLBAR', {}) if not self.settings.get('access_token'): raise MiddlewareNotUsed if not self._get_setting('enabled'): raise MiddlewareNotUsed self._ensure_log_handler() kw = self.settings.copy() access_token = kw.pop('access_token') environment = kw.pop('environment', 'development' if settings.DEBUG else 'production') kw.setdefault('exception_level_filters', DEFAULTS['exception_level_filters']) # ignorable_404_urls is only relevant for this middleware not as an argument to init kw.pop('ignorable_404_urls', None) rollbar.init(access_token, environment, **kw) def hook(request, data): try: # try django 1.5 method for getting url_name url_name = request.resolver_match.url_name except: # fallback to older method try: url_name = resolve(request.path_info).url_name except: url_name = None if url_name: data['context'] = url_name data['framework'] = 'django' if request and hasattr(request, 'META'): request.META['rollbar.uuid'] = data['uuid'] rollbar.BASE_DATA_HOOK = hook # monkeypatch debug module if self._get_setting('patch_debugview'): try: _patch_debugview(self._get_setting('web_base')) except Exception as e: log.error( "Rollbar - unable to monkeypatch debugview to add 'View in Rollbar' link." " To disable, set `ROLLBAR['patch_debugview'] = False` in settings.py." " Exception was: %r", e )
def init_rollbar(): rollbar.init( # access token for the demo app: https://rollbar.com/demo app.config['ROLLBAR_ACCESS_TOKEN'], # environment name 'production', # server root directory, makes tracebacks prettier root=os.path.dirname(os.path.realpath(__file__)), # flask already sets up logging allow_logging_basic_config=False) # send exceptions from `app` to rollbar, using flask's signal system. got_request_exception.connect(rollbar.contrib.flask.report_exception, app)
def init_rollbar(): if app.config['ROLLBAR_TOKEN']: rollbar.init( app.config['ROLLBAR_TOKEN'], app.config['ENVIRONMENT'], # server root directory, makes tracebacks prettier root=os.path.dirname(os.path.realpath(__file__)), # flask already sets up logger allow_logger_basic_config=False) logger.debug("Rollbar intiated") # send exceptions from `app` to rollbar, using flask's signal system. got_request_exception.connect(rollbar.contrib.flask.report_exception, app)
def init_rollbar(): """init rollbar module""" rollbar.init( # access token for the demo app: https://rollbar.com/demo core.config.config["ROLLBAR_DASHB0ARD_KEY"], # environment name core.config.config["ROLLBAR_ENV"], # server root directory, makes tracebacks prettier root=os.path.dirname(os.path.realpath(__file__)), # flask already sets up logging allow_logging_basic_config=False) # send exceptions from `app` to rollbar, using flask's signal system. got_request_exception.connect(rollbar.contrib.flask.report_exception, app)
def init_rollbar(): """init rollbar module""" rollbar.init( # access token for the demo app: https://rollbar.com/demo '4007dbacf03f426ab291c36da97da1e6', # environment name 'production', # server root directory, makes tracebacks prettier root=os.path.dirname(os.path.realpath(__file__)), # flask already sets up logging allow_logging_basic_config=False) # send exceptions from `app` to rollbar, using flask's signal system. got_request_exception.connect(rollbar.contrib.flask.report_exception, app)
def aggregate(project_id, token, href, metadata, environment): try: panoptes_file = open("/app/config/aggregation.yml","rb") api_details = yaml.load(panoptes_file) rollbar_token = api_details["default"]["rollbar"] except IOError: panoptes_file = open(base_directory+"/Databases/aggregation.yml","rb") api_details = yaml.load(panoptes_file) rollbar_token = api_details["staging"]["rollbar"] print rollbar_token rollbar.init(rollbar_token,environment) print "hello" rollbar.report_message("step5","info")
def init_rollbar(): """init rollbar module""" rollbar.init( os.environ['ROLLBAR_SERVER_TOKEN'], # environment name os.environ['ENV'], # server root directory, makes tracebacks prettier root=os.path.dirname(os.path.realpath(__file__)), # flask already sets up logging allow_logging_basic_config=False) # send exceptions from `app` to rollbar, using flask's signal system. got_request_exception.connect( rollbar.contrib.flask.report_exception, app)
def init_rollbar(): """init rollbar module""" rollbar.init( # access token for the demo app: https://rollbar.com/demo 'fc316ac1f7404dc28af26d5baed1416c', # environment name 'flasktest', # server root directory, makes tracebacks prettier root=os.path.dirname(os.path.realpath(__file__)), # flask already sets up logging allow_logging_basic_config=False) # send exceptions from `app` to rollbar, using flask's signal system. got_request_exception.connect(rollbar.contrib.flask.report_exception, app)
def includeme(config): """ Pyramid entry point """ settings = config.registry.settings config.add_tween('rollbar.contrib.pyramid.rollbar_tween_factory', under=EXCVIEW) # run patch_debugtoolbar, unless they disabled it if asbool(settings.get('rollbar.patch_debugtoolbar', True)): patch_debugtoolbar(settings) def hook(request, data): data['framework'] = 'pyramid' if request: request.environ['rollbar.uuid'] = data['uuid'] if request.matched_route: data['context'] = request.matched_route.name rollbar.BASE_DATA_HOOK = hook kw = parse_settings(settings) access_token = kw.pop('access_token') environment = kw.pop('environment', 'production') if kw.get('scrub_fields'): kw['scrub_fields'] = set([str.strip(x) for x in kw.get('scrub_fields').split('\n') if x]) if kw.get('exception_level_filters'): r = DottedNameResolver() exception_level_filters = [] for line in kw.get('exception_level_filters').split('\n'): if line: dotted_path, level = line.split() try: cls = r.resolve(dotted_path) exception_level_filters.append((cls, level)) except ImportError: log.error('Could not import %r' % dotted_path) kw['exception_level_filters'] = exception_level_filters kw['enabled'] = asbool(kw.get('enabled', True)) rollbar.init(access_token, environment, **kw)