git @ Cat's Eye Technologies yastasoti / 1313cca
Various fixes, tentative attempt at introducing logging. Chris Pressey 6 years ago
1 changed file(s) with 9 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
0 #!/usr/bin/env python3
0 #!/usr/bin/env python
11
22 from argparse import ArgumentParser
33 import hashlib
44 import json
5 import logging
56 import os
67 from subprocess import check_call, CalledProcessError
78 import sys
1718 from tqdm import tqdm
1819 except ImportError:
1920 def tqdm(x, **kwargs): return x
21
22
23 logger = logging.getLogger("yastasoti")
2024
2125
2226 def url_to_dirname_and_filename(url):
113117 raise
114118 response = {
115119 "status_code": 600,
116 "error": "{}: {}".format(e.__class__.__name, e)
120 "error": "{}: {}".format(e.__class__.__name__, e)
117121 }
118122 self.results.append({
119123 'response': response,
131135
132136 class LinkChecker(LinkTraverser):
133137 def handle_link(self, url):
134 reponse = requests.head(url)
138 response = requests.head(url)
135139 return {
136140 'status_code': response.status_code
137141 }
174178
175179
176180 def main(args):
181 #logging.basicConfig(level=logging.INFO)
182
177183 argparser = ArgumentParser()
178184
179185 # Checks if the links are resolvable, and optionally downloads a copy of each