Various fixes, tentative attempt at introducing logging.
Chris Pressey
6 years ago
0 | #!/usr/bin/env python3 | |
0 | #!/usr/bin/env python | |
1 | 1 | |
2 | 2 | from argparse import ArgumentParser |
3 | 3 | import hashlib |
4 | 4 | import json |
5 | import logging | |
5 | 6 | import os |
6 | 7 | from subprocess import check_call, CalledProcessError |
7 | 8 | import sys |
17 | 18 | from tqdm import tqdm |
18 | 19 | except ImportError: |
19 | 20 | def tqdm(x, **kwargs): return x |
21 | ||
22 | ||
23 | logger = logging.getLogger("yastasoti") | |
20 | 24 | |
21 | 25 | |
22 | 26 | def url_to_dirname_and_filename(url): |
113 | 117 | raise |
114 | 118 | response = { |
115 | 119 | "status_code": 600, |
116 | "error": "{}: {}".format(e.__class__.__name, e) | |
120 | "error": "{}: {}".format(e.__class__.__name__, e) | |
117 | 121 | } |
118 | 122 | self.results.append({ |
119 | 123 | 'response': response, |
131 | 135 | |
132 | 136 | class LinkChecker(LinkTraverser): |
133 | 137 | def handle_link(self, url): |
134 | reponse = requests.head(url) | |
138 | response = requests.head(url) | |
135 | 139 | return { |
136 | 140 | 'status_code': response.status_code |
137 | 141 | } |
174 | 178 | |
175 | 179 | |
176 | 180 | def main(args): |
181 | #logging.basicConfig(level=logging.INFO) | |
182 | ||
177 | 183 | argparser = ArgumentParser() |
178 | 184 | |
179 | 185 | # Checks if the links are resolvable, and optionally downloads a copy of each |