mirror of https://github.com/OpenKMIP/PyKMIP.git
Merge pull request #156 from OpenKMIP/maint/remove-library-logging
Removing default log configuration and usage
This commit is contained in:
commit
9362abbce5
|
@ -13,7 +13,6 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import logging.config
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
|
@ -26,45 +25,10 @@ with open(version_path, 'r') as version_file:
|
|||
mo = re.search(r"^.*= '(\d\.\d\.\d)'$", version_file.read(), re.MULTILINE)
|
||||
__version__ = mo.group(1)
|
||||
|
||||
path = os.path.join(os.path.dirname(__file__), 'logconfig.ini')
|
||||
|
||||
if os.path.exists(path):
|
||||
logging.config.fileConfig(path)
|
||||
else:
|
||||
minor_version = sys.version_info[1]
|
||||
|
||||
if minor_version == 7:
|
||||
config = {
|
||||
'version': 1,
|
||||
'disable_existing_loggers': False,
|
||||
'formatters': {
|
||||
'simpleFormatter': {
|
||||
'format':
|
||||
'%(asctime)s - %(name)s - %(levelname)s - %(message)s'
|
||||
}
|
||||
},
|
||||
'handlers': {
|
||||
'consoleHandler': {
|
||||
'level': 'INFO',
|
||||
'class': 'logging.StreamHandler',
|
||||
'formatter': 'simpleFormatter',
|
||||
'stream': sys.stdout
|
||||
}
|
||||
},
|
||||
'loggers': {
|
||||
'root': {
|
||||
'level': 'INFO',
|
||||
'handlers': ['consoleHandler']
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
logging.config.dictConfig(config)
|
||||
else:
|
||||
logging.basicConfig()
|
||||
|
||||
__all__ = ['core', 'demos', 'services']
|
||||
|
||||
|
||||
if sys.version_info[:2] == (2, 6):
|
||||
warnings.simplefilter("always")
|
||||
warnings.warn(
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
# under the License.
|
||||
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
|
||||
from kmip.core import enums
|
||||
|
@ -24,6 +23,8 @@ from kmip.pie import client
|
|||
|
||||
|
||||
if __name__ == '__main__':
|
||||
logger = utils.build_console_logger(logging.INFO)
|
||||
|
||||
# Build and parse arguments
|
||||
parser = utils.build_cli_parser(enums.Operation.CREATE)
|
||||
opts, args = parser.parse_args(sys.argv[1:])
|
||||
|
@ -34,18 +35,12 @@ if __name__ == '__main__':
|
|||
|
||||
# Exit early if the arguments are not specified
|
||||
if algorithm is None:
|
||||
logging.debug('No algorithm provided, exiting early from demo')
|
||||
logger.error('No algorithm provided, exiting early from demo')
|
||||
sys.exit()
|
||||
if length is None:
|
||||
logging.debug("No key length provided, exiting early from demo")
|
||||
logger.error("No key length provided, exiting early from demo")
|
||||
sys.exit()
|
||||
|
||||
# Build and setup logging and needed factories
|
||||
f_log = os.path.join(os.path.dirname(__file__), os.pardir, os.pardir,
|
||||
'logconfig.ini')
|
||||
logging.config.fileConfig(f_log)
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
algorithm = getattr(enums.CryptographicAlgorithm, algorithm, None)
|
||||
|
||||
# Build the client and connect to the server
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
# under the License.
|
||||
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
|
||||
from kmip.core import enums
|
||||
|
@ -23,6 +22,8 @@ from kmip.pie import client
|
|||
|
||||
|
||||
if __name__ == '__main__':
|
||||
logger = utils.build_console_logger(logging.INFO)
|
||||
|
||||
# Build and parse arguments
|
||||
parser = utils.build_cli_parser(enums.Operation.CREATE_KEY_PAIR)
|
||||
opts, args = parser.parse_args(sys.argv[1:])
|
||||
|
@ -33,18 +34,12 @@ if __name__ == '__main__':
|
|||
|
||||
# Exit early if the arguments are not specified
|
||||
if algorithm is None:
|
||||
logging.debug('No algorithm provided, exiting early from demo')
|
||||
logger.error('No algorithm provided, exiting early from demo')
|
||||
sys.exit()
|
||||
if length is None:
|
||||
logging.debug("No key length provided, exiting early from demo")
|
||||
logger.error("No key length provided, exiting early from demo")
|
||||
sys.exit()
|
||||
|
||||
# Build and setup logging and needed factories
|
||||
f_log = os.path.join(os.path.dirname(__file__), os.pardir, os.pardir,
|
||||
'logconfig.ini')
|
||||
logging.config.fileConfig(f_log)
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
algorithm = getattr(enums.CryptographicAlgorithm, algorithm, None)
|
||||
|
||||
# Build the client and connect to the server
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
# under the License.
|
||||
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
|
||||
from kmip.core import enums
|
||||
|
@ -23,6 +22,8 @@ from kmip.pie import client
|
|||
|
||||
|
||||
if __name__ == '__main__':
|
||||
logger = utils.build_console_logger(logging.INFO)
|
||||
|
||||
# Build and parse arguments
|
||||
parser = utils.build_cli_parser(enums.Operation.DESTROY)
|
||||
opts, args = parser.parse_args(sys.argv[1:])
|
||||
|
@ -32,15 +33,9 @@ if __name__ == '__main__':
|
|||
|
||||
# Exit early if the UUID is not specified
|
||||
if uid is None:
|
||||
logging.debug('No UUID provided, exiting early from demo')
|
||||
logger.error('No UUID provided, exiting early from demo')
|
||||
sys.exit()
|
||||
|
||||
# Build and setup logging and needed factories
|
||||
f_log = os.path.join(os.path.dirname(__file__), os.pardir, os.pardir,
|
||||
'logconfig.ini')
|
||||
logging.config.fileConfig(f_log)
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
# Build the client and connect to the server
|
||||
with client.ProxyKmipClient(config=config) as client:
|
||||
try:
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
# under the License.
|
||||
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
|
||||
from kmip.core import enums
|
||||
|
@ -23,6 +22,8 @@ from kmip.pie import client
|
|||
|
||||
|
||||
if __name__ == '__main__':
|
||||
logger = utils.build_console_logger(logging.INFO)
|
||||
|
||||
# Build and parse arguments
|
||||
parser = utils.build_cli_parser(enums.Operation.GET)
|
||||
opts, args = parser.parse_args(sys.argv[1:])
|
||||
|
@ -32,15 +33,9 @@ if __name__ == '__main__':
|
|||
|
||||
# Exit early if the UUID is not specified
|
||||
if uid is None:
|
||||
logging.debug('No UUID provided, exiting early from demo')
|
||||
logger.error('No UUID provided, exiting early from demo')
|
||||
sys.exit()
|
||||
|
||||
# Build and setup logging and needed factories
|
||||
f_log = os.path.join(os.path.dirname(__file__), os.pardir, os.pardir,
|
||||
'logconfig.ini')
|
||||
logging.config.fileConfig(f_log)
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
# Build the client and connect to the server
|
||||
with client.ProxyKmipClient(config=config) as client:
|
||||
try:
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
# under the License.
|
||||
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
|
||||
from kmip.core import enums
|
||||
|
@ -23,6 +22,8 @@ from kmip.pie import client
|
|||
|
||||
|
||||
if __name__ == '__main__':
|
||||
logger = utils.build_console_logger(logging.INFO)
|
||||
|
||||
# Build and parse arguments
|
||||
parser = utils.build_cli_parser(enums.Operation.GET_ATTRIBUTE_LIST)
|
||||
opts, args = parser.parse_args(sys.argv[1:])
|
||||
|
@ -32,15 +33,9 @@ if __name__ == '__main__':
|
|||
|
||||
# Exit early if the UUID is not specified
|
||||
if uid is None:
|
||||
logging.debug('No ID provided, exiting early from demo')
|
||||
logger.error('No ID provided, exiting early from demo')
|
||||
sys.exit()
|
||||
|
||||
# Build and setup logging and needed factories
|
||||
f_log = os.path.join(os.path.dirname(__file__), os.pardir, os.pardir,
|
||||
'logconfig.ini')
|
||||
logging.config.fileConfig(f_log)
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
# Build the client and connect to the server
|
||||
with client.ProxyKmipClient(config=config) as client:
|
||||
try:
|
||||
|
|
|
@ -24,8 +24,9 @@ from kmip.pie import objects
|
|||
|
||||
|
||||
if __name__ == '__main__':
|
||||
logger = utils.build_console_logger(logging.INFO)
|
||||
|
||||
parser = utils.build_cli_parser()
|
||||
logger = logging.getLogger(__name__)
|
||||
opts, args = parser.parse_args(sys.argv[1:])
|
||||
|
||||
config = opts.config
|
||||
|
|
|
@ -24,8 +24,9 @@ from kmip.pie import objects
|
|||
|
||||
|
||||
if __name__ == '__main__':
|
||||
logger = utils.build_console_logger(logging.INFO)
|
||||
|
||||
parser = utils.build_cli_parser()
|
||||
logger = logging.getLogger(__name__)
|
||||
opts, args = parser.parse_args(sys.argv[1:])
|
||||
|
||||
config = opts.config
|
||||
|
|
|
@ -24,8 +24,9 @@ from kmip.pie import objects
|
|||
|
||||
|
||||
if __name__ == '__main__':
|
||||
logger = utils.build_console_logger(logging.INFO)
|
||||
|
||||
parser = utils.build_cli_parser()
|
||||
logger = logging.getLogger(__name__)
|
||||
opts, args = parser.parse_args(sys.argv[1:])
|
||||
|
||||
config = opts.config
|
||||
|
|
|
@ -24,8 +24,9 @@ from kmip.pie import objects
|
|||
|
||||
|
||||
if __name__ == '__main__':
|
||||
logger = utils.build_console_logger(logging.INFO)
|
||||
|
||||
parser = utils.build_cli_parser()
|
||||
logger = logging.getLogger(__name__)
|
||||
opts, args = parser.parse_args(sys.argv[1:])
|
||||
|
||||
config = opts.config
|
||||
|
|
|
@ -25,8 +25,9 @@ from kmip.pie import objects
|
|||
|
||||
|
||||
if __name__ == '__main__':
|
||||
logger = utils.build_console_logger(logging.INFO)
|
||||
|
||||
parser = utils.build_cli_parser()
|
||||
logger = logging.getLogger(__name__)
|
||||
opts, args = parser.parse_args(sys.argv[1:])
|
||||
|
||||
config = opts.config
|
||||
|
|
|
@ -24,8 +24,9 @@ from kmip.pie import objects
|
|||
|
||||
|
||||
if __name__ == '__main__':
|
||||
logger = utils.build_console_logger(logging.INFO)
|
||||
|
||||
parser = utils.build_cli_parser()
|
||||
logger = logging.getLogger(__name__)
|
||||
opts, args = parser.parse_args(sys.argv[1:])
|
||||
|
||||
config = opts.config
|
||||
|
|
|
@ -21,11 +21,12 @@ from kmip.demos import utils
|
|||
from kmip.services.kmip_client import KMIPProxy
|
||||
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
logger = utils.build_console_logger(logging.INFO)
|
||||
|
||||
# Build and parse arguments
|
||||
parser = utils.build_cli_parser(Operation.ACTIVATE)
|
||||
opts, args = parser.parse_args(sys.argv[1:])
|
||||
|
@ -35,15 +36,9 @@ if __name__ == '__main__':
|
|||
|
||||
# Exit early if the UUID is not specified
|
||||
if uuid is None:
|
||||
logging.debug('No UUID provided, exiting early from demo')
|
||||
logger.error('No UUID provided, exiting early from demo')
|
||||
sys.exit()
|
||||
|
||||
# Build and setup logging and needed factories
|
||||
f_log = os.path.join(os.path.dirname(__file__), os.pardir, os.pardir,
|
||||
'logconfig.ini')
|
||||
logging.config.fileConfig(f_log)
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
# Build the client and connect to the server
|
||||
client = KMIPProxy(config=config)
|
||||
client.open()
|
||||
|
|
|
@ -35,11 +35,12 @@ from kmip.core.objects import Attribute
|
|||
from kmip.services.kmip_client import KMIPProxy
|
||||
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
logger = utils.build_console_logger(logging.INFO)
|
||||
|
||||
# Build and parse arguments
|
||||
parser = utils.build_cli_parser(Operation.CREATE)
|
||||
opts, args = parser.parse_args(sys.argv[1:])
|
||||
|
@ -52,18 +53,12 @@ if __name__ == '__main__':
|
|||
|
||||
# Exit early if the arguments are not specified
|
||||
if algorithm is None:
|
||||
logging.debug('No algorithm provided, exiting early from demo')
|
||||
logger.error('No algorithm provided, exiting early from demo')
|
||||
sys.exit()
|
||||
if length is None:
|
||||
logging.debug("No key length provided, exiting early from demo")
|
||||
logger.error("No key length provided, exiting early from demo")
|
||||
sys.exit()
|
||||
|
||||
# Build and setup logging and needed factories
|
||||
f_log = os.path.join(os.path.dirname(__file__), os.pardir, os.pardir,
|
||||
'logconfig.ini')
|
||||
logging.config.fileConfig(f_log)
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
attribute_factory = AttributeFactory()
|
||||
credential_factory = CredentialFactory()
|
||||
|
||||
|
@ -88,8 +83,8 @@ if __name__ == '__main__':
|
|||
algorithm_enum = getattr(CryptographicAlgorithm, algorithm, None)
|
||||
|
||||
if algorithm_enum is None:
|
||||
logging.debug("{0} not found".format(algorithm))
|
||||
logging.debug("Invalid algorithm specified, exiting early from demo")
|
||||
logger.debug("{0} not found".format(algorithm))
|
||||
logger.debug("Invalid algorithm specified, exiting early from demo")
|
||||
|
||||
client.close()
|
||||
sys.exit()
|
||||
|
|
|
@ -37,11 +37,12 @@ from kmip.core.objects import Attribute
|
|||
from kmip.services.kmip_client import KMIPProxy
|
||||
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
logger = utils.build_console_logger(logging.INFO)
|
||||
|
||||
# Build and parse arguments
|
||||
parser = utils.build_cli_parser(Operation.CREATE_KEY_PAIR)
|
||||
opts, args = parser.parse_args(sys.argv[1:])
|
||||
|
@ -55,28 +56,22 @@ if __name__ == '__main__':
|
|||
|
||||
# Exit early if the arguments are not specified
|
||||
if algorithm is None:
|
||||
logging.error('No algorithm provided, exiting early from demo')
|
||||
logger.error('No algorithm provided, exiting early from demo')
|
||||
sys.exit()
|
||||
if length is None:
|
||||
logging.error("No key length provided, exiting early from demo")
|
||||
logger.error("No key length provided, exiting early from demo")
|
||||
sys.exit()
|
||||
if name is None:
|
||||
logging.error("No key name provided, exiting early from demo")
|
||||
logger.error("No key name provided, exiting early from demo")
|
||||
sys.exit()
|
||||
|
||||
attribute_type = AttributeType.CRYPTOGRAPHIC_ALGORITHM
|
||||
algorithm_enum = getattr(CryptographicAlgorithm, algorithm, None)
|
||||
|
||||
if algorithm_enum is None:
|
||||
logging.error("Invalid algorithm specified; exiting early from demo")
|
||||
logger.error("Invalid algorithm specified; exiting early from demo")
|
||||
sys.exit()
|
||||
|
||||
# Build and setup logging and needed factories
|
||||
f_log = os.path.join(os.path.dirname(__file__), os.pardir, os.pardir,
|
||||
'logconfig.ini')
|
||||
logging.config.fileConfig(f_log)
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
attribute_factory = AttributeFactory()
|
||||
credential_factory = CredentialFactory()
|
||||
|
||||
|
|
|
@ -25,11 +25,12 @@ from kmip.demos import utils
|
|||
from kmip.services.kmip_client import KMIPProxy
|
||||
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
logger = utils.build_console_logger(logging.INFO)
|
||||
|
||||
# Build and parse arguments
|
||||
parser = utils.build_cli_parser(Operation.DESTROY)
|
||||
opts, args = parser.parse_args(sys.argv[1:])
|
||||
|
@ -41,15 +42,9 @@ if __name__ == '__main__':
|
|||
|
||||
# Exit early if the UUID is not specified
|
||||
if uuid is None:
|
||||
logging.debug('No UUID provided, exiting early from demo')
|
||||
logger.error('No UUID provided, exiting early from demo')
|
||||
sys.exit()
|
||||
|
||||
# Build and setup logging and needed factories
|
||||
f_log = os.path.join(os.path.dirname(__file__), os.pardir, os.pardir,
|
||||
'logconfig.ini')
|
||||
logging.config.fileConfig(f_log)
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
attribute_factory = AttributeFactory()
|
||||
credential_factory = CredentialFactory()
|
||||
|
||||
|
|
|
@ -23,12 +23,13 @@ from kmip.demos import utils
|
|||
from kmip.services.kmip_client import KMIPProxy
|
||||
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
import re
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
logger = utils.build_console_logger(logging.INFO)
|
||||
|
||||
# Build and parse arguments
|
||||
parser = utils.build_cli_parser(Operation.DISCOVER_VERSIONS)
|
||||
opts, args = parser.parse_args(sys.argv[1:])
|
||||
|
@ -44,12 +45,6 @@ if __name__ == '__main__':
|
|||
protocol_versions.append(ProtocolVersion.create(int(mm[0]),
|
||||
int(mm[1])))
|
||||
|
||||
# Build and setup logging
|
||||
f_log = os.path.join(os.path.dirname(__file__), os.pardir, os.pardir,
|
||||
'logconfig.ini')
|
||||
logging.config.fileConfig(f_log)
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
# Build the client and connect to the server
|
||||
client = KMIPProxy(config=config)
|
||||
client.open()
|
||||
|
|
|
@ -28,11 +28,12 @@ from kmip.demos import utils
|
|||
from kmip.services.kmip_client import KMIPProxy
|
||||
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
logger = utils.build_console_logger(logging.INFO)
|
||||
|
||||
# Build and parse arguments
|
||||
parser = utils.build_cli_parser(Operation.GET)
|
||||
opts, args = parser.parse_args(sys.argv[1:])
|
||||
|
@ -45,7 +46,7 @@ if __name__ == '__main__':
|
|||
|
||||
# Exit early if the UUID is not specified
|
||||
if uuid is None:
|
||||
logging.debug('No UUID provided, exiting early from demo')
|
||||
logger.error('No UUID provided, exiting early from demo')
|
||||
sys.exit()
|
||||
|
||||
format_type_enum = None
|
||||
|
@ -53,16 +54,10 @@ if __name__ == '__main__':
|
|||
format_type_enum = getattr(KeyFormatTypeEnum, format_type, None)
|
||||
|
||||
if format_type_enum is None:
|
||||
logging.error(
|
||||
logger.error(
|
||||
"Invalid key format type specified; exiting early from demo")
|
||||
sys.exit()
|
||||
|
||||
# Build and setup logging and needed factories
|
||||
f_log = os.path.join(os.path.dirname(__file__), os.pardir, os.pardir,
|
||||
'logconfig.ini')
|
||||
logging.config.fileConfig(f_log)
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
attribute_factory = AttributeFactory()
|
||||
credential_factory = CredentialFactory()
|
||||
|
||||
|
|
|
@ -30,11 +30,12 @@ from kmip.demos import utils
|
|||
from kmip.services.kmip_client import KMIPProxy
|
||||
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
logger = utils.build_console_logger(logging.INFO)
|
||||
|
||||
# Build and parse arguments
|
||||
parser = utils.build_cli_parser(Operation.LOCATE)
|
||||
opts, args = parser.parse_args(sys.argv[1:])
|
||||
|
@ -46,15 +47,9 @@ if __name__ == '__main__':
|
|||
|
||||
# Exit early if the UUID is not specified
|
||||
if name is None:
|
||||
logging.debug('No name provided, exiting early from demo')
|
||||
logger.error('No name provided, exiting early from demo')
|
||||
sys.exit()
|
||||
|
||||
# Build and setup logging and needed factories
|
||||
f_log = os.path.join(os.path.dirname(__file__), os.pardir, os.pardir,
|
||||
'logconfig.ini')
|
||||
logging.config.fileConfig(f_log)
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
attribute_factory = AttributeFactory()
|
||||
credential_factory = CredentialFactory()
|
||||
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
# under the License.
|
||||
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
|
||||
from six.moves import xrange
|
||||
|
@ -31,6 +30,8 @@ from kmip.services.kmip_client import KMIPProxy
|
|||
|
||||
|
||||
if __name__ == '__main__':
|
||||
logger = utils.build_console_logger(logging.INFO)
|
||||
|
||||
# Build and parse arguments
|
||||
parser = utils.build_cli_parser(Operation.QUERY)
|
||||
opts, args = parser.parse_args(sys.argv[1:])
|
||||
|
@ -39,12 +40,6 @@ if __name__ == '__main__':
|
|||
password = opts.password
|
||||
config = opts.config
|
||||
|
||||
# Build and setup logging and needed factories
|
||||
f_log = os.path.join(os.path.dirname(__file__), os.pardir, os.pardir,
|
||||
'logconfig.ini')
|
||||
logging.config.fileConfig(f_log)
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
# Build query function list.
|
||||
query_functions = list()
|
||||
query_functions.append(
|
||||
|
|
|
@ -25,11 +25,12 @@ from kmip.demos import utils
|
|||
from kmip.services.kmip_client import KMIPProxy
|
||||
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
logger = utils.build_console_logger(logging.INFO)
|
||||
|
||||
parser = utils.build_cli_parser(Operation.REGISTER)
|
||||
opts, args = parser.parse_args(sys.argv[1:])
|
||||
|
||||
|
@ -42,20 +43,14 @@ if __name__ == '__main__':
|
|||
# Exit early if the arguments are not specified
|
||||
object_type = getattr(ObjectType, object_type, None)
|
||||
if object_type is None:
|
||||
logging.error("Invalid object type specified; exiting early from demo")
|
||||
logger.error("Invalid object type specified; exiting early from demo")
|
||||
sys.exit()
|
||||
|
||||
key_format_type = getattr(KeyFormatType, format_type, None)
|
||||
if key_format_type is None:
|
||||
logging.error(
|
||||
logger.error(
|
||||
"Invalid key format type specified; exiting early from demo")
|
||||
|
||||
# Build and setup logging and needed factories
|
||||
f_log = os.path.join(os.path.dirname(__file__), os.pardir, os.pardir,
|
||||
'logconfig.ini')
|
||||
logging.config.fileConfig(f_log)
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
# Create the template attribute for the secret and then build the secret
|
||||
usage_mask = utils.build_cryptographic_usage_mask(logger, object_type)
|
||||
attributes = [usage_mask]
|
||||
|
|
|
@ -22,11 +22,12 @@ from kmip.demos import utils
|
|||
from kmip.services.kmip_client import KMIPProxy
|
||||
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
logger = utils.build_console_logger(logging.INFO)
|
||||
|
||||
# Build and parse arguments
|
||||
parser = utils.build_cli_parser(Operation.REVOKE)
|
||||
opts, args = parser.parse_args(sys.argv[1:])
|
||||
|
@ -36,15 +37,9 @@ if __name__ == '__main__':
|
|||
|
||||
# Exit early if the UUID is not specified
|
||||
if uuid is None:
|
||||
logging.debug('No UUID provided, exiting early from demo')
|
||||
logger.error('No UUID provided, exiting early from demo')
|
||||
sys.exit()
|
||||
|
||||
# Build and setup logging and needed factories
|
||||
f_log = os.path.join(os.path.dirname(__file__), os.pardir, os.pardir,
|
||||
'logconfig.ini')
|
||||
logging.config.fileConfig(f_log)
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
# Build the client and connect to the server
|
||||
client = KMIPProxy(config=config)
|
||||
client.open()
|
||||
|
|
|
@ -13,6 +13,11 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import binascii
|
||||
import logging
|
||||
import optparse
|
||||
import sys
|
||||
|
||||
from kmip.core.attributes import CryptographicAlgorithm
|
||||
from kmip.core.attributes import CryptographicLength
|
||||
|
||||
|
@ -38,9 +43,17 @@ from kmip.core.secrets import PublicKey
|
|||
from kmip.core.secrets import SymmetricKey
|
||||
from kmip.core.secrets import SecretData
|
||||
|
||||
import binascii
|
||||
import optparse
|
||||
import sys
|
||||
|
||||
def build_console_logger(level):
|
||||
logger = logging.getLogger('demo')
|
||||
logger.setLevel(level)
|
||||
handler = logging.StreamHandler()
|
||||
formatter = logging.Formatter(
|
||||
'%(asctime)s - %(name)s - %(levelname)s - %(message)s'
|
||||
)
|
||||
handler.setFormatter(formatter)
|
||||
logger.addHandler(handler)
|
||||
return logger
|
||||
|
||||
|
||||
def build_cli_parser(operation=None):
|
||||
|
|
|
@ -1,21 +0,0 @@
|
|||
[loggers]
|
||||
keys=root
|
||||
|
||||
[handlers]
|
||||
keys=consoleHandler
|
||||
|
||||
[formatters]
|
||||
keys=simpleFormatter
|
||||
|
||||
[logger_root]
|
||||
level=INFO
|
||||
handlers=consoleHandler
|
||||
|
||||
[handler_consoleHandler]
|
||||
class=StreamHandler
|
||||
level=INFO
|
||||
formatter=simpleFormatter
|
||||
args=(sys.stdout,)
|
||||
|
||||
[formatter_simpleFormatter]
|
||||
format=%(asctime)s - %(name)s - %(levelname)s - %(message)s
|
Loading…
Reference in New Issue