first functional commit

This commit is contained in:
Pin
2022-10-02 12:31:34 -04:00
parent d367398766
commit 46d46a4e36
52 changed files with 1216 additions and 0 deletions

39
src/main.py Normal file
View File

@@ -0,0 +1,39 @@
#!/usr/bin/python3
import os
import requests
from clint.textui import progress
def downloadArtifact(artifactURL: str, downloadPath: str):
print("holding")
def downloadImage(imageURL: str):
createDownloadFolder()
# Obtain last segment of URL for file name
fileName = imageURL.split("/")[-1]
if not os.path.exists("download/" + fileName):
print("Downloading - {}".format(imageURL))
r = requests.get(imageURL, stream=True)
with open("download/" + fileName, "wb") as fd:
totalLength = int(r.headers.get('content-length'))
for ch in progress.bar(r.iter_content(chunk_size = 2048), expected_size=(totalLength/2048)):
if ch:
fd.write(ch)
fd.close()
return
def createDownloadFolder():
if not os.path.isdir("download"):
os.mkdir("download")
return
#downloadImage("https://cloud.centos.org/centos/7/images/CentOS-7-x86_64-GenericCloud.qcow2")
#downloadImage("https://cloud-images.ubuntu.com/jammy/current/jammy-server-cloudimg-amd64.img")
#downloadImage("https://cloud-images.ubuntu.com/releases/focal/release/ubuntu-20.04-server-cloudimg-amd64.img")
downloadImage("http://file.pinfosec.local/file/vm-images/CentOS-7-x86_64-GenericCloud.qcow2")
downloadImage("http://file.pinfosec.local/file/vm-images/jammy-server-cloudimg-amd64.img")
downloadImage("http://file.pinfosec.local/file/vm-images/ubuntu-20.04-server-cloudimg-amd64.img")