-
Notifications
You must be signed in to change notification settings - Fork 1
Sourcery refactored master branch #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -50,7 +50,6 @@ def delete_items(aws_creds): | |
| f"Failed to Remove {policy_arn} from Profile {role.name} - skipping ", | ||
| e, | ||
| ) | ||
| pass | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
| else: | ||
| print(f"Removed {policy_arn} from Profile {role.name} OK") | ||
|
|
||
|
|
@@ -67,7 +66,6 @@ def delete_items(aws_creds): | |
| f"Failed to Remove {rolename} from Profile {inst_prof} - skipping ", | ||
| e, | ||
| ) | ||
| pass | ||
| else: | ||
| print(f"Removed Role {rolename} from Profile {inst_prof} OK") | ||
|
|
||
|
|
@@ -77,7 +75,6 @@ def delete_items(aws_creds): | |
| print(f"Role {role.name} does not exist at all") | ||
| except Exception as e: | ||
| print(f"Failed to Delete Role {role.name} - skipping -", e) | ||
| pass | ||
| else: | ||
| print(f"Deleted Instance Role {role.name} OK") | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -64,7 +64,6 @@ def vpc_delete(vpcid, aws_creds): | |
| print( | ||
| f"SG {sec_group['GroupName']} {sec_group['GroupId']} does not have a group dependancy" | ||
| ) | ||
| pass | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
| else: | ||
| print( | ||
| f"SG {sec_group['GroupName']} {sec_group['GroupId']} has a " | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,8 +25,6 @@ def main(aws_creds): | |
| name = "No Name Set" | ||
| except Exception as e: | ||
| print(type(e), e) | ||
| else: | ||
| pass | ||
|
Comment on lines
-28
to
-29
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
| finally: | ||
| print(vpcid, name) | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -99,10 +99,7 @@ def my_create_vpc(self, tagged=True): | |
| except Exception: | ||
| raise | ||
| else: | ||
| if self.tagged: | ||
| return self.message + "and tagged OK" | ||
| else: | ||
| return self.message + "OK" | ||
| return f"{self.message}and tagged OK" if self.tagged else f"{self.message}OK" | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
|
||
| def my_create_subnet(self, subnet_bundle): | ||
| """ Create Subnets in precise Availability Zones """ | ||
|
|
@@ -268,7 +265,6 @@ def my_create_instance_profile(self, inst_prof_name): | |
| self.iam_client.create_instance_profile(InstanceProfileName=inst_prof_name) | ||
| except self.iam_client.exceptions.EntityAlreadyExistsException: | ||
| print(f"IP: Instance Profle {inst_prof_name} Already Exists -- skipping") | ||
| pass | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
| except Exception as e: | ||
| print("IP: Inst prof problem ", e) | ||
| else: | ||
|
|
@@ -289,10 +285,8 @@ def my_create_app_role(self, app_role_name, app_role_file): | |
| ) | ||
| except self.iam_client.exceptions.EntityAlreadyExistsException: | ||
| print(f"AR: App role {app_role_name} Already Exists -- skipping") | ||
| pass | ||
| except Exception as e: | ||
| print("AR: App Role problem - Still need to insert to Inst Prof", e) | ||
| pass | ||
|
Comment on lines
-292
to
-295
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
| else: | ||
| print(f"AR: App role {app_role_name} Created OK") | ||
|
|
||
|
|
@@ -302,7 +296,6 @@ def my_create_app_role(self, app_role_name, app_role_file): | |
| ) | ||
| except self.iam_client.exceptions.LimitExceededException: | ||
| print(f"AR: {inst_prof_name} already has a Role -- Skipping") | ||
| pass | ||
| except Exception as e: | ||
| print( | ||
| "AR: Problem adding role {app_role_name} to instance profile {inst_prof_name} ", | ||
|
|
@@ -330,7 +323,6 @@ def my_create_policy(self, policy_name, policy_file, policy_desc): | |
|
|
||
| except self.iam_client.exceptions.EntityAlreadyExistsException: | ||
| print(f"PL: Policy {policy_name} Already exists -- skipping") | ||
| pass | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
| except Exception as e: | ||
| print("PL: Policy Creation problem ", e) | ||
| else: | ||
|
|
@@ -365,7 +357,6 @@ def my_create_log_groups(self, log_group_name): | |
| self.logs_client.create_log_group(logGroupName=log_group_name) | ||
| except self.logs_client.exceptions.ResourceAlreadyExistsException: | ||
| print(f"LG: Log Group {log_group_name} Already Exists -- skipping") | ||
| pass | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
| except Exception as e: | ||
| print("LG: Log Group problem ", e) | ||
| else: | ||
|
|
@@ -440,7 +431,6 @@ def my_create_t_a_p_group(self, auto_scaling_bundle, subnet_bundles): | |
|
|
||
| except self.elbv2_client.exceptions.DuplicateTargetGroupNameException: | ||
| print("TG: Target Group Exists Already -- skipping") | ||
| pass | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
| except Exception: | ||
| raise | ||
| else: | ||
|
|
@@ -456,7 +446,7 @@ def my_create_load_balancer(self, randomAS=False): | |
|
|
||
| if randomAS: | ||
| """ We randomly choose the Target / ASGroup """ | ||
| FirstTg_Group = random.choice([x for x in self.target_groups.keys()]) | ||
| FirstTg_Group = random.choice(list(self.target_groups.keys())) | ||
|
Comment on lines
-459
to
+449
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
| else: | ||
| FirstTg_Group = "Target-GRP-Auto-Scale-GREEN" | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -43,13 +43,9 @@ def get_secret(secret_name, region_name): | |
| # Decrypts secret using the associated KMS CMK. | ||
| # Depending on whether the secret is a string or binary, one of these fields will be populated. | ||
| if "SecretString" in get_secret_value_response: | ||
| secret = get_secret_value_response["SecretString"] | ||
| return secret | ||
| return get_secret_value_response["SecretString"] | ||
| else: | ||
| decoded_binary_secret = base64.b64decode( | ||
| get_secret_value_response["SecretBinary"] | ||
| ) | ||
| return decoded_binary_secret | ||
| return base64.b64decode(get_secret_value_response["SecretBinary"]) | ||
|
Comment on lines
-46
to
+48
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lines
17-17refactored with the following changes:use-fstring-for-concatenation)