Add remove bad CRL files from the tmp download dir
This commit is contained in:
parent
fd13c981dd
commit
d656229879
@ -28,16 +28,22 @@ def crl_list_from_disa_html(html):
|
|||||||
parser.feed(html)
|
parser.feed(html)
|
||||||
return parser.crl_list
|
return parser.crl_list
|
||||||
|
|
||||||
|
def crl_local_path(out_dir, crl_location):
|
||||||
def write_crl(out_dir, crl_location):
|
|
||||||
name = re.split("/", crl_location)[-1]
|
name = re.split("/", crl_location)[-1]
|
||||||
crl = os.path.join(out_dir, name)
|
crl = os.path.join(out_dir, name)
|
||||||
|
return crl
|
||||||
|
|
||||||
|
def write_crl(out_dir, crl_location):
|
||||||
|
crl = crl_local_path(out_dir, crl_location)
|
||||||
with requests.get(crl_location, stream=True) as r:
|
with requests.get(crl_location, stream=True) as r:
|
||||||
with open(crl, "wb") as crl_file:
|
with open(crl, "wb") as crl_file:
|
||||||
for chunk in r.iter_content(chunk_size=1024):
|
for chunk in r.iter_content(chunk_size=1024):
|
||||||
if chunk:
|
if chunk:
|
||||||
crl_file.write(chunk)
|
crl_file.write(chunk)
|
||||||
|
|
||||||
|
def remove_bad_crl(out_dir, crl_location):
|
||||||
|
crl = crl_local_path(out_dir, crl_location)
|
||||||
|
os.remove(crl)
|
||||||
|
|
||||||
def refresh_crls(out_dir, logger=None):
|
def refresh_crls(out_dir, logger=None):
|
||||||
disa_html = fetch_disa()
|
disa_html = fetch_disa()
|
||||||
@ -52,6 +58,7 @@ def refresh_crls(out_dir, logger=None):
|
|||||||
logger.error(
|
logger.error(
|
||||||
"Error downloading {}, continuing anyway".format(crl_location)
|
"Error downloading {}, continuing anyway".format(crl_location)
|
||||||
)
|
)
|
||||||
|
remove_bad_crl(out_dir, crl_location)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
Loading…
x
Reference in New Issue
Block a user