Commit 20f34867 authored by Romain Courteaud's avatar Romain Courteaud

Do not loop by default.

parent 7479fca7
......@@ -26,7 +26,7 @@ class BotError(Exception):
class WebBot:
def __init__(self):
self.config = configparser.ConfigParser(empty_lines_in_values=False)
self.config[CONFIG_SECTION] = {"INTERVAL": 60}
self.config[CONFIG_SECTION] = {"INTERVAL": -1}
def initDB(self, sqlite_path):
self._db = LogDB(sqlite_path)
......@@ -98,7 +98,12 @@ class WebBot:
# Get the list of available IPv4 frontend CDN
hostname = parsed_url.hostname
dns_info_list = socket.getaddrinfo(hostname, "http", socket.AF_INET)
try:
dns_info_list = socket.getaddrinfo(
hostname, "http", socket.AF_INET
)
except socket.gaierror:
dns_info_list = []
ip_list = [x[4][0] for x in dns_info_list]
for ip in ip_list:
......@@ -149,8 +154,8 @@ class WebBot:
u = miniupnpc.UPnP()
u.discoverdelay = 200
u.discover()
u.selectigd()
try:
u.selectigd()
print("external ip: {}".format(u.externalipaddress()))
except Exception:
pass
......@@ -159,7 +164,11 @@ class WebBot:
try:
while self._running:
self.iterateLoop()
time.sleep(self.config.getint(CONFIG_SECTION, "INTERVAL"))
interval = self.config.getint(CONFIG_SECTION, "INTERVAL")
if interval < 0:
self.stop()
else:
time.sleep(interval)
except KeyboardInterrupt:
self.stop()
except:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment