Beispiel #1
0
def _normalize_args(args):
    """
    Pre-process arguments before calling ``start_hub()``.  This
    ensures the arguments are normalized.

    :params args: The values of the command line arguments for
                  normalization.
    """

    # If no endpoints have been set up, set up the defaults
    if not args.endpoints:
        args.endpoints = [('', util.HEYU_PORT)]
        if socket.has_ipv6:
            args.endpoints.append(('::', util.HEYU_PORT))
    else:
        # Resolve the endpoints
        args.endpoints = [util.parse_hub(endpoint)
                          for endpoint in args.endpoints]

    # Go into the background if requested, and not in debug mode
    if args.daemon and not args.debug:
        util.daemonize(pidfile=args.pid_file)
Beispiel #2
0
    def test_bare_ipv4(self, mock_getaddrinfo):
        result = util.parse_hub('127.0.0.1')

        self.assertEqual(('127.0.0.1', util.HEYU_PORT), result)
        mock_getaddrinfo.assert_called_once_with(
            '127.0.0.1', util.HEYU_PORT, 0, socket.SOCK_STREAM)
Beispiel #3
0
    def test_ipv4_with_port(self, mock_getaddrinfo):
        result = util.parse_hub('127.0.0.1:1234')

        self.assertEqual(('127.0.0.1', 1234), result)
        mock_getaddrinfo.assert_called_once_with(
            '127.0.0.1', 1234, 0, socket.SOCK_STREAM)
Beispiel #4
0
    def test_hostname_with_port(self, mock_getaddrinfo):
        result = util.parse_hub('hostname:1234')

        self.assertEqual(('hostname', 1234), result)
        mock_getaddrinfo.assert_called_once_with(
            'hostname', 1234, 0, socket.SOCK_STREAM)