• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python mongoctl_logging.log_exception函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中mongoctl.mongoctl_logging.log_exception函数的典型用法代码示例。如果您正苦于以下问题:Python log_exception函数的具体用法?Python log_exception怎么用?Python log_exception使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了log_exception函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: is_online

 def is_online(self):
     try:
         self.new_db_connection()
         return True
     except Exception, e:
         log_exception(e)
         return False
开发者ID:macroeyes,项目名称:mongoctl,代码行数:7,代码来源:server.py


示例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)
开发者ID:unitive-inc,项目名称:mongoctl,代码行数:7,代码来源:server.py


示例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))
开发者ID:macroeyes,项目名称:mongoctl,代码行数:9,代码来源:server.py


示例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
开发者ID:Mat-Loz,项目名称:mongoctl,代码行数:10,代码来源:mongod.py


示例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)
开发者ID:mongolab,项目名称:mongoctl,代码行数:10,代码来源:server.py


示例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
开发者ID:hongchoi,项目名称:mongoctl,代码行数:10,代码来源:server.py


示例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
开发者ID:hongchoi,项目名称:mongoctl,代码行数:10,代码来源:server.py


示例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)
开发者ID:richardxx,项目名称:mongoctl-service,代码行数:11,代码来源:server.py


示例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
开发者ID:mongolab,项目名称:mongoctl,代码行数:12,代码来源:server.py


示例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
开发者ID:macroeyes,项目名称:mongoctl,代码行数:12,代码来源:server.py


示例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
开发者ID:unitive-inc,项目名称:mongoctl,代码行数:12,代码来源:server.py


示例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
开发者ID:hongchoi,项目名称:mongoctl,代码行数:12,代码来源:server.py


示例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
开发者ID:unitive-inc,项目名称:mongoctl,代码行数:12,代码来源:server.py


示例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()")
开发者ID:mongolab,项目名称:mongoctl,代码行数:13,代码来源:mongod.py


示例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
开发者ID:Mat-Loz,项目名称:mongoctl,代码行数:13,代码来源:mongod.py


示例16: get_rs_config

 def get_rs_config(self):
     try:
         return self.get_db('local')['system.replset'].find_one()
     except (Exception,RuntimeError), e:
         log_debug("Error whille trying to read rs config from "
                   "server '%s': %s" % (self.id, 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
开发者ID:Mat-Loz,项目名称:mongoctl,代码行数:13,代码来源:mongod.py


示例17: push_mongodb

def push_mongodb(repo_name, mongodb_version, mongodb_edition=None,
                 access_key=None, secret_key=None):
    """

    :param repo_name:
    :param mongodb_version:
    :param mongodb_edition:
    :return:
    """
    mongodb_edition = mongodb_edition or MongoDBEdition.COMMUNITY
    repo = get_binary_repository(repo_name)

    if access_key and isinstance(repo, S3MongoDBBinaryRepository):
        repo.access_key = access_key
        repo.secret_key = secret_key
        repo.validate()

    version_info = make_version_info(mongodb_version, mongodb_edition)
    mongodb_install_dir = get_mongo_installation(version_info)


    if not mongodb_install_dir:
        raise MongoctlException("No mongodb installation found for '%s'" %
                                version_info)

    mongodb_install_home = os.path.dirname(mongodb_install_dir)
    target_archive_name = repo.get_archive_name(mongodb_version,
                                                mongodb_edition)

    target_archive_path = os.path.join(mongodb_install_home,
                                       target_archive_name)

    mongodb_install_dir_name = os.path.basename(mongodb_install_dir)
    log_info("Taring MongoDB at '%s'" % mongodb_install_dir_name)

    tar_exe = which("tar")
    tar_cmd = [tar_exe, "-cvzf", target_archive_name, mongodb_install_dir_name]
    call_command(tar_cmd, cwd=mongodb_install_home)

    log_info("Uploading tar to repo")

    repo.upload_file(mongodb_version, mongodb_edition, target_archive_path)

    # cleanup
    log_info("Cleanup")
    try:
        os.remove(target_archive_path)
    except Exception, e:
        log_error(str(e))
        log_exception(e)
开发者ID:zenglzh,项目名称:mongoctl,代码行数:50,代码来源:push_to_repo.py


示例18: needs_to_auth

 def needs_to_auth(self, dbname):
     """
     Determines if the server needs to authenticate to the database.
     NOTE: we stopped depending on is_auth() since its only a configuration
     and may not be accurate
     """
     log_debug("Checking if server '%s' needs to auth on  db '%s'...." % (self.id, dbname))
     try:
         conn = self.new_db_connection()
         db = conn[dbname]
         db.collection_names()
         result = False
     except (RuntimeError, Exception), e:
         log_exception(e)
         result = "authorized" in str(e)
开发者ID:hongchoi,项目名称:mongoctl,代码行数:15,代码来源:server.py


示例19: get_server_build_info

 def get_server_build_info(self):
     """
     issues a buildinfo command
     """
     if self.is_online():
         try:
             return self.get_mongo_client().server_info()
         except OperationFailure, ofe:
             log_exception(ofe)
             if "there are no users authenticated" in str(ofe):
                 # this is a pymongo 3.6.1 regression where the buildinfo command fails on non authenticated client
                 # fall-back to an authenticated client
                 admin_db = self.get_db("admin", no_auth=False)
                 return admin_db.command("buildinfo")
         except Exception, e:
             log_exception(e)
开发者ID:mongolab,项目名称:mongoctl,代码行数:16,代码来源:server.py


示例20: needs_to_auth

 def needs_to_auth(self, dbname):
     """
     Determines if the server needs to authenticate to the database.
     NOTE: we stopped depending on is_auth() since its only a configuration
     and may not be accurate
     """
     log_debug("Checking if server '%s' needs to auth on  db '%s'...." %
               (self.id, dbname))
     try:
         client = self.get_mongo_client()
         db = client.get_database(dbname)
         db.collection_names()
         result = False
     except (RuntimeError,Exception), e:
         log_exception(e)
         # updated for to handle auth failures from mongodb 3.6
         result = "authorized" in str(e) or "there are no users authenticated" in str(e)
开发者ID:mongolab,项目名称:mongoctl,代码行数:17,代码来源:server.py



注:本文中的mongoctl.mongoctl_logging.log_exception函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python mongoctl_logging.log_info函数代码示例发布时间:2022-05-27
下一篇:
Python session.Session类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap