UNCLASSIFIED

Commit 7a7bbea7 authored by Ian Dunbar-Hall's avatar Ian Dunbar-Hall
Browse files

finishing hello typing

parent c75a5774
...@@ -13,6 +13,7 @@ from datetime import timezone ...@@ -13,6 +13,7 @@ from datetime import timezone
from datetime import timedelta from datetime import timedelta
from time import sleep from time import sleep
from dateutil.parser import parse from dateutil.parser import parse
from typing import Dict
import bs4 as bs # type: ignore import bs4 as bs # type: ignore
...@@ -20,14 +21,14 @@ from dcar.request import Session ...@@ -20,14 +21,14 @@ from dcar.request import Session
from dcar.utils import validate_argument from dcar.utils import validate_argument
def website_find_all(session): def website_find_all(session) -> dict:
""" """
This function uses the DCAR website and python beautiful soup to collect This function uses the DCAR website and python beautiful soup to collect
metadata. metadata.
""" """
validate_argument("session", session, Session) validate_argument("session", session, Session)
image_details_dict = {} image_details_dict: Dict[str, Dict] ={}
vendor_level_request = session.get("/") vendor_level_request = session.get("/")
vendor_level_page = bs.BeautifulSoup(vendor_level_request.content, 'html.parser') vendor_level_page = bs.BeautifulSoup(vendor_level_request.content, 'html.parser')
...@@ -104,7 +105,7 @@ def website_find_all(session): ...@@ -104,7 +105,7 @@ def website_find_all(session):
def compare_image(registry_image_name: str, registry_user: str, registry_password: str, def compare_image(registry_image_name: str, registry_user: str, registry_password: str,
image_details: dict, acceptable_image_delta_min: int = 10): image_details: dict, acceptable_image_delta_min: int = 10) -> bool:
""" """
This function compares DCAR image data to a container image on a registry. This function compares DCAR image data to a container image on a registry.
""" """
...@@ -137,7 +138,7 @@ def compare_image(registry_image_name: str, registry_user: str, registry_passwor ...@@ -137,7 +138,7 @@ def compare_image(registry_image_name: str, registry_user: str, registry_passwor
def mirror_image(session, registry_image_name: str, registry_user: str, registry_password: str, def mirror_image(session, registry_image_name: str, registry_user: str, registry_password: str,
image_name: str, image_details: dict, push_w_docker: bool, max_retries: int = 3): image_name: str, image_details: dict, push_w_docker: bool, max_retries: int = 3) -> bool:
""" """
This function takes DCAR image data and will download push an image to a container registry. This function takes DCAR image data and will download push an image to a container registry.
""" """
......
...@@ -4,8 +4,8 @@ detect DCAR SSO. ...@@ -4,8 +4,8 @@ detect DCAR SSO.
""" """
from time import sleep from time import sleep
from requests import session, Response
import requests
import bs4 as bs # type: ignore import bs4 as bs # type: ignore
import pyotp # type: ignore import pyotp # type: ignore
...@@ -23,7 +23,7 @@ class Session: ...@@ -23,7 +23,7 @@ class Session:
validate_argument("password", password, str) validate_argument("password", password, str)
validate_argument("totp_seed", totp_seed, str) validate_argument("totp_seed", totp_seed, str)
self.session = requests.session() self.session = session()
self.username = username self.username = username
self.password = password self.password = password
self.totp_seed = totp_seed.replace(" ", "") self.totp_seed = totp_seed.replace(" ", "")
...@@ -56,7 +56,8 @@ class Session: ...@@ -56,7 +56,8 @@ class Session:
raise LoginError() raise LoginError()
def get(self, path: str, stream: bool = False, verify: bool = False, max_retries: int = 10, def get(self, path: str, stream: bool = False, verify: bool = False, max_retries: int = 10,
retry_sleep: int = 10, dcar_url: str = "https://dcar.dsop.io", sso_url: str = "https://sso.dsop.io"): retry_sleep: int = 10, dcar_url: str = "https://dcar.dsop.io",
sso_url: str = "https://sso.dsop.io") -> Response:
""" """
Wrapper method for the requests.get() method. This method Wrapper method for the requests.get() method. This method
will check if the request was redirected to DCAR SSO. If will check if the request was redirected to DCAR SSO. If
......
...@@ -5,7 +5,8 @@ This module contains random utility functions. ...@@ -5,7 +5,8 @@ This module contains random utility functions.
import os import os
from jinja2 import Template from jinja2 import Template
def populate_image_name(template_string: str, vendor: str, product: str, image: str, tag: str): def populate_image_name(template_string: str, vendor: str, product: str,
image: str, tag: str) -> str:
""" """
Utility function to populate a templated string for a container image Utility function to populate a templated string for a container image
name. name.
......
""" """
Module for unit testing the dcar.request module. Module for unit testing the dcar.request module.
""" """
import pytest import pytest # type: ignore
from dcar.request import Session, LoginError from dcar.request import Session, LoginError
class MockResponse: class MockResponse:
......
""" """
Module for unit testing the dcar.utils module. Module for unit testing the dcar.utils module.
""" """
import pytest import pytest # type: ignore
from dcar.utils import populate_image_name, check_envs from dcar.utils import populate_image_name, check_envs
......
...@@ -7,7 +7,7 @@ Example: ...@@ -7,7 +7,7 @@ Example:
""" """
import os import os
import pyotp import pyotp # type: ignore
from dcar.utils import check_envs from dcar.utils import check_envs
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment