示例#1
0
def create_dump(ctx):
    manifest_log = StringIO()
    manifest_handler = logging.StreamHandler(manifest_log)
    setup_loghandler(manifest_handler, ctx.options["verbose"])
    log.addHandler(manifest_handler)

    scopes = ctx.options["scopes"]

    meta = ctx.manifest["meta"] = OrderedDict()
    meta["invocation_time"] = datetime.now().isoformat()
    meta["finish_time"] = None
    meta["argv"] = sys.argv
    meta["options"] = ctx.options
    meta["host"] = gethostname()
    meta["uid"] = os.getuid()
    meta["gid"] = os.getgid()
    meta["version"] = VERSION

    init_storage(ctx)

    base_dir = str(ctx.options["project_dir"])
    config_path = get_config_path_from_options(
        base_dir, {"--file": ctx.options["compose_files"]}, ctx.environment
    )
    ctx.project = get_project(
        base_dir,
        config_path=config_path,
        project_name=ctx.options["project_name"],
        verbose=ctx.options["verbose"],
        host=None,
        tls_config=None,
        environment=ctx.environment,
    )

    if "config" in scopes:
        store_config(ctx)

    if "mounted" in scopes or "volumes" in scopes:
        if not ctx.options["no_pause"]:
            ctx.project.pause(service_names=ctx.options["services"])
        store_volumes(ctx)
        if not ctx.options["no_pause"]:
            ctx.project.unpause(service_names=ctx.options["services"])

    meta["finish_time"] = datetime.now().isoformat()

    normalize_manifest_mapping(ctx.manifest)
    manifest_log.seek(0)

    doc = yaml.dump(ctx.manifest, default_flow_style=False)
    doc += "---\n"
    doc += yaml.dump(
        [x.strip() for x in manifest_log.readlines() if x], default_style='"'
    )

    ctx.storage.write_file(doc, "Manifest.yml")

    ctx.storage.finalize()
示例#2
0
def create_dump(ctx):
    manifest_log = StringIO()
    manifest_handler = logging.StreamHandler(manifest_log)
    setup_loghandler(manifest_handler, ctx.options['verbose'])
    log.addHandler(manifest_handler)

    scopes = ctx.options['scopes']

    meta = ctx.manifest['meta'] = OrderedDict()
    meta['invocation_time'] = datetime.now().isoformat()
    meta['finish_time'] = None
    meta['argv'] = sys.argv
    meta['options'] = ctx.options
    meta['host'] = gethostname()
    meta['uid'] = os.getuid()
    meta['gid'] = os.getgid()
    meta['version'] = VERSION

    init_storage(ctx)

    base_dir = str(ctx.options['project_dir'])
    config_path = get_config_path_from_options(
        base_dir, {'--file': ctx.options['compose_files']}, ctx.environment)
    ctx.project = \
        get_project(base_dir, config_path=config_path,
                    project_name=ctx.options['project_name'],
                    verbose=ctx.options['verbose'], host=None, tls_config=None, environment=ctx.environment)

    if 'config' in scopes:
        store_config(ctx)

    if 'mounted' in scopes or 'volumes' in scopes:
        if not ctx.options['no_pause']:
            ctx.project.pause(service_names=ctx.options['services'])
        store_volumes(ctx)
        if not ctx.options['no_pause']:
            ctx.project.unpause(service_names=ctx.options['services'])

    meta['finish_time'] = datetime.now().isoformat()

    normalize_manifest_mapping(ctx.manifest)
    manifest_log.seek(0)

    doc = yaml.dump(ctx.manifest, default_flow_style=False)
    doc += '---\n'
    doc += yaml.dump([x.strip() for x in manifest_log.readlines() if x],
                     default_style='"')

    ctx.storage.write_file(doc, 'Manifest.yml')

    ctx.storage.finalize()
示例#3
0
def create_dump(ctx):
    manifest_log = StringIO()
    manifest_handler = logging.StreamHandler(manifest_log)
    setup_loghandler(manifest_handler, ctx.options['verbose'])
    log.addHandler(manifest_handler)

    scopes = ctx.options['scopes']

    meta = ctx.manifest['meta'] = OrderedDict()
    meta['invocation_time'] = datetime.now().isoformat()
    meta['finish_time'] = None
    meta['argv'] = sys.argv
    meta['options'] = ctx.options
    meta['host'] = gethostname()
    meta['uid'] = os.getuid()
    meta['gid'] = os.getgid()
    meta['version'] = __version__

    init_storage(ctx)

    base_dir = str(ctx.options['project_dir'])
    config_path = get_config_path_from_options(
        base_dir, {'--file': ctx.options['compose_files']}, ctx.environment)
    ctx.project = \
        get_project(base_dir, config_path=config_path,
                    project_name=ctx.options['project_name'],
                    verbose=ctx.options['verbose'], host=None, tls_config=None, environment=ctx.environment)

    if 'config' in scopes:
        store_config(ctx)

    if 'mounted' in scopes or 'volumes' in scopes:
        if ctx.options['no_pause']:
            ctx.project.pause(service_names=ctx.options['services'])
        store_volumes(ctx)
        if ctx.options['no_pause']:
            ctx.project.unpause(service_names=ctx.options['services'])

    meta['finish_time'] = datetime.now().isoformat()

    normalize_manifest_mapping(ctx.manifest)
    manifest_log.seek(0)

    doc = yaml.dump(ctx.manifest, default_flow_style=False)
    doc += '---\n'
    doc += yaml.dump([x.strip() for x in manifest_log.readlines() if x], default_style='"')

    ctx.storage.write_file(doc, 'Manifest.yml')

    ctx.storage.finalize()
示例#4
0
def main():
    try:
        args = parse_cli_args(sys.argv[1:])
        setup_loghandler(console_handler, getattr(args, 'verbose', False))
        args.action(args)
    except SystemExit as e:
        exit_code = e.code
    except compose_config.ConfigurationError as e:
        log.error(e.msg)
        exit_code = 1
    except Exception as e:
        log.error('An unhandled exception occurred, please submit a bug report:')
        log.exception(e)
        exit_code = 3
    else:
        exit_code = 0

    raise SystemExit(exit_code)
示例#5
0
def main():
    try:
        args = parse_cli_args(sys.argv[1:])
        setup_loghandler(console_handler, getattr(args, 'verbose', False))
        log.setLevel(console_handler.level)
        args.action(args)
    except SystemExit as e:
        exit_code = e.code
    except compose_config.ConfigurationError as e:
        log.error(e.msg)
        exit_code = 1
    except Exception as e:
        log.error(
            'An unhandled exception occurred, please submit a bug report:')
        log.exception(e)
        exit_code = 3
    else:
        exit_code = 0

    raise SystemExit(exit_code)