Skip to content

Commit

Permalink
Changes updated
Browse files Browse the repository at this point in the history
Signed-off-by: Divya Madala <[email protected]>
  • Loading branch information
Divyaasm committed Nov 11, 2022
1 parent 6fdf7c3 commit 9011dc0
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 17 deletions.
7 changes: 4 additions & 3 deletions src/validation_workflow/download_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ def is_url_valid(url: str) -> int:

@staticmethod
def download(url: str, tmp_dir: TemporaryDirectory) -> bool:
response = requests.get(url, stream=True) # get() method sends a GET request to the url
# This method writes the contents from the response object into temporary directory file name fetched from the end of the url.
response = requests.get(url, stream=True)
path = tmp_dir.name + "/" + url.split("/")[-1]
val = bool(open(path, "wb").write(response.content)) # writes the contents from the response object into temporary directory file name fetched from the end of the url
return val
status = bool(open(path, "wb").write(response.content))
return status
2 changes: 1 addition & 1 deletion src/validation_workflow/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@


class Validation(ABC):
url = "https://artifacts.opensearch.org/releases/bundle/"
base_url = "https://artifacts.opensearch.org/releases/bundle/"

def __init__(self, version: str, distribution: str, platform: str, projects: list) -> None:
self.version = version
Expand Down
2 changes: 1 addition & 1 deletion src/validation_workflow/validation_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class ValidationArgs:
version: str

def __init__(self) -> None:
parser = argparse.ArgumentParser(description="Download Artifacts.")
parser = argparse.ArgumentParser(description="Validation Framework for Validation Workflow.")
parser.add_argument(
"version",
type=str,
Expand Down
8 changes: 4 additions & 4 deletions src/validation_workflow/validation_rpm.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@


class ValidationRpm(Validation, DownloadUtils):
tmp_dir = TemporaryDirectory()

@classmethod
def download_artifacts(self, projects: list, version: str, platform: str, architectures: list) -> bool:
tmp_dir = TemporaryDirectory()
for project in projects:
for architecture in architectures:
url = f"{self.url}{project}/{version}/{project}-{version}-{platform}-{architecture}.rpm"
if ValidationRpm.is_url_valid(url) and ValidationRpm.download(url, tmp_dir):
url = f"{self.base_url}{project}/{version}/{project}-{version}-{platform}-{architecture}.rpm"
if ValidationRpm.is_url_valid(url) and ValidationRpm.download(url, self.tmp_dir):
logging.info(f" Valid URL - {url} and Download Successful !")
else:
logging.info(f"Invalid URL - {url}")
raise Exception("Invalid url - check version")
raise Exception(f"Invalid url - {url}")
return True
8 changes: 4 additions & 4 deletions src/validation_workflow/validation_tar.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@


class ValidationTar(Validation, DownloadUtils):
tmp_dir = TemporaryDirectory()

@classmethod
def download_artifacts(self, projects: list, version: str, platform: str, architectures: list) -> bool:
tmp_dir = TemporaryDirectory()
for project in projects:
for architecture in architectures:
url = f"{self.url}{project}/{version}/{project}-{version}-{platform}-{architecture}.tar.gz"
if ValidationTar.is_url_valid(url) and ValidationTar.download(url, tmp_dir):
url = f"{self.base_url}{project}/{version}/{project}-{version}-{platform}-{architecture}.tar.gz"
if ValidationTar.is_url_valid(url) and ValidationTar.download(url, self.tmp_dir):
logging.info(f" Valid URL - {url} and Download Successful !")
else:
logging.info(f"Invalid URL - {url}")
raise Exception("Invalid url - check version")
raise Exception(f"Invalid url - {url}")
return True
8 changes: 4 additions & 4 deletions src/validation_workflow/validation_yum.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@


class ValidationYum(Validation, DownloadUtils):
tmp_dir = TemporaryDirectory()

@classmethod
def download_artifacts(self, projects: list, version: str, platform: str, architectures: list) -> bool:
tmp_dir = TemporaryDirectory()
for project in projects:
url = f"{self.url}{project}/{version[0:1]}.x/{project}-{version[0:1]}.x.repo"
if ValidationYum.is_url_valid(url) and ValidationYum.download(url, tmp_dir):
url = f"{self.base_url}{project}/{version[0:1]}.x/{project}-{version[0:1]}.x.repo"
if ValidationYum.is_url_valid(url) and ValidationYum.download(url, self.tmp_dir):
logging.info(f" Valid URL - {url} and Download Successful !")
else:
logging.info(f"Invalid URL - {url}")
raise Exception("Invalid url - check version")
raise Exception(f"Invalid url - {url}")
return True

0 comments on commit 9011dc0

Please sign in to comment.