Skip to content

Commit fcec3f8

Browse files
committed
error reporting during lookup of description.
1 parent 55f4bba commit fcec3f8

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

build_cats.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ def cache_lookup(self, url):
3636
if descr is not None and descr != "":
3737
return descr
3838
if url not in DescriptionCache.ignore_set:
39-
print(f"cache_lookup: {url}")
4039
descr = gettitle.get_meta_descr(url)
4140
if descr is not None:
4241
self.map_url_to_descr[url] = descr
@@ -66,6 +65,7 @@ def get_all(self):
6665

6766
cache_lookup_ok = 0
6867
cache_lookup_failed = 0
68+
failed_lookups = []
6969

7070
for entry in json_data:
7171
#print("Category {} SubCategory {}".format(entry.get("c"), entry.get("sc")))
@@ -86,13 +86,18 @@ def get_all(self):
8686

8787
description = self.desc_cache.cache_lookup( url ) #, self.soup_builder )
8888
if description is None or description == "":
89+
print("failed lookup: {url}")
8990
cache_lookup_failed += 1
91+
failed_lookups.append( url )
9092
else:
9193
cache_lookup_ok += 1
9294

9395
entry = (entry.get("t"), entry.get("s"), url, description)
9496
print(f"Cache lookup succeeded: {cache_lookup_ok} failed: {cache_lookup_failed}")
95-
97+
if len(failed_lookups) != 0:
98+
with open("failed_lookups.txt", "w") as failed_lookups:
99+
print("failed lookups:\n", "\n".join(failed_lookups) )
100+
failed_lookups.write("\n".join(failed_lookups))
96101

97102
sub_cat_obj.append(entry)
98103
num_entries = num_entries + 1

mycookiejar.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1297,7 +1297,7 @@ def _cookies_for_request(self, request):
12971297
"""Return a list of cookies to be returned to server."""
12981298
cookies = []
12991299
for domain in self._cookies.keys():
1300-
print(f"dbg: _cookies_for_request cookie domain: {domain}")
1300+
#print(f"dbg: _cookies_for_request cookie domain: {domain}")
13011301
cookies.extend(self._cookies_for_domain(domain, request))
13021302
return cookies
13031303

@@ -1366,7 +1366,7 @@ def add_cookie_header(self, request):
13661366
The Cookie2 header is also added unless policy.hide_cookie2 is true.
13671367
13681368
"""
1369-
print(f"dbg: add_cookie_header request: {repr(request)}")
1369+
#print(f"dbg: add_cookie_header request: {repr(request)}")
13701370

13711371
_debug("add_cookie_header")
13721372
self._cookies_lock.acquire()

0 commit comments

Comments
 (0)