From 6aeefba4cc53dea253aaeb945160dfa1552fd91f Mon Sep 17 00:00:00 2001 From: Paymaun Date: Thu, 30 Aug 2018 18:18:09 -0700 Subject: [PATCH] v0.5.2 additions (#41) * Reformatted readme * Using uamqp 1.0.1 which significantly reduces chance of deadlock on interrupt * Catch empty sys.excepthook errors occasionally raised by underlying cancelled futures --- README.md | 59 +++++++++++++------------ azext_iot/_constants.py | 2 +- azext_iot/operations/events3/_events.py | 5 ++- setup.py | 4 ++ 4 files changed, 39 insertions(+), 31 deletions(-) diff --git a/README.md b/README.md index e85d8102f..b124dabf9 100644 --- a/README.md +++ b/README.md @@ -12,42 +12,47 @@ The extension augments the vanilla Azure CLI IoT by adding to or modifying the e - IoT Edge - IoT Device Provisioning Service (DPS) -## Quick Start +## Installation -Validate that your Azure CLI version is [compatible](#compatibility). +The extension is designed to be plug-and-play with Azure CLI. **Even** if you have Azure CLI installed make sure it is up to date. -**Add the extension**: `az extension add --name azure-cli-iot-ext` +:exclamation: For **installation troubleshooting** please go to the [respective docs section](docs/install-help.md) for help. -**List installed extensions**: `az extension list` +### Compatibility +Before installation ensure that your Azure CLI version meets the following criteria. The criteria differs based on OS and method of installation. Use `az --version` to determine the CLI version. -**Update the extension**: `az extension update --name azure-cli-iot-ext` +In all cases your CLI needs to be at least `v2.0.24`. -**Remove the extension**: `az extension remove --name azure-cli-iot-ext` +| CLI Install Method | NOT compatible with | +| ------------- | ------------- | +| Windows via MSI | v2.0.34 to v2.0.38 | +| Windows via PIP, Linux or macOS | v2.0.34 to v2.0.36 | -## Installation -The extension is designed to be plug-and-play with Azure CLI. **Even** if you have Azure CLI installed make sure it is up to date. +### Quick Guide -:exclamation: For **installation troubleshooting** please go to the [respective docs section](docs/install-help.md) for help. +Validate that your Azure CLI version is [compatible](#compatibility). -### Compatibility -Before installation validate that your Azure CLI version is within the following criteria. The criteria differs based on OS and method of installation. Use `az --version` to validate. +**Common Az CLI extension operations** + +Add: `az extension add --name azure-cli-iot-ext` + +List: `az extension list` -```python -# Windows MSI ->= '2.0.24' and NOT between '2.0.34' - '2.0.38' inclusive +Update: `az extension update --name azure-cli-iot-ext` -# Windows PIP, Linux and macOS ->= '2.0.24' and NOT between '2.0.34' - '2.0.36' inclusive -``` +Remove: `az extension remove --name azure-cli-iot-ext` -### Step 0: Install/Update Azure CLI -At a minimum your CLI core version must be within the compatibility criteria defined above. +### Full Guide + +#### Step 0: Install/Update Azure CLI + +At a minimum your CLI core version must be within the [compatibility](#compatibility) criteria defined above. Follow the installation instructions on [GitHub](https://github.com/Azure/azure-cli) or [Microsoft Docs](https://docs.microsoft.com/en-us/cli/azure/install-azure-cli?view=azure-cli-latest) to setup Azure CLI in your environment. -### Step 1: Install the extension +#### Step 1: Install the extension Now that you have a compatible Azure CLI installed you can add the IoT extension. When you install an extension, any additional Python dependencies required are automatically downloaded and installed. @@ -89,7 +94,7 @@ To build the wheel locally, ensure you have the Python `wheel` package installed Now follow the local package installation method. -### Step 2: Log In (if you haven't already) +#### Step 2: Log In (if you haven't already) Your subscription details are used to interact with target resources. @@ -97,7 +102,7 @@ You can login interactively, pass in account credentials, or use a service princ [More details](https://docs.microsoft.com/en-us/cli/azure/authenticate-azure-cli?view=azure-cli-latest) about Azure CLI authentication. -### Step 3: Have Fun +#### Step 3: Have Fun If you have any suggestions or find bugs, please let us know. @@ -107,16 +112,17 @@ To remove the extension at any time, you can use `az extension remove --name azu ## Command Guide -[Command Wiki](https://github.com/Azure/azure-iot-cli-extension/wiki/Commands) +The [Microsoft Docs](https://docs.microsoft.com/en-us/cli/azure/ext/azure-cli-iot-ext/iot?view=azure-cli-latest) extensions reference are updated per release. #### Tips for success -**Tip#1** Many commands require the default policy to exist on the target resource which is being manipulated. For example IoT Hub based commands commonly look for the **iothubowner** policy. _This behavior will change in a future update_. +* Many commands require the default policy to exist on the target resource which is being manipulated. For example IoT Hub based commands commonly look for the **iothubowner** policy. _This behavior will change in a future update_. -**Tip#2** For command parameters that take JSON, for example the `az iot hub device-twin update` command's `--set` parameter, JSON input is different between CMD/PowerShell and Bash-like shells. +* For command parameters that take JSON, for example the `az iot hub device-twin update` command's `--set` parameter, the JSON input format is different between CMD/PowerShell and Bash-like shells. Please read the [Tips Wiki page](https://github.com/Azure/azure-iot-cli-extension/wiki/Tips) for more detail and to maximize the functionality and enjoyment out of the IoT extension. + ## Developer setup Extension development depends on a local Azure CLI dev environment. First, follow these [instructions](https://github.com/Azure/azure-cli/blob/master/doc/configuring_your_machine.md) to prepare your machine. @@ -185,9 +191,6 @@ At this point if your environment has been setup to execute all tests, you can l `pytest -v --cov=azext_iot --cov-config /.coveragerc` -## Known Issues - -- Device Export does not currently support IoT Edge device capability ## Contributing diff --git a/azext_iot/_constants.py b/azext_iot/_constants.py index 65e54619b..e21844f29 100644 --- a/azext_iot/_constants.py +++ b/azext_iot/_constants.py @@ -16,7 +16,7 @@ MIN_SIM_MSG_INTERVAL = 1 MIN_SIM_MSG_COUNT = 1 SIM_RECEIVE_SLEEP_SEC = 3 -EVENT_LIB = ('uamqp', '0.2.1') +EVENT_LIB = ('uamqp', '1.0.1') # Config Key's CONFIG_KEY_UAMQP_EXT_VERSION = 'uamqp_ext_version' diff --git a/azext_iot/operations/events3/_events.py b/azext_iot/operations/events3/_events.py index f5b253240..e4a7047df 100644 --- a/azext_iot/operations/events3/_events.py +++ b/azext_iot/operations/events3/_events.py @@ -108,7 +108,7 @@ def _get_conn_props(): properties=properties, device_id=device_id, timeout=timeout)) - await asyncio.gather(*coroutines) + await asyncio.gather(*coroutines, return_exceptions=True) async def monitor_events(endpoint, connection, path, auth, partition, consumer_group, enqueuedtimeutc, @@ -154,7 +154,7 @@ def _output_msg_kpi(msg): async for msg in receive_client.receive_messages_iter_async(): _output_msg_kpi(msg) - except asyncio.CancelledError: + except (asyncio.CancelledError, KeyboardInterrupt): exp_cancelled = True await receive_client.close_async() except uamqp.errors.LinkDetach as ld: @@ -164,6 +164,7 @@ def _output_msg_kpi(msg): finally: if not exp_cancelled: await receive_client.close_async() + logger.info("Closed monitor on partition %s", partition) def _build_auth_container(target): diff --git a/setup.py b/setup.py index 1270c6824..7a2d3b131 100644 --- a/setup.py +++ b/setup.py @@ -40,6 +40,10 @@ # 'jmespath==0.9.3', # 'pyyaml==3.13' +# There is also a dependency for uamqp for amqp based commands +# though that is installed out of band (managed by the extension) +# for compatibility reasons. + DEPENDENCIES = [ 'paho-mqtt==1.3.1' ]