Example #1
0
def run(status: str) -> List[Dict[str, Any]]:
    api = get_api()
    devices = get_devices(api.all_lights(), ARGS.luxafor_flag_device)

    if not devices:
        exit(wording.get('device_no') + wording.get('exclamation_mark'))
    return process_devices(devices, status)
Example #2
0
def run(status: str) -> List[Dict[str, Any]]:
    api = get_api()
    devices = get_devices(api.list(), ARGS.thingm_blink_device)

    if not devices:
        exit(wording.get('device_no') + wording.get('exclamation_mark'))
    return process_devices(devices, status)
Example #3
0
def run(status : StatusType) -> List[ConsumerModel]:
	api = get_api()
	devices = get_devices(api.all_lights(), ARGS.thingm_blink1_device)

	if not devices:
		sys.exit(wording.get('device_no') + wording.get('exclamation_mark'))
	return process_devices(devices, status)
Example #4
0
def init(program: ArgumentParser) -> None:
    args = helper.get_first(program.parse_known_args())

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

    # report header

    reporter.print_header()
    print()

    # handle background run

    if args.background_run is True:
        application = loop.get_application()
        timer = loop.get_timer()
        timer.setInterval(500)
        timer.timeout.connect(lambda: background_run(program))
        timer.singleShot(0, lambda: run(program))  # type: ignore
        timer.start()
        sys.exit(application.exec_())
    else:
        run(program)
Example #5
0
def run(status):
    api = get_api()
    devices = get_devices(api.devices, ARGS.razer_chroma_device)

    if not devices:
        exit(wording.get('device_no') + wording.get('exclamation_mark'))
    return process_devices(status, devices)
Example #6
0
def run(status: StatusType) -> List[ConsumerModel]:
    api = get_api()
    devices = get_devices(api.devices, ARGS.razer_chroma_device)

    if not devices:
        sys.exit(wording.get('device_no') + wording.get('exclamation_mark'))
    return process_devices(devices, status)
Example #7
0
def run(status: str) -> List[Dict[str, Any]]:
    api = get_api()
    devices = get_devices(api.find_all(),
                          ARGS.agile_innovative_blinkstick_device)

    if not devices:
        exit(wording.get('device_no') + wording.get('exclamation_mark'))
    return process_devices(devices, status)
Example #8
0
def run(status):
	api = get_api()
	devices = get_devices(api.list(), ARGS.thingm_blink_device)
	api.close()

	if not devices:
		exit(wording.get('device_no') + wording.get('exclamation_mark'))
	return process_devices(status, devices)
Example #9
0
def load_consumer(consumer_name: str) -> Any:
    try:
        return importlib.import_module('chroma_feedback.consumer.' +
                                       consumer_name)
    except ImportError:
        exit(
            wording.get('consumer_no').format(consumer_name) +
            wording.get('exclamation_mark'))
Example #10
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)
Example #11
0
def process(program : ArgumentParser) -> List[ProducerModel]:
	args = helper.get_first(program.parse_known_args())
	result = []

	for producer_name in args.producer:
		producer = load_producer(producer_name)
		producer.init(program)
		try:
			result.extend(producer.run())
		except IOError:
			sys.exit(wording.get('producer_crash').format(producer_name) + wording.get('exclamation_mark'))
	return result
Example #12
0
def process(program : ArgumentParser, status : StatusType) -> List[ConsumerModel]:
	args = helper.get_first(program.parse_known_args())
	result = []

	for consumer_name in args.consumer:
		consumer = load_consumer(consumer_name)
		consumer.init(program)
		try:
			result.extend(consumer.run(status))
		except IOError:
			sys.exit(wording.get('consumer_crash').format(consumer_name) + wording.get('exclamation_mark'))
	return result
Example #13
0
def process(status, program):
    args = program.parse_known_args()[0]
    result = []

    for consumer_name in args.consumer:
        try:
            consumer = importlib.import_module('chroma_feedback.consumer.' +
                                               consumer_name)
            consumer.init(program)
            result.extend(consumer.run(status))
        except ImportError:
            exit(wording.get('consumer_no') + wording.get('exclamation_mark'))
    return result
