# Path: mongoctl/errors.py
# class MongoctlException(Exception):
#     def __init__(self, message, cause=None):
#         super(MongoctlException, self).__init__(message)
#         self._cause = cause


import mongoctl.repository as repository
from mongoctl.errors import MongoctlException
__author__ = 'abdul'

###############################################################################
# print uri command
###############################################################################
def print_uri_command(parsed_options):
    id = parsed_options.id
    db = parsed_options.db
    # check if the id is a server id

    server = repository.lookup_server(id)
    if server:
        print server.get_mongo_uri_template(db=db)
    else:
        cluster = repository.lookup_cluster(id)
        if cluster:
            print cluster.get_mongo_uri_template(db=db)
        else:

# Path: mongoctl/errors.py
# class MongoctlException(Exception):
#     def __init__(self, message, cause=None):
#         super(MongoctlException, self).__init__(message)
#         self._cause = cause


# Path: mongoctl/commands/misc/print_uri.py
import mongoctl.repository as repository
from mongoctl.errors import MongoctlException

__author__ = 'abdul'

###############################################################################
# print uri command
###############################################################################
def print_uri_command(parsed_options):
    id = parsed_options.id
    db = parsed_options.db
    # check if the id is a server id

    server = repository.lookup_server(id)
    if server:
        print server.get_mongo_uri_template(db=db)
    else:
        cluster = repository.lookup_cluster(id)
        if cluster:
            print cluster.get_mongo_uri_template(db=db)
        else:

            raise MongoctlException("Cannot find a server or a cluster with"