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 sqlite3
|
||||||
import time
|
import time
|
||||||
import re
|
import re
|
||||||
import json
|
|
||||||
import click
|
import click
|
||||||
import click_config_file
|
import click_config_file
|
||||||
import requests
|
import requests
|
||||||
|
@ -83,7 +82,7 @@ class DiscoverMastodonServers:
|
||||||
self._log.debug(
|
self._log.debug(
|
||||||
"Server '%s' didn't return Content-Type header. Headers: '%s'. Content returned: '%s'",
|
"Server '%s' didn't return Content-Type header. Headers: '%s'. Content returned: '%s'",
|
||||||
server['name'],
|
server['name'],
|
||||||
json.dumps(result.headers, indent=2),
|
result.headers,
|
||||||
result.content
|
result.content
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
|
@ -119,6 +118,14 @@ class DiscoverMastodonServers:
|
||||||
server['name'],
|
server['name'],
|
||||||
error
|
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
|
return data
|
||||||
|
|
||||||
def get_instance_info(self, server):
|
def get_instance_info(self, server):
|
||||||
|
@ -189,7 +196,7 @@ class DiscoverMastodonServers:
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
server[1]['peers'] = False
|
server['peers'] = False
|
||||||
self._log.debug("Fetching public timeline in server '%s'", server_name)
|
self._log.debug("Fetching public timeline in server '%s'", server_name)
|
||||||
data = self.get_timeline(server)
|
data = self.get_timeline(server)
|
||||||
if data:
|
if data:
|
||||||
|
@ -233,6 +240,8 @@ class DiscoverMastodonServers:
|
||||||
record['peers'] = True
|
record['peers'] = True
|
||||||
if 'timeline' not in record:
|
if 'timeline' not in record:
|
||||||
record['timeline'] = True
|
record['timeline'] = True
|
||||||
|
if 'last_update' not in record:
|
||||||
|
record['last_update'] = time.time()
|
||||||
cur = self.conn.cursor()
|
cur = self.conn.cursor()
|
||||||
result_select = cur.execute(f"""
|
result_select = cur.execute(f"""
|
||||||
SELECT name FROM {table} WHERE name = '{record['name']}'
|
SELECT name FROM {table} WHERE name = '{record['name']}'
|
||||||
|
|
Loading…
Reference in a new issue