Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
blink1073 committed Oct 28, 2024
1 parent f1fc0e7 commit cea141b
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 24 deletions.
8 changes: 3 additions & 5 deletions .evergreen/auth_aws/lib/aws_assign_instance_profile.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
#!/usr/bin/env python3
"""
Script for assign an instance policy to the current machine.
"""

import argparse
import urllib.request
import logging
import json
import logging
import os
import sys
import time
import urllib.request
from functools import partial

import boto3
import botocore

from util import get_key as _get_key

sys.path.insert(1, os.path.join(sys.path[0], '..'))
Expand All @@ -41,7 +39,7 @@ def _has_instance_profile():
try:
url = base_url + iam_role
print("Reading: " + url)
req = urllib.request.urlopen(url)
urllib.request.urlopen(url)
print("Assigned " + iam_role)
except urllib.error.HTTPError as e:
print(e)
Expand Down
3 changes: 1 addition & 2 deletions .evergreen/auth_aws/lib/aws_assume_role.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
#!/usr/bin/env python3
"""
Script for assuming an aws role.
"""

import argparse
import uuid
import logging
import uuid

import boto3

Expand Down
3 changes: 1 addition & 2 deletions .evergreen/auth_aws/lib/aws_assume_web_role.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
#!/usr/bin/env python3
"""
Script for assuming an aws role using AssumeRoleWithWebIdentity.
"""

import argparse
import logging
import os
import uuid
import logging

import boto3

Expand Down
5 changes: 1 addition & 4 deletions .evergreen/auth_aws/lib/aws_handle_oidc_creds.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/usr/bin/env python3
"""
Script for handling OIDC credentials.
"""
Expand All @@ -15,7 +14,6 @@
from pyop.userinfo import Userinfo



class CustomSubjectIdentifierFactory(HashBasedSubjectIdentifierFactory):
"""
Implements a hash based algorithm for creating a pairwise subject identifier.
Expand All @@ -33,7 +31,7 @@ def create_pairwise_identifier(self, user_id, sector_identifier):


def get_default_config():
config = {
return {
"issuer": os.getenv('IDP_ISSUER', ''),
"jwks_uri": os.getenv('IDP_JWKS_URI', ''),
'rsa_key': os.getenv('IDP_RSA_KEY', ''),
Expand All @@ -42,7 +40,6 @@ def get_default_config():
'username': os.getenv("IDP_USERNAME", 'test_user'),
'token_file': os.getenv('AWS_WEB_IDENTITY_TOKEN_FILE')
}
return config


def get_provider(config=None, expires=None):
Expand Down
7 changes: 3 additions & 4 deletions .evergreen/auth_aws/lib/aws_unassign_instance_profile.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
#!/usr/bin/env python3
"""
Script for unassigning an instance policy from the current machine.
"""

import argparse
import urllib.error
import urllib.request
import logging
import sys
import time
import urllib.error
import urllib.request

import boto3
import botocore
Expand All @@ -32,7 +31,7 @@ def _has_instance_profile():
try:
url = base_url + iam_role
print("Reading: " + url)
req = urllib.request.urlopen(url)
urllib.request.urlopen(url)
except urllib.error.HTTPError as e:
print(e)
if e.code == 404:
Expand Down
9 changes: 4 additions & 5 deletions .evergreen/auth_aws/lib/container_tester.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/usr/bin/env python3
"""
Script for testing mongodb in containers.
Expand Down Expand Up @@ -41,7 +40,7 @@

def _run_process(params, cwd=None):
LOGGER.info("RUNNING COMMAND: %s", params)
ret = subprocess.run(params, cwd=cwd)
ret = subprocess.run(params, cwd=cwd, check=False)
return ret.returncode

def _userandhostandport(endpoint):
Expand Down Expand Up @@ -137,7 +136,7 @@ def remote_ps_container(cluster):
assert private_ip_address

eni = ec2_client.describe_network_interfaces(NetworkInterfaceIds=enis)
public_ip = [n["Association"]["PublicIp"] for n in eni["NetworkInterfaces"]][0]
public_ip = next(iter(n["Association"]["PublicIp"] for n in eni["NetworkInterfaces"]))

for container in task['containers']:
taskArn = container['taskArn']
Expand All @@ -146,7 +145,7 @@ def remote_ps_container(cluster):
task_id = task_id + "/" + name
lastStatus = container['lastStatus']

print("{:<43}{:<9}{:<25}{:<25}{:<16}".format(task_id, lastStatus, public_ip, private_ip_address, taskDefinition_short ))
print(f"{task_id:<43}{lastStatus:<9}{public_ip:<25}{private_ip_address:<25}{taskDefinition_short:<16}")

def _remote_create_container_args(args):
remote_create_container(args.cluster, args.task_definition, args.service, args.subnets, args.security_group)
Expand Down Expand Up @@ -247,7 +246,7 @@ def remote_get_public_endpoint_str(cluster, service_name):
assert enis

eni = ec2_client.describe_network_interfaces(NetworkInterfaceIds=enis)
public_ip = [n["Association"]["PublicIp"] for n in eni["NetworkInterfaces"]][0]
public_ip = next(iter(n["Association"]["PublicIp"] for n in eni["NetworkInterfaces"]))
break

return f"root@{public_ip}:22"
Expand Down
3 changes: 1 addition & 2 deletions .evergreen/auth_aws/lib/util.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
def get_key(key: str, uppercase: bool) -> str:
if uppercase:
return key.upper()
else:
return key
return key

0 comments on commit cea141b

Please sign in to comment.