Ejemplo n.º 1
0
def run(program: ArgumentParser) -> None:
    status = None

    if sys.version_info < (3, 4):
        exit(
            wording.get('version_no').format(sys.version_info.major,
                                             sys.version_info.minor) +
            wording.get('exclamation_mark'))

    # report header

    if threading.active_count() == 1:
        reporter.print_header()
        print()

    # process producer

    producer_result = producer.process(program)

    # handle exit

    if not producer_result:
        exit(wording.get('result_no') + wording.get('exclamation_mark'))

    # report producer

    producer_report = reporter.create_producer_report(producer_result)
    if producer_report:
        reporter.print_report(producer_report)
        print()

    # handle dry run

    args = helper.get_first(program.parse_known_args())
    if args.dry_run is False:

        # process consumer

        status = helper.get_producer_status(producer_result)
        consumer_result = consumer.process(program, status)

        # report consumer

        consumer_report = reporter.create_consumer_report(consumer_result)
        if consumer_report:
            reporter.print_report(consumer_report)
            print()

    # handle thread

    if args.background_run is True:
        threading.Timer(args.background_interval, run, args=[program]).start()
        if helper.is_linux():
            systray_report = reporter.create_systray_report(producer_result)
            if systray.is_active():
                systray.update(status, systray_report)
            else:
                systray.create(status, systray_report)
Ejemplo n.º 2
0
def test_create_producer_report_failed() -> None:
    producer_report = reporter.create_producer_report(
        producer_result=[{
            'producer': 'travis',
            'slug': 'redaxmedia/chroma-feedback',
            'active': True,
            'status': 'failed'
        }])

    assert 'Build of redaxmedia/chroma-feedback on travis failed' in producer_report[
        0]
Ejemplo n.º 3
0
def test_create_producer_report_failed() -> None:
	producer_report = reporter.create_producer_report(
	[
		{
			'producer': 'github',
			'slug': 'redaxmedia/chroma-feedback',
			'active': True,
			'status': 'failed'
		}
	])

	assert producer_report[0]['status'] == 'failed'
	assert producer_report[0]['message'] == 'Build of redaxmedia/chroma-feedback on github failed'
	assert producer_report[0]['symbol']
Ejemplo n.º 4
0
def run(program: ArgumentParser) -> None:
    args = helper.get_first(program.parse_known_args())
    status = None

    # process producer

    producer_result = producer.process(program)

    # handle exit

    if not producer_result:
        sys.exit(wording.get('result_no') + wording.get('exclamation_mark'))

    # report producer

    producer_report = reporter.create_producer_report(producer_result)

    if producer_report:
        reporter.print_report(producer_report)
        print()

    # handle dry run

    if args.dry_run is False:

        # process consumer

        status = helper.get_producer_status(producer_result)
        consumer_result = consumer.process(program, status)

        # report consumer

        consumer_report = reporter.create_consumer_report(consumer_result)

        if consumer_report:
            reporter.print_report(consumer_report)
            print()

    # handle systray

    if loop.is_created() is True:
        if systray.is_created() is True:
            systray.update(status, producer_report)
        else:
            systray.create(status, producer_report)