diff --git a/bench/cli/iiotools.py b/bench/cli/iiotools.py index 3206468..b8079e9 100644 --- a/bench/cli/iiotools.py +++ b/bench/cli/iiotools.py @@ -1,6 +1,11 @@ import click -import iio +try: + import iio +except ImportError: + click.echo("IIO not found, please install pylibiio") + exit(1) + @click.group() @click.option("--uri", "-u", help="URI of target device/board") @@ -16,15 +21,12 @@ def cli(ctx, uri, device, complex): @cli.command() -@click.option("--attribute", "-a", help="Attribute to access", required=True) -@click.pass_context -def get(ctx, attribute): - """Get an attribute from a device""" - click.echo(f"Get {attribute} from {ctx.obj['uri']}") - -@cli.command() -@click.option("--frequency", "-f", help="Set the frequency of the DDS in Hz", required=True) -@click.option("--amplitude", "-a", help="Set the amplitude of the DDS in 0->1", required=True) +@click.option( + "--frequency", "-f", help="Set the frequency of the DDS in Hz", required=True +) +@click.option( + "--amplitude", "-a", help="Set the amplitude of the DDS in 0->1", required=True +) @click.option("--channel", "-c", help="Set the channel of the DDS", required=True) @click.pass_context def set_dds(ctx, frequency, amplitude, channel): @@ -52,7 +54,7 @@ def set_dds(ctx, frequency, amplitude, channel): ch = int(channel) * 4 channels = [ch, ch + 1] else: - ch = int(channel)*2 + ch = int(channel) * 2 channels = [ch, ch + 1] for i, ch in enumerate(channels): @@ -70,6 +72,3 @@ def set_dds(ctx, frequency, amplitude, channel): chan.attrs["phase"].value = "0" click.echo(f"Set DDS of channel {channel} to {frequency}Hz and {amplitude} scale") - - - diff --git a/bench/cli/main.py b/bench/cli/main.py deleted file mode 100644 index f5ea32f..0000000 --- a/bench/cli/main.py +++ /dev/null @@ -1,19 +0,0 @@ -import click - - - -# @click.group() -# @click.option("--uri", "-u", help="URI to connect to device") -# @click.pass_context -# def cli(ctx, uri): -# """Command line interface for pybench""" -# ctx.obj = {} -# ctx.obj["uri"] = uri - -# @cli.command() -# @click.option("--attribute", "-a", help="Attribute to access", required=True) -# @click.pass_context -# def get(ctx, attribute): -# """Get an attribute from a device""" -# click.echo(f"Get {attribute} from {ctx.obj['uri']}") - diff --git a/bench/cli/visatools.py b/bench/cli/visatools.py index 8d0e6f7..7775237 100644 --- a/bench/cli/visatools.py +++ b/bench/cli/visatools.py @@ -9,6 +9,7 @@ def cli(ctx, uri): ctx.obj = {} ctx.obj["uri"] = uri + @cli.command() @click.pass_context def list(ctx, attribute): diff --git a/doc/source/cli.md b/doc/source/cli.md index ce8411d..9ad2916 100644 --- a/doc/source/cli.md +++ b/doc/source/cli.md @@ -1,6 +1,6 @@ # Command Line Interface Tools -The following command line tools are available in the when the optional `cli` dependency is installed. +The following command line tools are available in the when the optional `cli` dependency is installed. ```bash pip install pybench[cli] @@ -29,4 +29,4 @@ There are two command line tools available: :nested: full -``` \ No newline at end of file +```