Fix day filter
[cds-indico.git] / indico / util / network.py
blobc48949acf7a8619384cfcfb43fdf432db064e849
1 # This file is part of Indico.
2 # Copyright (C) 2002 - 2015 European Organization for Nuclear Research (CERN).
4 # Indico is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License as
6 # published by the Free Software Foundation; either version 3 of the
7 # License, or (at your option) any later version.
9 # Indico is distributed in the hope that it will be useful, but
10 # WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with Indico; if not, see <http://www.gnu.org/licenses/>.
17 """
18 Network-related utility functions
19 """
21 import socket
22 from collections import defaultdict
25 def resolve_host(host, per_family=False):
26 result = socket.getaddrinfo(host, None)
28 if per_family:
29 families = defaultdict(list)
30 for tup in result:
31 families[tup[0]].append(tup[-1][0])
32 return families
33 else:
34 return set(tup[-1][0] for tup in result)