@@ -197,37 +197,40 @@ In this section, you create a Python app to get the module twin desired properti
197
197
198
198
1. Add the following code to your Python file. Replace *YourModuleConnectionString* with the module connection string you copied in step 1.
199
199
200
- ```python
201
- import time
202
- from azure.iot.device import IoTHubModuleClient
200
+ ```python
201
+ import time
202
+ from azure.iot.device import IoTHubModuleClient
203
203
204
- def twin_patch_handler(twin_patch):
205
- print("")
206
- print("Twin desired properties patch received:")
207
- print(twin_patch)
204
+ CONNECTION_STRING = "YourIotHubConnectionString"
208
205
209
206
210
- def main():
211
- print ("Starting the IoT Hub Python sample...")
212
- client = IoTHubModuleClient.create_from_connection_string(CONNECTION_STRING)
207
+ def twin_patch_handler(twin_patch):
208
+ print("")
209
+ print("Twin desired properties patch received:")
210
+ print(twin_patch)
213
211
214
- print ("Waiting for commands, press Ctrl-C to exit")
215
- try:
216
- # Attach the handler to the client
217
- client.on_twin_desired_properties_patch_received = twin_patch_handler
218
-
219
- while True:
220
- time.sleep(1000)
221
- except KeyboardInterrupt:
222
- print("IoTHubModuleClient sample stopped")
223
- finally:
224
- # Graceful exit
225
- print("Shutting down IoT Hub Client")
226
- client.shutdown()
227
-
228
- if __name__ == '__main__':
229
- main()
230
- ```
212
+
213
+ def main():
214
+ print ("Starting the IoT Hub Python sample...")
215
+ client = IoTHubModuleClient.create_from_connection_string(CONNECTION_STRING)
216
+
217
+ print ("Waiting for commands, press Ctrl-C to exit")
218
+ try:
219
+ # Attach the handler to the client
220
+ client.on_twin_desired_properties_patch_received = twin_patch_handler
221
+
222
+ while True:
223
+ time.sleep(1000)
224
+ except KeyboardInterrupt:
225
+ print("IoTHubModuleClient sample stopped")
226
+ finally:
227
+ # Graceful exit
228
+ print("Shutting down IoT Hub Client")
229
+ client.shutdown()
230
+
231
+ if __name__ == '__main__':
232
+ main()
233
+ ```
231
234
232
235
## Run the apps
233
236
0 commit comments