# Path: mongodb_consistent_backup/Errors.py
# class DBAuthenticationError(OperationError):
#     """Raised when a db authentication error occurs"""
#     pass
# 
# class DBConnectionError(OperationError):
#     """Raised when a db connection error occurs"""
#     pass
# 
# class DBOperationError(OperationError):
#     """Raised when a db operation error occurs"""
#     pass
# 
# class Error(Exception):
#     """Raised when something failed in an unexpected and unrecoverable way"""
#     pass


import logging
from bson.codec_options import CodecOptions
from inspect import currentframe, getframeinfo
from pymongo import ASCENDING, DESCENDING, CursorType, MongoClient
from pymongo.errors import ConfigurationError, ConnectionFailure, OperationFailure, ServerSelectionTimeoutError
from ssl import CERT_REQUIRED, CERT_NONE
from time import sleep
from mongodb_consistent_backup.Common import parse_config_bool
from mongodb_consistent_backup.Errors import DBAuthenticationError, DBConnectionError, DBOperationError, Error
                status = self._conn['admin'].command(admin_command)
            except OperationFailure, e:
                if not quiet:
                    logging.error("Error running admin command '%s': %s" % (admin_command, e))
                tries += 1
                sleep(1)
        if not status:
            raise DBOperationError("Could not get output from command: '%s' after %i retries!" % (admin_command, self.retries))
        return status

    def server_version(self):
        status = self.admin_command('serverStatus')
        try:
            if 'version' in status:
                version = status['version'].split('-')[0]
                return tuple(version.split('.'))
        except Exception, e:
            raise Error("Unable to determine version from serverStatus! Error: %s" % e)

    def connection(self):
        return self._conn

    def is_mongos(self):
        return self._conn.is_mongos

    def is_master(self, force=False):
        try:
            if force or not self._is_master:
                self._is_master = self.admin_command('isMaster', True)
        except OperationFailure, e:

# Path: mongodb_consistent_backup/Errors.py
# class DBAuthenticationError(OperationError):
#     """Raised when a db authentication error occurs"""
#     pass
# 
# class DBConnectionError(OperationError):
#     """Raised when a db connection error occurs"""
#     pass
# 
# class DBOperationError(OperationError):
#     """Raised when a db operation error occurs"""
#     pass
# 
# class Error(Exception):
#     """Raised when something failed in an unexpected and unrecoverable way"""
#     pass


# Path: mongodb_consistent_backup/Common/DB.py
import logging
from bson.codec_options import CodecOptions
from inspect import currentframe, getframeinfo
from pymongo import ASCENDING, DESCENDING, CursorType, MongoClient
from pymongo.errors import ConfigurationError, ConnectionFailure, OperationFailure, ServerSelectionTimeoutError
from ssl import CERT_REQUIRED, CERT_NONE
from time import sleep
from mongodb_consistent_backup.Common import parse_config_bool
from mongodb_consistent_backup.Errors import DBAuthenticationError, DBConnectionError, DBOperationError, Error

                status = self._conn['admin'].command(admin_command)
            except OperationFailure, e:
                if not quiet:
                    logging.error("Error running admin command '%s': %s" % (admin_command, e))
                tries += 1
                sleep(1)
        if not status:
            raise DBOperationError("Could not get output from command: '%s' after %i retries!" % (admin_command, self.retries))
        return status

    def server_version(self):
        status = self.admin_command('serverStatus')
        try:
            if 'version' in status:
                version = status['version'].split('-')[0]
                return tuple(version.split('.'))
        except Exception, e:
            raise Error("Unable to determine version from serverStatus! Error: %s" % e)

    def connection(self):
        return self._conn

    def is_mongos(self):
        return self._conn.is_mongos

    def is_master(self, force=False):
        try:
            if force or not self._is_master:
                self._is_master = self.admin_command('isMaster', True)
        except OperationFailure, e:

            raise DBOperationError("Unable to run isMaster command! Error: %s" % e)