Exemplo n.º 1
0
def main (args, app):
  # print args.report
  # print app.parser.parse_known_args( )
  requested = args.report[:]
  for spec in requested:
    report =  app.actions.selected(args).reports[spec]
    device = app.devices[report.fields['device']]
    task = app.actions.commands['add'].usages.commands[device.name].method.commands[report.fields['use']]
    # print(task.name, task.usage, task.method, report.fields, app.inputs)
    # print device.name, device
    # print report.name, report.fields
    # XXX.bewest: very crude, need to prime the Use's args from the config
    app.parser.set_defaults(**task.method.from_ini(report.fields))
    args, extra = app.parser.parse_known_args(app.inputs)
    """
    for k, v in report.fields.items( ):
      setattr(args, k, v)
    """
    # print args
    print(report.format_url( ))
    repo = app.git_repo( )

    try:
        output = task.method(args, app)
    except Exception as e:
        print(report.name, ' raised ', e, file=sys.stderr)
        # save prior progress in git
        app.epilog( )
        # ensure we still blow up with non-zero exit
        raise
    else:
        reporters.Reporter(report, device, task)(output)
        print('reporting', report.name)
        repo.git.add([report.name], write_extension_data=False)
Exemplo n.º 2
0
def main(args, app):
    # print args.report
    # print app.parser.parse_known_args( )
    requested = args.report[:]
    for spec in requested:
        report = app.actions.selected(args).reports[spec]
        device = app.devices[report.fields['device']]
        task = app.actions.commands['add'].usages.commands[
            device.name].method.commands[report.fields['use']]
        # print task.name, task.usage, task.method
        # print device.name, device
        # print report.name, report.fields
        # XXX.bewest: very crude, need to prime the Use's args from the config
        app.parser.set_defaults(**report.fields)
        args, extra = app.parser.parse_known_args()
        """
    for k, v in report.fields.items( ):
      setattr(args, k, v)
    """
        # print args
        print(report.format_url())
        repo = app.git_repo()

        try:
            output = task.method(args, app)
        except Exception as e:
            print(report.name, ' raised ', e, file=sys.stderr)
            raise
        else:
            reporters.Reporter(report, device, task)(output)
            print('reporting', report.name)
            repo.index.add([report.name])
Exemplo n.º 3
0
    def compare(self, compared, competitors):
        reporter = reporters.Reporter()
        rules = ComparatorExtensions(compared, competitors, reporter)

        if rules.rule_valid_compared():
            if rules.rule_compared_smaller():
                self.send_with_email.send(reporter.format_report())

            if rules.rule_compared_two_times_smaller():
                self.send_with_sms.send(reporter.format_report())

        report = reporter.format_report()
        self.save_to_file.send(report)
        self.show_on_console.send(report)
Exemplo n.º 4
0
def main(args, app):
    report = app.actions.selected(args).reports[args.report]
    device = app.devices[report.fields['device']]
    task = app.actions.commands['add'].usages.commands[
        device.name].method.commands[report.fields['use']]
    # print task.name, task.usage, task.method
    # print device.name, device
    # print report.name, report.fields
    # XXX.bewest: very crude, need to prime the Use's args from the config
    for k, v in report.fields.items():
        setattr(args, k, v)
    # print args
    print report.format_url()
    repo = app.git_repo()
    reporter = reporters.Reporter(report, device, task)
    reporter(task.method(args, app))
    print 'reporting', report.name
    repo.index.add([report.name])