fix error in dict and add exception
This commit is contained in:
parent
c1c431cf12
commit
103c8a6605
1 changed files with 12 additions and 3 deletions
|
@ -12,7 +12,6 @@ from logging.handlers import SysLogHandler
|
|||
import sqlite3
|
||||
import time
|
||||
import re
|
||||
import json
|
||||
import click
|
||||
import click_config_file
|
||||
import requests
|
||||
|
@ -83,7 +82,7 @@ class DiscoverMastodonServers:
|
|||
self._log.debug(
|
||||
"Server '%s' didn't return Content-Type header. Headers: '%s'. Content returned: '%s'",
|
||||
server['name'],
|
||||
json.dumps(result.headers, indent=2),
|
||||
result.headers,
|
||||
result.content
|
||||
)
|
||||
else:
|
||||
|
@ -119,6 +118,14 @@ class DiscoverMastodonServers:
|
|||
server['name'],
|
||||
error
|
||||
)
|
||||
except Exception as error:
|
||||
server['state'] = 'Error'
|
||||
self._log.warning(
|
||||
"Error fetching endpoint '%s' from server '%s'. %s",
|
||||
endpoint,
|
||||
server['name'],
|
||||
error
|
||||
)
|
||||
return data
|
||||
|
||||
def get_instance_info(self, server):
|
||||
|
@ -189,7 +196,7 @@ class DiscoverMastodonServers:
|
|||
}
|
||||
)
|
||||
else:
|
||||
server[1]['peers'] = False
|
||||
server['peers'] = False
|
||||
self._log.debug("Fetching public timeline in server '%s'", server_name)
|
||||
data = self.get_timeline(server)
|
||||
if data:
|
||||
|
@ -233,6 +240,8 @@ class DiscoverMastodonServers:
|
|||
record['peers'] = True
|
||||
if 'timeline' not in record:
|
||||
record['timeline'] = True
|
||||
if 'last_update' not in record:
|
||||
record['last_update'] = time.time()
|
||||
cur = self.conn.cursor()
|
||||
result_select = cur.execute(f"""
|
||||
SELECT name FROM {table} WHERE name = '{record['name']}'
|
||||
|
|
Loading…
Reference in a new issue