def main(): import _dimgx _dimgx._logexception = exitonraise(_dimgx._logexception) # WARNING: monkey patch; pylint: disable=protected-access args = buildparser().parse_args(sys_argv[1:]) logging_basicConfig(format=args.log_format) getLogger().setLevel(logging_getLevelName(args.log_level)) dc_kw = kwargs_from_env() # TODO: hack to work around github:docker/docker-py#706 if DOCKER_TLS_VERIFY == '0': dc_kw['tls'].assert_hostname = False dc = AutoVersionClient(**dc_kw) layers_dict = inspectlayers(dc, args.image) top_most_layer_id, selected_layers = selectlayers(args, layers_dict) if not selected_layers: _LOGGER.warning('no known layers selected') if args.target is None: printlayerinfo(args, selected_layers) else: extractlayers(dc, args, selected_layers, top_most_layer_id)
def main(): import _dimgx _dimgx._logexception = exitonraise(_dimgx._logexception) # WARNING: monkey patch; pylint: disable=protected-access args = buildparser().parse_args(sys_argv[1:]) logging_basicConfig(format=args.log_format) getLogger().setLevel(logging_getLevelName(args.log_level)) patch_broken_tarfile_29760() dc_kw = kwargs_from_env() # TODO: hack to work around github:docker/docker-py#706 if DOCKER_TLS_VERIFY == '0': dc_kw['tls'].assert_hostname = False dc = AutoVersionClient(**dc_kw) layers_dict = inspectlayers(dc, args.image) top_most_layer_id, selected_layers = selectlayers(args, layers_dict) if not selected_layers: _LOGGER.warning('no known layers selected') if args.target is None: printlayerinfo(args, selected_layers) else: extractlayers(dc, args, selected_layers, top_most_layer_id)
__all__ = () DOCKER_TLS_VERIFY = environ.get('DOCKER_TLS_VERIFY', None) DOCKER_TLS_VERIFY = DOCKER_TLS_VERIFY if DOCKER_TLS_VERIFY else None _LOGGER = getLogger(__name__.lstrip('_')) _LAYER_RE_STR = r'(?:[0-9A-Fa-f]{1,64})' _LAYER_SPEC_RE = re_compile(r'^(?P<l>{layer_re})(?::(?P<r>{layer_re}))?$'.format(layer_re=_LAYER_RE_STR), IGNORECASE) _TARGET_STDOUT = '-' _CMP_BZIP2 = 'bz2' _CMP_GZIP = 'gz' _CMP_NONE = None _DEFAULT_CMP_LVL = 9 _DEFAULT_LOG_FMT = '%(levelname)-8s: %(message)s' _LOG_LEVELS_BY_NAME = OrderedDict(( ( logging_getLevelName(l), l ) for l in ( ERROR, WARNING, INFO, DEBUG ) )) _DEFAULT_LOG_LVL = logging_getLevelName(WARNING) _EXIT_EXEC = 2 _EXIT_LAYER_SPEC = 3 _USAGE = """ %(prog)s [options] [-l LAYER_SPEC] ... [-t PATH] IMAGE_SPEC %(prog)s -h # for help """ _DESCRIPTION = """ Docker IMaGe layer eXtractor (and flattener) """ _EPILOG = """ Diagnostics: 1 for a problem encountered while parsing the command arguments; {} for an execution error; {} for a LAYER_SPEC that doesn\'t reference a known layer (if strict layer specifications are enabled).
from logging import ( CRITICAL, basicConfig as logging_basicConfig, getLevelName as logging_getLevelName, getLogger, ) from dimgx import patch_broken_tarfile_29760 from _dimgx.cmd import _DEFAULT_LOG_FMT # ---- Constants --------------------------------------------------------- __all__ = ('HashedBytesIo', ) _LOG_LVL = environ.get('LOG_LVL') _LOG_LVL = CRITICAL + 1 if not _LOG_LVL else logging_getLevelName(_LOG_LVL) _LOG_FMT = environ.get('LOG_FMT', _DEFAULT_LOG_FMT) # ---- Classes ----------------------------------------------------------- # ======================================================================== class HashedBytesIo(BytesIO): # ---- Constructor --------------------------------------------------- def __init__(self, initial_bytes=None, hashimpl=sha256): super().__init__(initial_bytes) self._hash_obj = hashimpl() # ---- Public properties ---------------------------------------------
DOCKER_TLS_VERIFY = environ.get('DOCKER_TLS_VERIFY', None) DOCKER_TLS_VERIFY = DOCKER_TLS_VERIFY if DOCKER_TLS_VERIFY else None _LOGGER = getLogger(__name__.lstrip('_')) _LAYER_RE_STR = r'(?:[0-9A-Fa-f]{1,64})' _LAYER_SPEC_RE = re_compile( r'^(?P<l>{layer_re})(?::(?P<r>{layer_re}))?$'.format( layer_re=_LAYER_RE_STR), IGNORECASE) _TARGET_STDOUT = '-' _CMP_BZIP2 = 'bz2' _CMP_GZIP = 'gz' _CMP_NONE = None _DEFAULT_CMP_LVL = 9 _DEFAULT_LOG_FMT = '%(levelname)-8s: %(message)s' _LOG_LEVELS_BY_NAME = OrderedDict( ((logging_getLevelName(l), l) for l in (ERROR, WARNING, INFO, DEBUG))) _DEFAULT_LOG_LVL = logging_getLevelName(WARNING) _EXIT_EXEC = 2 _EXIT_LAYER_SPEC = 3 _USAGE = """ %(prog)s [options] [-l LAYER_SPEC] ... [-t PATH] IMAGE_SPEC %(prog)s -h # for help """ _DESCRIPTION = """ Docker IMaGe layer eXtractor (and flattener) """ _EPILOG = """ Diagnostics: 1 for a problem encountered while parsing the command arguments; {} for an execution error; {} for a LAYER_SPEC that doesn\'t reference a known layer (if strict layer specifications are enabled).
basicConfig as logging_basicConfig, getLevelName as logging_getLevelName, getLogger, ) from dimgx import patch_broken_tarfile_29760 from _dimgx.cmd import _DEFAULT_LOG_FMT # ---- Constants --------------------------------------------------------- __all__ = ( 'HashedBytesIo', ) _LOG_LVL = environ.get('LOG_LVL') _LOG_LVL = CRITICAL + 1 if not _LOG_LVL else logging_getLevelName(_LOG_LVL) _LOG_FMT = environ.get('LOG_FMT', _DEFAULT_LOG_FMT) # ---- Classes ----------------------------------------------------------- # ======================================================================== class HashedBytesIo(BytesIO): # ---- Constructor --------------------------------------------------- def __init__(self, initial_bytes=None, hashimpl=sha256): super().__init__(initial_bytes) self._hash_obj = hashimpl() # ---- Public properties ---------------------------------------------
from logging import ( CRITICAL, basicConfig as logging_basicConfig, getLevelName as logging_getLevelName, getLogger, ) from _dimgx.cmd import _DEFAULT_LOG_FMT #---- Constants ---------------------------------------------------------- __all__ = ( 'HashedBytesIo', ) _LOG_LEVEL = environ.get('_DIMGX_LOG_LVL') _LOG_LEVEL = CRITICAL + 1 if not _LOG_LEVEL else logging_getLevelName(_LOG_LEVEL) #---- Classes ------------------------------------------------------------ #========================================================================= class HashedBytesIo(BytesIO): #---- Constructor ---------------------------------------------------- def __init__(self, initial_bytes=None, hashimpl=sha256): super().__init__(initial_bytes) self._hash_obj = hashimpl() #---- Public properties ---------------------------------------------- @property