Example #14
0
def api_factory() -> Any:
	api = None

	try:
		from lifxlan import LifxLAN, WorkflowException

		try:
			api = LifxLAN()
		except WorkflowException:
			exit(wording.get('connection_no').format('LIFX LIGHT') + wording.get('exclamation_mark'))
		return api
	except ImportError:
		exit(wording.get('package_no').format('LIFX LIGHT') + wording.get('exclamation_mark'))
Example #15
0
def process(program):
    args = program.parse_known_args()[0]
    result = []

    for provider_name in args.provider:
        try:
            provider = importlib.import_module('chroma_feedback.provider.' +
                                               provider_name)
            provider.init(program)
            result.extend(provider.run())
        except ImportError:
            exit(wording.get('provider_no') + wording.get('exclamation_mark'))
    return result
Example #16
0
def run(program):
    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 provider

    provider_result = provider.process(program)

    # handle exit

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

    # report provider

    provider_report = reporter.create_provider_report(provider_result)
    if provider_report:
        reporter.print_report(provider_report)
        print()

    # handle dry run

    args = program.parse_known_args()[0]
    if args.dry_run is False:

        # process consumer

        status = helper.get_provider_status(provider_result)
        consumer_result = consumer.process(status, program)

        # 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()
Example #17
0
def api_factory() -> Any:
	api = None

	try:
		from openrazer.client import DeviceManager, DaemonNotFound

		try:
			api = DeviceManager()
			api.sync_effects = True
		except DaemonNotFound:
			sys.exit(wording.get('daemon_no').format('RAZER CHROMA') + wording.get('exclamation_mark'))
		return api
	except ImportError:
		sys.exit(wording.get('package_no').format('OPENRAZER META') + wording.get('exclamation_mark'))
Example #18
0
def api_factory() -> Any:
	api = None

	try:
		from blinkstick import blinkstick

		try:
			api = blinkstick
			api.find_all()
		except OSError:
			exit(wording.get('connection_no').format('AGILE INNOVATIVE BLINKSTICK') + wording.get('exclamation_mark'))
		return api
	except ImportError:
		exit(wording.get('package_no').format('BLINKSTICK') + wording.get('exclamation_mark'))
Example #19
0
def create_producer_report(producer_result: List[Dict[str, Any]]) -> List[str]:
    report = []

    # process result

    for producer in producer_result:
        if producer['active'] is True:
            if producer['status'] == 'passed':
                report.append(
                    color.format_green(wording.get('tick')) +
                    ' ' + wording.get('build_passed').format(
                        producer['slug'], producer['producer']))
            if producer['status'] == 'process':
                report.append(
                    color.format_yellow(wording.get('hourglass')) + ' ' +
                    wording.get('build_process').format(
                        producer['slug'], producer['producer']))
            if producer['status'] == 'errored':
                report.append(
                    wording.get('cross') + ' ' +
                    wording.get('build_errored').format(
                        producer['slug'], producer['producer']))
            if producer['status'] == 'failed':
                report.append(
                    color.format_red(wording.get('cross')) +
                    ' ' + wording.get('build_failed').format(
                        producer['slug'], producer['producer']))
    return report
Example #20
0
def api_factory() -> Any:
	api = None

	try:
		from busylight.lights import USBLightIOError, USBLightNotFound
		from busylight.lights.agile_innovative import BlinkStick

		try:
			api = BlinkStick
			api.first_light().release()
		except (USBLightIOError, USBLightNotFound):
			sys.exit(wording.get('connection_no').format('AGILE INNOVATIVE BLINKSTICK') + wording.get('exclamation_mark'))
		return api
	except ImportError:
		sys.exit(wording.get('package_no').format('BUSYLIGHT FOR HUMANS') + wording.get('exclamation_mark'))
Example #21
0
def api_factory() -> Any:
	api = None

	try:
		from busylight.lights import USBLightIOError, USBLightNotFound
		from busylight.lights.embrava import Blynclight

		try:
			api = Blynclight
			api.first_light().release()
		except (USBLightIOError, USBLightNotFound):
			sys.exit(wording.get('connection_no').format('EMBRAVA BLYNCLIGHT') + wording.get('exclamation_mark'))
		return api
	except ImportError:
		sys.exit(wording.get('package_no').format('BUSYLIGHT FOR HUMANS') + wording.get('exclamation_mark'))
