Example #1
0
    def test_log_dir_not_created_if_exists(mock_makedirs, mocked_path_exists):
        logging_util.LOGGING_DIRECTORY = tempfile.gettempdir()
        mocked_path_exists.return_value = True

        logging_util.setup_logger()

        assert not mock_makedirs.called, 'makedirs called when path existed'
Example #2
0
    def test_log_dir_created(mock_makedirs, mocked_path_exists):
        logging_util.LOGGING_DIRECTORY = tempfile.gettempdir()
        mocked_path_exists.return_value = False

        logging_util.setup_logger()

        mock_makedirs.assert_called_once_with(
            os.path.expanduser(tempfile.gettempdir()))
Example #3
0
from dlpx.virtualization._internal import (click_util, exceptions,
                                           logging_util, package_util,
                                           util_classes)
from dlpx.virtualization._internal.commands import build as build_internal
from dlpx.virtualization._internal.commands import \
    download_logs as download_logs_internal
from dlpx.virtualization._internal.commands import initialize as init_internal
from dlpx.virtualization._internal.commands import upload as upload_internal

#
# Setup the logger and file handler. This needs to be done immediately as
# logging will not work as expected until this has been done. Other classes
# have module level loggers that are initialized on the import, not when a
# function is called.
#
logging_util.setup_logger()
logger = logging.getLogger(__name__)

__version__ = package_util.get_version()

# This is needed to add -h as an option for the help menu.
CONTEXT_SETTINGS = dict(help_option_names=['-h', '--help'],
                        obj=click_util.ConfigFileProcessor.read_config())

DVP_CONFIG_MAP = CONTEXT_SETTINGS['obj']


@contextmanager
def command_error_handler():
    try:
        yield