Files
zaza-openstack-tests/zaza/utilities/cli_utils.py
T
David Ames f2982a4f1f Split _local_utils into functional modules
The _local_utils module was misnamed as the utilities it contained
may be used outside of zaza proper. For example in mojo.

This change separates the utilities into functional modules:

 cli_utils: For utilities pertaining to running scripts from command line.
 juju_utils: For utilities pertaining to juju commands.
 generic_utils: For helper utilities that are generic in nature.
2018-05-14 10:49:49 -07:00

44 lines
1.1 KiB
Python

#!/usr/bin/env python3
import logging
import os
def parse_arg(options, arg, multiargs=False):
"""Parse argparse argments
:param options: Argparse options
:type options: argparse object
:param arg: Argument attribute key
:type arg: string
:param multiargs: More than one arugment or not
:type multiargs: boolean
:returns: Argparse atrribute value
:rtype: string
"""
if arg.upper() in os.environ:
if multiargs:
return os.environ[arg.upper()].split()
else:
return os.environ[arg.upper()]
else:
return getattr(options, arg)
def setup_logging():
"""Setup zaza logging
:returns: Nothing: This fucntion is executed for its sideffect
:rtype: None
"""
logFormatter = logging.Formatter(
fmt="%(asctime)s [%(levelname)s] %(message)s",
datefmt="%Y-%m-%d %H:%M:%S")
rootLogger = logging.getLogger()
rootLogger.setLevel('INFO')
consoleHandler = logging.StreamHandler()
consoleHandler.setFormatter(logFormatter)
rootLogger.addHandler(consoleHandler)