tested for http requests (404s)
This commit is contained in:
parent
9905a15ace
commit
d8c4cb47fa
@ -1,4 +1,5 @@
|
||||
latestpage="result.html"
|
||||
# latestpage="result.html"
|
||||
latestpages=["meta.json", "result.html"]
|
||||
|
||||
[page]
|
||||
postsperpage = 20
|
||||
|
29
microblog.py
29
microblog.py
@ -374,24 +374,27 @@ if __name__ == "__main__":
|
||||
print(json.dumps(profile), file=f)
|
||||
|
||||
import urllib.request as http
|
||||
def fn1(config): # come up with better name later
|
||||
def fn1(webring_config): # come up with better name later
|
||||
def fetch(follow_list):
|
||||
oither_people = []
|
||||
other_people = []
|
||||
for someone in follow_list:
|
||||
try:
|
||||
with http.urlopen(someone) as response:
|
||||
data = response.read()
|
||||
objects.append(json.loads(data))
|
||||
except urllib.error.HTTPError:
|
||||
print("http error - skipping", file=sys.stderr)
|
||||
except http.HTTPError as e:
|
||||
print(e,": ", someone, file=sys.stderr)
|
||||
pass
|
||||
return other_people
|
||||
list_of_json_objs = []
|
||||
with open("meta.json",'r') as f:
|
||||
list_of_json_objs.append(json.loads(f.read()))
|
||||
# list_of_json_obj = fetch(config["profile"]["following"])
|
||||
# list_of_json_objs = []
|
||||
# with open("meta.json",'r') as f:
|
||||
# list_of_json_objs.append(json.loads(f.read()))
|
||||
list_of_json_objs = fetch(webring_config["list"])
|
||||
if list_of_json_objs == []:
|
||||
print("no remote profiles loaded", file=sys.stderr)
|
||||
return []
|
||||
rendered = []
|
||||
template = config["format"]
|
||||
template = webring_config["format"]
|
||||
SHORT_BIO_LIMIT = 150
|
||||
for profile in list_of_json_objs:
|
||||
epoch_timestamp = profile["last-updated"]
|
||||
@ -456,13 +459,17 @@ if __name__ == "__main__":
|
||||
len(p), p[0].get_epoch_time(), cfg["webring"] )
|
||||
if "following" in cfg["webring"]:
|
||||
fellows = fn1(cfg["webring"]["following"] )
|
||||
updated += writepage(
|
||||
tpl, fellows, tc, cfg["page"], subdir="placeholder" )
|
||||
if fellows != []:
|
||||
updated += writepage(
|
||||
tpl, fellows, tc, cfg["page"], subdir="placeholder" )
|
||||
with open("updatedfiles.txt", 'w') as f:
|
||||
for filename in updated:
|
||||
print(filename, file=f) # sys.stderr)
|
||||
if "latestpage" in cfg:
|
||||
print(cfg["latestpage"], file=f)
|
||||
if "latestpages" in cfg:
|
||||
for page in cfg["latestpages"]:
|
||||
print(page, file=f)
|
||||
try:
|
||||
main()
|
||||
except KeyError as e:
|
||||
|
Loading…
x
Reference in New Issue
Block a user