Example #22
0
def api_factory() -> Any:
	api = None

	try:
		from busylight.lights import USBLightIOError, USBLightNotFound
		from busylight.lights.thingm import Blink1

		try:
			api = Blink1
			api.first_light().release()
		except (USBLightIOError, USBLightNotFound):
			sys.exit(wording.get('connection_no').format('THINGM BLINK1') + wording.get('exclamation_mark'))
		return api
	except ImportError:
		sys.exit(wording.get('package_no').format('BUSYLIGHT FOR HUMANS') + wording.get('exclamation_mark'))
Example #23
0
def discover_ips() -> List[str]:
	ips = []
	message =\
	[
		'HF-A11ASSISTHREAD'
	]
	discovery = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
	discovery.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
	discovery.settimeout(2)
	discovery.sendto('\r\n'.join(message).encode(), ('255.255.255.255', 48899))

	try:
		ips.append(helper.get_first(discovery.recvfrom(65507)[1]))
	except OSError:
		print(wording.get('ip_no').format('MAGIC HUE') + wording.get('exclamation_mark'))
	return ips
Example #24
0
def discover_ips() -> List[str]:
	ips = []
	message =\
	[
		'M-SEARCH * HTTP/1.1',
		'MAN: "ssdp:discover"'
	]
	discovery = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP)
	discovery.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_TTL, 32)
	discovery.settimeout(2)
	discovery.sendto('\r\n'.join(message).encode(), ('239.255.255.250', 1900))

	try:
		ips.append(helper.get_first(discovery.recvfrom(65507)[1]))
	except socket.timeout:
		sys.exit(wording.get('ip_no').format('PHILIPS HUE BRIDGE') + wording.get('exclamation_mark'))
	return ips
Example #25
0
def api_factory(ip: str) -> Any:
    api = None

    try:
        from magichue import Light

        try:
            api = Light(ip)
        except OSError:
            exit(
                wording.get('connection_no').format('MAGIC HUE') +
                wording.get('exclamation_mark'))
        return api
    except ImportError:
        exit(
            wording.get('package_no').format('MAGIC HUE') +
            wording.get('exclamation_mark'))
Example #26
0
def api_factory() -> Any:
    api = None

    try:
        from blink1.blink1 import Blink1, Blink1ConnectionFailed

        try:
            api = Blink1()
        except Blink1ConnectionFailed:
            exit(
                wording.get('connection_no').format('THINGM BLINK') +
                wording.get('exclamation_mark'))
        return api
    except ImportError:
        exit(
            wording.get('package_no').format('THINGM BLINK') +
            wording.get('exclamation_mark'))
Example #27
0
def discover_ips() -> List[str]:
	ips = []
	message =\
	[
		'M-SEARCH * HTTP/1.1',
		'MAN: "ssdp:discover"'
	]
	discovery = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
	discovery.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
	discovery.settimeout(2)
	discovery.sendto('\r\n'.join(message).encode(), ('255.255.255.255', 38899))

	try:
		ips.append(helper.get_first(discovery.recvfrom(65507)[1]))
	except OSError:
		print(wording.get('ip_no').format('WIZ LIGHT') + wording.get('exclamation_mark'))
	return ips
Example #28
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)
Example #29
0
def api_factory(ip: str) -> Any:
    api = None

    try:
        from pywizlight import wizlight
        from pywizlight.exceptions import WizLightConnectionError, WizLightTimeOutError

        try:
            api = wizlight(ip, True)
        except (WizLightConnectionError, WizLightTimeOutError):
            sys.exit(
                wording.get('connection_no').format('WIZ LIGHT') +
                wording.get('exclamation_mark'))
        return api
    except ImportError:
        sys.exit(
            wording.get('package_no').format('WIZ LIGHT') +
            wording.get('exclamation_mark'))
Example #30
0
def discover_ips() -> List[str]:
	ips = []
	message =\
	[
		'M-SEARCH * HTTP/1.1',
		'HOST: 239.255.255.250:1982',
		'MAN: "ssdp:discover"',
		'ST: wifi_bulb'
	]
	discovery = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP)
	discovery.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_TTL, 32)
	discovery.settimeout(2)
	discovery.sendto('\r\n'.join(message).encode(), ('239.255.255.250', 1982))

	try:
		ips.append(helper.get_first(discovery.recvfrom(65507)[1]))
	except socket.timeout:
		print(wording.get('ip_no').format('XIAOMI YEELIGHT') + wording.get('exclamation_mark'))
	return ips