-
-
Save altendky/a1423f8519c4785283ee723106ef5e8b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Run such as: | |
venv/bin/python rundevice.py --device-path "interface/devices/DG 247 Factory.epz" | |
""" | |
import click | |
import epyqlib.hildevice | |
import epyqlib.utils.twisted | |
import twisted.internet.defer | |
import twisted.internet.reactor | |
import twisted.internet.task | |
def react_async_helper(reactor, f, args, kwargs): | |
return twisted.internet.defer.ensureDeferred( | |
f(reactor, *args, **kwargs), | |
) | |
def react_async(f, *args, **kwargs): | |
twisted.internet.task.react(react_async_helper, (f, args, kwargs)) | |
@click.command() | |
@click.option( | |
'--device-path', | |
type=click.Path(exists=True, dir_okay=False, resolve_path=True), | |
required=True, | |
) | |
def command(device_path): | |
react_async(async_main, device_path=device_path) | |
async def async_main(reactor, device_path): | |
device = epyqlib.hildevice.Device(definition_path=device_path) | |
print('about to sleep') | |
await epyqlib.utils.twisted.sleep(1) | |
print('slept 1') | |
await epyqlib.utils.twisted.sleep(1) | |
print('slept 1') | |
command() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
altendky/altwistendpy#1