import subprocess
import sys
import requests # URL checking
+from multiprocessing import Pool
INFRA_RE = re.compile("\$\(eval \$\(([a-z-]*)-package\)\)")
URL_RE = re.compile("\s*https?://\S*\s*$")
self.current_version = None
self.url = None
self.url_status = None
+ self.url_worker = None
def pkgvar(self):
return self.name.upper().replace("-", "_")
Package.all_versions[pkgvar] = value
-def check_url_status(pkg):
- if pkg.url_status != "Missing" and pkg.url_status != "No Config.in":
+def check_url_status_worker(url, url_status):
+ if url_status != "Missing" and url_status != "No Config.in":
try:
- url_status_code = requests.head(pkg.url, timeout=5).status_code
+ url_status_code = requests.head(url, timeout=30).status_code
if url_status_code >= 400:
- pkg.url_status = "Invalid(%s)" % str(url_status_code)
+ return "Invalid(%s)" % str(url_status_code)
except requests.exceptions.RequestException:
- return
+ return "Invalid(Err)"
+ return "Ok"
+ return url_status
+
+
+def check_package_urls(packages):
+ Package.pool = Pool(processes=64)
+ for pkg in packages:
+ pkg.url_worker = pkg.pool.apply_async(check_url_status_worker, (pkg.url, pkg.url_status))
+ for pkg in packages:
+ pkg.url_status = pkg.url_worker.get(timeout=3600)
def calculate_stats(packages):
pkg.set_check_package_warnings()
pkg.set_current_version()
pkg.set_url()
- check_url_status(pkg)
+ print("Checking URL status")
+ check_package_urls(packages)
print("Calculate stats")
stats = calculate_stats(packages)
print("Write HTML")