|  | 
| 284 | 284 |  "outputs": [], | 
| 285 | 285 |  "source": [ | 
| 286 | 286 |  "import boto3\n", | 
|  | 287 | + "from botocore.exceptions import ClientError\n", | 
| 287 | 288 |  "import os\n", | 
| 288 | 289 |  "import time\n", | 
| 289 | 290 |  "\n", | 
|  | 
| 457 | 458 |  " print(\"Endpoint status: {}\".format(response['EndpointStatus']))\n", | 
| 458 | 459 |  " if response['EndpointStatus'] == 'InService':\n", | 
| 459 | 460 |  " break\n", | 
| 460 |  | - " except:\n", | 
| 461 |  | - " pass \n", | 
|  | 461 | + " except ClientError as e:\n", | 
|  | 462 | + " print(e.response[\"Error\"][\"Message\"])\n", | 
| 462 | 463 |  " time.sleep(10)" | 
| 463 | 464 |  ] | 
| 464 | 465 |  }, | 
|  | 
| 690 | 691 |  "print('stack name: {}'.format(stack_name))\n", | 
| 691 | 692 |  "\n", | 
| 692 | 693 |  "# Get latest stack events\n", | 
| 693 |  | - "response = cfn.describe_stack_events(StackName=stack_name)\n", | 
|  | 694 | + "while True:\n", | 
|  | 695 | + " try:\n", | 
|  | 696 | + " response = cfn.describe_stack_events(StackName=stack_name)\n", | 
|  | 697 | + " break\n", | 
|  | 698 | + " except ClientError as e:\n", | 
|  | 699 | + " print(e.response[\"Error\"][\"Message\"])\n", | 
|  | 700 | + " time.sleep(10)\n", | 
|  | 701 | + " \n", | 
| 694 | 702 |  "get_event_dataframe(response['StackEvents']).head()" | 
| 695 | 703 |  ] | 
| 696 | 704 |  }, | 
|  | 
| 735 | 743 |  " and 'DataCaptureConfig' in response \\\n", | 
| 736 | 744 |  " and response['DataCaptureConfig']['EnableCapture']:\n", | 
| 737 | 745 |  " break\n", | 
| 738 |  | - " except:\n", | 
| 739 |  | - " pass\n", | 
|  | 746 | + " except ClientError as e:\n", | 
|  | 747 | + " print(e.response[\"Error\"][\"Message\"])\n", | 
| 740 | 748 |  " time.sleep(10)" | 
| 741 | 749 |  ] | 
| 742 | 750 |  }, | 
|  | 
| 777 | 785 |  " response = cfn.describe_stacks(StackName=stack_name)\n", | 
| 778 | 786 |  " if response['Stacks']:\n", | 
| 779 | 787 |  " stack = response['Stacks'][0]\n", | 
|  | 788 | + " outputs = None\n", | 
| 780 | 789 |  " if 'Outputs' in stack:\n", | 
| 781 | 790 |  " outputs = dict([(o['OutputKey'], o['OutputValue']) for o in stack['Outputs']])\n", | 
| 782 | 791 |  " return stack['StackStatus'], outputs \n", | 
|  | 
| 787 | 796 |  " status, outputs = get_stack_status(stack_name)\n", | 
| 788 | 797 |  " response = sm.describe_endpoint(EndpointName=prd_endpoint_name)\n", | 
| 789 | 798 |  " print(\"Endpoint status: {}\".format(response['EndpointStatus']))\n", | 
| 790 |  | - " except:\n", | 
| 791 |  | - " pass\n", | 
|  | 799 | + " except ClientError as e:\n", | 
|  | 800 | + " print(e.response[\"Error\"][\"Message\"])\n", | 
| 792 | 801 |  " time.sleep(10) \n", | 
| 793 | 802 |  " \n", | 
| 794 | 803 |  "print('stack status: {}'.format(status))\n", | 
|  | 
| 845 | 854 |  " if status.endswith('COMPLETE'):\n", | 
| 846 | 855 |  " print('Deployment complete\\n')\n", | 
| 847 | 856 |  " break\n", | 
| 848 |  | - " except Exception as e:\n", | 
| 849 |  | - " pass\n", | 
|  | 857 | + " except ClientError as e:\n", | 
|  | 858 | + " print(e.response[\"Error\"][\"Message\"])\n", | 
| 850 | 859 |  " time.sleep(10)" | 
| 851 | 860 |  ] | 
| 852 | 861 |  }, | 
|  | 
| 1033 | 1042 |  "while processing_job_arn == None:\n", | 
| 1034 | 1043 |  " try:\n", | 
| 1035 | 1044 |  " response = sm.list_monitoring_executions(MonitoringScheduleName=schedule_name)\n", | 
| 1036 |  | - " except:\n", | 
| 1037 |  | - " pass\n", | 
|  | 1045 | + " except ClientError as e:\n", | 
|  | 1046 | + " print(e.response[\"Error\"][\"Message\"])\n", | 
| 1038 | 1047 |  " for mon in response['MonitoringExecutionSummaries']:\n", | 
| 1039 | 1048 |  " status = mon['MonitoringExecutionStatus']\n", | 
| 1040 | 1049 |  " now = datetime.now(tzlocal())\n", | 
|  | 
| 1235 | 1244 |  "metadata": {}, | 
| 1236 | 1245 |  "outputs": [], | 
| 1237 | 1246 |  "source": [ | 
| 1238 |  | - "from botocore.exceptions import ClientError\n", | 
| 1239 |  | - "\n", | 
| 1240 | 1247 |  "while True:\n", | 
| 1241 | 1248 |  " try:\n", | 
| 1242 | 1249 |  " response = synth.get_canary(Name=canary_name)\n", | 
|  | 
| 1252 | 1259 |  " if e.response[\"Error\"][\"Code\"] == \"ResourceNotFoundException\":\n", | 
| 1253 | 1260 |  " print('No canary found.')\n", | 
| 1254 | 1261 |  " break\n", | 
| 1255 |  | - " except:\n", | 
| 1256 |  | - " pass\n", | 
|  | 1262 | + " print(e.response[\"Error\"][\"Message\"])\n", | 
| 1257 | 1263 |  " time.sleep(10)\n", | 
| 1258 | 1264 |  "\n", | 
| 1259 | 1265 |  "# Output a html link to the cloudwatch console\n", | 
|  | 
| 1332 | 1338 |  " if e.response[\"Error\"][\"Code\"] == \"ResourceNotFoundException\":\n", | 
| 1333 | 1339 |  " print('Canary succesfully deleted.')\n", | 
| 1334 | 1340 |  " break\n", | 
| 1335 |  | - " except:\n", | 
| 1336 |  | - " pass\n", | 
|  | 1341 | + " print(e.response[\"Error\"][\"Message\"])\n", | 
| 1337 | 1342 |  " time.sleep(10)" | 
| 1338 | 1343 |  ] | 
| 1339 | 1344 |  }, | 
|  | 
| 1370 | 1375 |  "display_name": "conda_python3", | 
| 1371 | 1376 |  "language": "python", | 
| 1372 | 1377 |  "name": "conda_python3" | 
|  | 1378 | + }, | 
|  | 1379 | + "language_info": { | 
|  | 1380 | + "codemirror_mode": { | 
|  | 1381 | + "name": "ipython", | 
|  | 1382 | + "version": 3 | 
|  | 1383 | + }, | 
|  | 1384 | + "file_extension": ".py", | 
|  | 1385 | + "mimetype": "text/x-python", | 
|  | 1386 | + "name": "python", | 
|  | 1387 | + "nbconvert_exporter": "python", | 
|  | 1388 | + "pygments_lexer": "ipython3", | 
|  | 1389 | + "version": "3.6.10" | 
| 1373 | 1390 |  } | 
| 1374 | 1391 |  }, | 
| 1375 | 1392 |  "nbformat": 4, | 
|  | 
0 commit comments