forked from Alucard24/Rope
-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
36 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,37 @@ | ||
from . import download_models | ||
|
||
import requests | ||
from tqdm import tqdm | ||
from pathlib import Path | ||
|
||
def get_filename_from_link(file_link): | ||
return f"models\{file_link.split(r'/')[-1]}" | ||
|
||
def download_file(url): | ||
filename = get_filename_from_link(url) | ||
|
||
if Path(filename).is_file(): | ||
print(f"Skipping {filename} as it is already downloaded ") | ||
else: | ||
print(f"{filename}") | ||
response = requests.get(url, stream=True) | ||
|
||
# Sizes in bytes. | ||
total_size = int(response.headers.get("content-length", 0)) | ||
block_size = 1024 | ||
|
||
with tqdm(total=total_size, unit="B", unit_scale=True) as progress_bar: | ||
with open(filename, "wb") as file: | ||
for data in response.iter_content(block_size): | ||
progress_bar.update(len(data)) | ||
file.write(data) | ||
|
||
if total_size != 0 and progress_bar.n != total_size: | ||
raise RuntimeError("Could not download file") | ||
|
||
#Download required Models | ||
model_links = open("scripts\model_links.txt").read().splitlines() | ||
for link in model_links: | ||
download_file(link) | ||
|
||
''' Additional Functions to execute when updating''' | ||
pass | ||
pass |