2018-01-03 18:53:34 +00:00
|
|
|
import json
|
|
|
|
import logging
|
|
|
|
import logging.config
|
|
|
|
import os
|
2018-03-03 00:22:20 +00:00
|
|
|
import subprocess
|
2013-08-29 15:21:13 +01:00
|
|
|
|
2018-01-03 18:53:34 +00:00
|
|
|
from core import constants
|
2013-08-29 15:21:13 +01:00
|
|
|
|
2018-01-03 22:40:45 +00:00
|
|
|
# setup logging
|
2018-01-03 18:53:34 +00:00
|
|
|
log_config_path = os.path.join(constants.CORE_CONF_DIR, "logging.conf")
|
|
|
|
with open(log_config_path, "r") as log_config_file:
|
|
|
|
log_config = json.load(log_config_file)
|
|
|
|
logging.config.dictConfig(log_config)
|
|
|
|
|
|
|
|
logger = logging.getLogger()
|
2018-01-03 22:40:45 +00:00
|
|
|
|
2018-03-03 00:22:20 +00:00
|
|
|
|
|
|
|
class CoreCommandError(subprocess.CalledProcessError):
|
|
|
|
"""
|
|
|
|
Used when encountering internal CORE command errors.
|
|
|
|
"""
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return "Command(%s), Status(%s):\n%s" % (self.cmd, self.returncode, self.output)
|