update DB

update scanner.py
This commit is contained in:
Dr.Lt.Data
2024-06-16 13:54:53 +09:00
parent 4811f429b8
commit c60492d275
7 changed files with 132 additions and 22 deletions

View File

@@ -3,9 +3,10 @@ import re
import os
import json
from git import Repo
from torchvision.datasets.utils import download_url
import concurrent
import datetime
import concurrent.futures
import requests
builtin_nodes = set()
@@ -15,6 +16,29 @@ from urllib.parse import urlparse
from github import Github
def download_url(url, dest_folder, filename=None):
# Ensure the destination folder exists
if not os.path.exists(dest_folder):
os.makedirs(dest_folder)
# Extract filename from URL if not provided
if filename is None:
filename = os.path.basename(url)
# Full path to save the file
dest_path = os.path.join(dest_folder, filename)
# Download the file
response = requests.get(url, stream=True)
if response.status_code == 200:
with open(dest_path, 'wb') as file:
for chunk in response.iter_content(chunk_size=1024):
if chunk:
file.write(chunk)
else:
raise Exception(f"Failed to download file from {url}")
# prepare temp dir
if len(sys.argv) > 1:
temp_dir = sys.argv[1]