fix: [IPAddress] catch empty config error

This commit is contained in:
Terrtia 2020-02-03 15:29:37 +01:00
parent 4d8db3fcc4
commit 8770bf05d7
No known key found for this signature in database
GPG key ID: 1E1B1F50D84613D0

View file

@ -16,6 +16,7 @@ and should be defined in the config.cfg file, under the [IP] section
import time import time
import re import re
import sys
from pubsublogger import publisher from pubsublogger import publisher
from packages import Paste from packages import Paste
from Helper import Process from Helper import Process
@ -60,8 +61,12 @@ if __name__ == '__main__':
p = Process(config_section) p = Process(config_section)
ip_networks = [] ip_networks = []
try:
for network in p.config.get("IP", "networks").split(","): for network in p.config.get("IP", "networks").split(","):
ip_networks.append(IPv4Network(network)) ip_networks.append(IPv4Network(network))
except:
print('Please provide a list of valid IP addresses')
sys.exit(0)
# Sent to the logging a description of the module # Sent to the logging a description of the module
@ -78,4 +83,3 @@ if __name__ == '__main__':
# Do something with the message from the queue # Do something with the message from the queue
search_ip(message) search_ip(message)