本文整理汇总了Python中raven.Client.get_ident方法的典型用法代码示例。如果您正苦于以下问题:Python Client.get_ident方法的具体用法?Python Client.get_ident怎么用?Python Client.get_ident使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类raven.Client
的用法示例。
在下文中一共展示了Client.get_ident方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run_from_argv
# 需要导入模块: from raven import Client [as 别名]
# 或者: from raven.Client import get_ident [as 别名]
def run_from_argv(self, argv):
if len(argv) <= 2 or argv[2] in ['-h', '--help']:
print self.usage(argv[1])
sys.exit(1)
subcommand_class = self._get_subcommand_class(argv[2])
parser = self.create_parser(argv[0], argv[2], subcommand_class)
if hasattr(self, 'use_argparse') and self.use_argparse:
subcommand_class.add_arguments(parser)
options = parser.parse_args(argv[3:])
cmd_options = vars(options)
args = cmd_options.pop('args', ())
else:
options, args = parser.parse_args(argv[3:])
handle_default_options(options)
try:
subcommand_class.execute(*args, **options.__dict__)
except Exception as e:
if not isinstance(e, CommandError):
if hasattr(settings, 'SENTRY_DSN'):
dsn = settings.SENTRY_DSN
elif hasattr(settings, 'RAVEN_CONFIG'):
dsn = settings.RAVEN_CONFIG.get('dsn')
else:
raise
sentry = Client(dsn)
# Force sync transport to avoid race condition with the process exiting
for url in sentry.servers:
parsed = urlparse.urlparse(url)
transport = sentry._registry.get_transport(parsed)
transport.async = False
sentry.get_ident(sentry.captureException())
self._write_error_in_stderr(e)
示例2: run_from_argv
# 需要导入模块: from raven import Client [as 别名]
# 或者: from raven.Client import get_ident [as 别名]
def run_from_argv(self, argv):
if len(argv) <= 2 or argv[2] in ['-h', '--help']:
stdout = OutputWrapper(sys.stdout)
stdout.write(self.usage(argv[1]))
sys.exit(1)
subcommand_class = self._get_subcommand_class(argv[2])
parser = self.create_parser(argv[0], argv[2], subcommand_class)
if hasattr(self, 'use_argparse') and self.use_argparse:
subcommand_class.add_arguments(parser)
options = parser.parse_args(argv[3:])
cmd_options = vars(options)
args = cmd_options.pop('args', ())
else:
options, args = parser.parse_args(argv[3:])
handle_default_options(options)
try:
subcommand_class.execute(*args, **options.__dict__)
except Exception as e:
if not isinstance(e, CommandError):
if hasattr(settings, 'SENTRY_DSN'):
dsn = settings.SENTRY_DSN
elif hasattr(settings, 'RAVEN_CONFIG'):
dsn = settings.RAVEN_CONFIG.get('dsn')
else:
raise
sentry = Client(dsn)
if not sentry.is_enabled():
raise
sentry.get_ident(sentry.captureException())
self._write_error_in_stderr(e)
示例3: SentryNotifier
# 需要导入模块: from raven import Client [as 别名]
# 或者: from raven.Client import get_ident [as 别名]
class SentryNotifier(object):
def __init__(self, **kwargs):
self.environment = kwargs.get('environment', 'production')
self.sentry_client = Client(**kwargs)
def __call__(self, e):
if not self.environment == 'test':
self.sentry_client.get_ident(self.sentry_client.captureException())
else:
print 'Would send [%s] to sentry.' % e
示例4: main
# 需要导入模块: from raven import Client [as 别名]
# 或者: from raven.Client import get_ident [as 别名]
def main():
if SENTRY_DSN:
client = Client(dsn=SENTRY_DSN)
while True:
try:
start_worker(sys.argv)
except Exception:
client.get_ident(client.captureException())
else:
while True:
try:
start_worker(sys.argv)
except InsightWorkerException:
traceback.print_exc()
示例5: main
# 需要导入模块: from raven import Client [as 别名]
# 或者: from raven.Client import get_ident [as 别名]
def main():
if SENTRY_DSN:
client = Client(dsn=SENTRY_DSN)
else:
client = None
print "Launch tornado ioloop"
application.listen(8888)
try:
ioloop.IOLoop.instance().start()
except Exception:
if client:
client.get_ident(client.captureException())
else:
raise
示例6: main
# 需要导入模块: from raven import Client [as 别名]
# 或者: from raven.Client import get_ident [as 别名]
def main():
root = logging.getLogger('sentry.errors')
root.setLevel(logging.DEBUG)
root.addHandler(logging.StreamHandler())
dsn = ' '.join(sys.argv[2:])
if not (dsn or os.environ.get('SENTRY_DSN')):
print "Error: No configuration detected!"
print "You must either pass a DSN to the command, or set the SENTRY_DSN environment variable."
sys.exit(1)
print "Using DSN configuration:"
print " ", dsn
print
client = Client(dsn)
print "Client configuration:"
for k in ('servers', 'project', 'public_key', 'secret_key'):
print ' %-15s: %s' % (k, getattr(client, k))
print
if not all([client.servers, client.project, client.public_key, client.secret_key]):
print "Error: All values must be set!"
sys.exit(1)
print 'Sending a test message...',
ident = client.get_ident(client.captureMessage('This is a test message generated using ``raven test``'))
print 'success!'
print
print 'The test message can be viewed at the following URL:'
url = client.servers[0].split('/api/store/', 1)[0]
print ' %s/%s/search/?q=%s' % (url, client.project, ident)
示例7: main
# 需要导入模块: from raven import Client [as 别名]
# 或者: from raven.Client import get_ident [as 别名]
def main():
root = logging.getLogger('sentry.errors')
root.setLevel(logging.DEBUG)
root.addHandler(logging.StreamHandler())
parser = OptionParser()
parser.add_option("--data", action="callback", callback=store_json,
type="string", nargs=1, dest="data")
(opts, args) = parser.parse_args()
dsn = ' '.join(args[1:]) or os.environ.get('SENTRY_DSN')
if not dsn:
print "Error: No configuration detected!"
print "You must either pass a DSN to the command, or set the SENTRY_DSN environment variable."
sys.exit(1)
print "Using DSN configuration:"
print " ", dsn
print
client = Client(dsn, include_paths=['raven'])
print "Client configuration:"
for k in ('servers', 'project', 'public_key', 'secret_key'):
print ' %-15s: %s' % (k, getattr(client, k))
print
if not all([client.servers, client.project, client.public_key, client.secret_key]):
print "Error: All values must be set!"
sys.exit(1)
print 'Sending a test message...',
ident = client.get_ident(client.captureMessage(
message='This is a test message generated using ``raven test``',
data=opts.data or {
'culprit': 'raven.scripts.runner',
'logger': 'raven.test',
'sentry.interfaces.Http': {
'method': 'GET',
'url': 'http://example.com',
}
},
level=logging.INFO,
stack=True,
extra={
'user': pwd.getpwuid(os.geteuid())[0],
'loadavg': os.getloadavg(),
}
))
if client.state.did_fail():
print 'error!'
return False
print 'success!'
print
print 'The test message can be viewed at the following URL:'
url = client.servers[0].split('/api/store/', 1)[0]
print ' %s/%s/search/?q=%s' % (url, client.project, ident)
示例8: main
# 需要导入模块: from raven import Client [as 别名]
# 或者: from raven.Client import get_ident [as 别名]
def main():
root = logging.getLogger("sentry.errors")
root.setLevel(logging.DEBUG)
root.addHandler(logging.StreamHandler())
parser = OptionParser()
parser.add_option("--data", action="callback", callback=store_json, type="string", nargs=1, dest="data")
(opts, args) = parser.parse_args()
dsn = " ".join(args[1:]) or os.environ.get("SENTRY_DSN")
if not dsn:
print("Error: No configuration detected!")
print("You must either pass a DSN to the command, or set the SENTRY_DSN environment variable.")
sys.exit(1)
print("Using DSN configuration:")
print(" ", dsn)
print()
client = Client(dsn, include_paths=["raven"])
print("Client configuration:")
for k in ("servers", "project", "public_key", "secret_key"):
print(" %-15s: %s" % (k, getattr(client, k)))
print()
if not all([client.servers, client.project, client.public_key, client.secret_key]):
print("Error: All values must be set!")
sys.exit(1)
print("Sending a test message...", end=" ")
ident = client.get_ident(
client.captureMessage(
message="This is a test message generated using ``raven test``",
data=opts.data
or {
"culprit": "raven.scripts.runner",
"logger": "raven.test",
"sentry.interfaces.Http": {"method": "GET", "url": "http://example.com"},
},
level=logging.INFO,
stack=True,
extra={"user": pwd.getpwuid(os.geteuid())[0], "loadavg": os.getloadavg()},
)
)
if client.state.did_fail():
print("error!")
return False
print("success!")
print()
print("The test message can be viewed at the following URL:")
url = client.servers[0].split("/api/store/", 1)[0]
print(" %s/%s/search/?q=%s" % (url, client.project, ident))
示例9: run_from_argv
# 需要导入模块: from raven import Client [as 别名]
# 或者: from raven.Client import get_ident [as 别名]
def run_from_argv(self, argv):
if len(argv) <= 2 or argv[2] in ['-h', '--help']:
print self.usage(argv[1])
sys.exit(1)
subcommand_class = self._get_subcommand_class(argv[2])
parser = self.create_parser(argv[0], argv[2], subcommand_class)
options, args = parser.parse_args(argv[3:])
handle_default_options(options)
try:
subcommand_class.execute(*args, **options.__dict__)
except Exception as e:
if not isinstance(e, CommandError):
if hasattr(settings, 'SENTRY_DSN'):
dsn = settings.SENTRY_DSN
elif hasattr(settings, 'RAVEN_CONFIG'):
dsn = settings.RAVEN_CONFIG.get('dsn')
else:
raise
sentry = Client(dsn)
sentry.get_ident(sentry.captureException())
self._write_error_in_stderr(e)
示例10: invoke
# 需要导入模块: from raven import Client [as 别名]
# 或者: from raven.Client import get_ident [as 别名]
def invoke(self, ctx): # noqa
# setup logging
if "verbose" in ctx.params and ctx.params["verbose"]:
level = max(10, 40 - ctx.params["verbose"] * 10)
set_log_level(level)
verbosity(ctx.params["verbose"])
if "log_file" in ctx.params and ctx.params["log_file"]:
set_log_file(ctx.params["log_file"])
# try running the command
try:
super(AerisCLI, self).invoke(ctx)
except SystemExit:
raise
except click.UsageError as e:
click.secho("error: %s" % e.message, err=True, fg="red")
click.echo(e.ctx.command.get_help(e.ctx), err=True)
sys.exit(e.exit_code)
except (ExposeTimeout, ExposeConnectionError):
warning("warning: expose is not available at the moment")
except KeyboardInterrupt:
logger.error(
'keyboard interrupt while running subcommand "%s"', ctx.invoked_subcommand, exc_info=sys.exc_info()
)
warning("\nwarning: ctrl+c pressed, aborting")
except:
log_id = None
if config.has("config", "raven"):
from raven import Client
client = Client("requests+" + config.get("config", "raven"))
log_id = client.get_ident(
client.captureException(
tags={"python": sys.version, "aeriscloud": ac_version, "platform": sys.platform},
extra={"user": os.environ["USER"]},
)
)
logger.error(
'uncaught exception while running subcommand "%s"', ctx.invoked_subcommand, exc_info=sys.exc_info()
)
if log_id:
fatal(
'error: an internal exception caused "%s" '
"to exit unexpectedly (log id: %s)" % (ctx.info_name, log_id)
)
else:
fatal('error: an internal exception caused "%s" ' "to exit unexpectedly" % ctx.info_name)
示例11: main
# 需要导入模块: from raven import Client [as 别名]
# 或者: from raven.Client import get_ident [as 别名]
def main():
root = logging.getLogger('sentry.errors')
root.setLevel(logging.DEBUG)
root.addHandler(logging.StreamHandler())
dsn = ' '.join(sys.argv[2:])
if not (dsn or os.environ.get('SENTRY_DSN')):
print "Error: No configuration detected!"
print "You must either pass a DSN to the command, or set the SENTRY_DSN environment variable."
sys.exit(1)
print "Using DSN configuration:"
print " ", dsn
print
client = Client(dsn, include_paths=['raven'])
print "Client configuration:"
for k in ('servers', 'project', 'public_key', 'secret_key'):
print ' %-15s: %s' % (k, getattr(client, k))
print
if not all([client.servers, client.project, client.public_key, client.secret_key]):
print "Error: All values must be set!"
sys.exit(1)
print 'Sending a test message...',
ident = client.get_ident(client.captureMessage(
message='This is a test message generated using ``raven test``',
data={
'culprit': 'raven.scripts.runner',
'logger': 'raven.test',
'sentry.interfaces.Http': {
'method': 'GET',
'url': 'http://example.com',
}
},
stack=True,
extra={
'user': os.getlogin(),
'loadavg': os.getloadavg(),
}
))
print 'success!'
print
print 'The test message can be viewed at the following URL:'
url = client.servers[0].split('/api/store/', 1)[0]
print ' %s/%s/search/?q=%s' % (url, client.project, ident)
示例12: main
# 需要导入模块: from raven import Client [as 别名]
# 或者: from raven.Client import get_ident [as 别名]
def main():
root = logging.getLogger('sentry.errors')
root.setLevel(logging.DEBUG)
root.addHandler(logging.StreamHandler())
parser = OptionParser()
parser.add_option("--dsn", action="store", default = os.environ.get('SENTRY_DSN'))
(opts, args) = parser.parse_args()
if not opts.dsn:
print "Error: No configuration detected!"
print "You must either pass a DSN with --dsn or set the SENTRY_DSN environment variable."
sys.exit(1)
if not args:
print "Error: no files specified!"
print "You must pass at least one filename on the command line."
sys.exit(1)
client = Client(opts.dsn)
client.string_max_length = None
data = {
'culprit': 'sentry_uploads.scripts.runner',
'logger': 'sentry_uploads.test',
}
data.update({
'sentry_uploads.interfaces.Uploads': {
'files': [{
'filename': os.path.basename(path),
'data': read_encode(path),
} for path in args],
},
})
ident = client.get_ident(client.captureMessage(
message = 'Upload of %s via sentry-upload script' % str(args),
data = data,
level = logging.INFO,
))
if client.state.did_fail():
print 'error!'
return False
print 'success!'
示例13: Client
# 需要导入模块: from raven import Client [as 别名]
# 或者: from raven.Client import get_ident [as 别名]
import time
from raven import Client
client = Client(dsn="http://5030659c0a8948b8aad226cd8241e701:[email protected]:9000/1")
try:
1 / 0
except:
ident = client.get_ident(client.captureException())
print ident
time.sleep(1)
示例14: Client
# 需要导入模块: from raven import Client [as 别名]
# 或者: from raven.Client import get_ident [as 别名]
# coding=utf-8
from raven import Client
c = Client('http://39aeb386bf7842a6b92dd93ff81eb998:[email protected]:9000/2')
# 发送捕捉的消息, Exception
c.captureMessage('23333')
try:
1/0
except ZeroDivisionError:
ident = c.get_ident(c.captureException())
print "Exception caught; reference is %s" % ident