Ejemplo n.º 1
0
def report(options, policies):
    assert len(policies) == 1, "Only one policy report at a time"
    policy = policies.pop()
    d = datetime.now()
    delta = timedelta(days=options.days)
    begin_date = d - delta
    do_report(policy, begin_date, sys.stdout, raw_output_fh=options.raw)
Ejemplo n.º 2
0
def report(options, policies):
    assert len(policies) == 1, "Only one policy report at a time"
    policy = policies.pop()
    d = datetime.now()
    delta = timedelta(days=options.days)
    begin_date = d - delta
    do_report(
        policy, begin_date, sys.stdout,
        raw_output_fh=options.raw)
Ejemplo n.º 3
0
def report(options, policies):
    if len(policies) == 0:
        log.error('Error: must supply at least one policy')
        sys.exit(1)

    resources = set([p.resource_type for p in policies])
    if len(resources) > 1:
        log.error('Error: Report subcommand can accept multiple policies, '
                  'but they must all be for the same resource.')
        sys.exit(1)

    delta = timedelta(days=options.days)
    begin_date = datetime.now() - delta
    do_report(
        policies, begin_date, options, sys.stdout, raw_output_fh=options.raw)
Ejemplo n.º 4
0
def report(options, policies):
    if len(policies) == 0:
        log.error('Error: must supply at least one policy')
        sys.exit(1)

    resources = set([p.resource_type for p in policies])
    if len(resources) > 1:
        log.error('Error: Report subcommand can accept multiple policies, '
                  'but they must all be for the same resource.')
        sys.exit(1)

    delta = timedelta(days=options.days)
    begin_date = datetime.now() - delta
    do_report(
        policies, begin_date, options, sys.stdout, raw_output_fh=options.raw)
Ejemplo n.º 5
0
def report(options, policies):
    if len(policies) != 1:
        eprint("Error: Report subcommand requires exactly one policy")
        sys.exit(1)
    
    policy = policies.pop()
    odir = options.output_dir.rstrip(os.path.sep)
    if os.path.sep in odir and os.path.basename(odir) == policy.name:
        # policy sub-directory passed - ignore
        options.output_dir = os.path.split(odir)[0]
        # regenerate the execution context based on new path
        policy = Policy(policy.data, options)
    d = datetime.now()
    delta = timedelta(days=options.days)
    begin_date = d - delta
    do_report(
        policy, begin_date, options, sys.stdout,
        raw_output_fh=options.raw)
Ejemplo n.º 6
0
def report(options, policies):
    if len(policies) != 1:
        eprint("Error: Report subcommand requires exactly one policy")
        sys.exit(1)

    policy = policies.pop()
    odir = options.output_dir.rstrip(os.path.sep)
    if os.path.sep in odir and os.path.basename(odir) == policy.name:
        options.region = options.regions[0]
        # policy sub-directory passed - ignore
        options.output_dir = os.path.split(odir)[0]
        # regenerate the execution context based on new path
        policy = Policy(policy.data, options)
    d = datetime.now()
    delta = timedelta(days=options.days)
    begin_date = d - delta
    do_report(
        policy, begin_date, options, sys.stdout,
        raw_output_fh=options.raw)