本文整理汇总了Python中mongoctl.mongoctl_logging.log_exception函数的典型用法代码示例。如果您正苦于以下问题:Python log_exception函数的具体用法?Python log_exception怎么用?Python log_exception使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了log_exception函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: is_online
def is_online(self):
try:
self.new_db_connection()
return True
except Exception, e:
log_exception(e)
return False
示例2: is_online
def is_online(self):
try:
ping(self.get_mongo_client())
return True
except (OperationFailure, AutoReconnect), ofe:
log_exception(ofe)
return "refused" not in str(ofe)
示例3: is_local
def is_local(self):
try:
server_host = self.get_host_address()
return server_host is None or is_host_local(server_host)
except Exception, e:
log_exception(e)
log_error("Unable to resolve address '%s' for server '%s'."
" Cause: %s" %
(self.get_host_address(), self.id, e))
示例4: get_rs_status
def get_rs_status(self):
try:
rs_status_cmd = SON([('replSetGetStatus', 1)])
rs_status = self.db_command(rs_status_cmd, 'admin')
return rs_status
except (Exception,RuntimeError), e:
log_debug("Cannot get rs status from server '%s'. cause: %s" %
(self.id, e))
log_exception(e)
return None
示例5: is_online
def is_online(self):
log_debug("(BEGIN) is_online() for %s" % self.id)
start_date = datetime.datetime.now()
result = False
try:
self.new_default_mongo_client()
result = True
except (OperationFailure, AutoReconnect), ofe:
log_exception(ofe)
result = "refused" not in str(ofe)
示例6: get_rs_config
def get_rs_config(self):
try:
return self.get_db("local")["system.replset"].find_one()
except (Exception, RuntimeError), e:
log_exception(e)
if type(e) == MongoctlException:
raise e
else:
log_verbose("Cannot get rs config from server '%s'. " "cause: %s" % (self.id, e))
return None
示例7: has_connectivity_on
def has_connectivity_on(self, address):
try:
log_verbose("Checking if server '%s' is accessible on " "address '%s'" % (self.id, address))
self.make_db_connection(address)
return True
except Exception, e:
log_exception(e)
log_verbose("Check failed for server '%s' is accessible on " "address '%s': %s" % (self.id, address, e))
return False
示例8: make_db_connection
def make_db_connection(address):
try:
return Connection(address,
socketTimeoutMS=CONN_TIMEOUT,
connectTimeoutMS=CONN_TIMEOUT)
except Exception, e:
log_exception(e)
error_msg = "Cannot connect to '%s'. Cause: %s" % \
(address, e)
raise MongoctlException(error_msg, cause=e)
示例9: prefer_use_ssl
def prefer_use_ssl(self):
if self.get_client_ssl_mode() != ClientSslMode.PREFER:
return False
log_debug("prefer_use_ssl() Checking if we prefer ssl for '%s'" %
self.id)
try:
self.new_ssl_test_mongo_client()
return True
except (OperationFailure, AutoReconnect), ofe:
log_exception(ofe)
return True
示例10: timeout_maybe_db_command
def timeout_maybe_db_command(self, cmd, dbname):
try:
result = self.db_command(cmd, dbname)
return result
except Exception, e:
log_exception(e)
if "timed out" in str(e):
log_warning("Command %s is taking a while to complete. "
"This is not necessarily bad. " %
document_pretty_string(cmd))
else:
raise
示例11: prefer_use_ssl
def prefer_use_ssl(self):
if self.get_client_ssl_mode() != ClientSslMode.PREFER:
return False
log_debug("prefer_use_ssl() Checking if we prefer ssl for '%s'" %
self.id)
try:
ping(self.new_mongo_client(ssl=True, **DEFAULT_CLIENT_OPTIONS))
return True
except (OperationFailure, AutoReconnect), ofe:
log_exception(ofe)
return True
示例12: prefer_use_ssl
def prefer_use_ssl(self):
if self.get_client_ssl_mode() != ClientSslMode.PREFER:
return False
log_debug("prefer_use_ssl() Checking if we prefer ssl for '%s'" % self.id)
try:
self.make_ssl_db_connection(self.get_connection_address())
return True
except Exception, e:
if not "SSL handshake failed" in str(e):
log_exception(e)
return None
示例13: has_connectivity_on
def has_connectivity_on(self, address):
try:
log_verbose("Checking if server '%s' is accessible on "
"address '%s'" % (self.id, address))
ping(pymongo.MongoClient(address, **DEFAULT_CLIENT_OPTIONS))
return True
except Exception, e:
log_exception(e)
log_verbose("Check failed for server '%s' is accessible on "
"address '%s': %s" % (self.id, address, e))
return False
示例14: get_replication_info
def get_replication_info(self):
try:
ol = self.get_db("local")["oplog.rs"]
first_op = ol.find(sort=[("$natural", 1)], limit=1).next()
last_op = ol.find(sort=[("$natural", -1)], limit=1).next()
first_ts = first_op["ts"]
last_ts = last_op["ts"]
return {
"timeDiff": last_ts.time - first_ts.time,
"timeDiffHours": (last_ts.time - first_ts.time) / 3600
}
except Exception, ex:
log_exception("Error during get_replication_info()")
示例15: get_member_rs_status
def get_member_rs_status(self):
rs_status = self.get_rs_status()
if rs_status:
try:
for member in rs_status['members']:
if 'self' in member and member['self']:
return member
except (Exception,RuntimeError), e:
log_debug("Cannot get member rs status from server '%s'."
" cause: %s" % (self.id, e))
log_exception(e)
return None