diff options
author | Petr Viktorin <pviktori@redhat.com> | 2014-06-13 12:47:48 +0200 |
---|---|---|
committer | Petr Viktorin <pviktori@redhat.com> | 2014-06-16 13:38:54 +0200 |
commit | 521df77744233f424ec68caa68548bede6e575fb (patch) | |
tree | e848271c1273f8bc78787bea39c439ef57731d49 /ipapython | |
parent | da64c891e952d31f2c52000fb20f091c1c7136dd (diff) | |
download | freeipa-521df77744233f424ec68caa68548bede6e575fb.tar.gz freeipa-521df77744233f424ec68caa68548bede6e575fb.tar.xz freeipa-521df77744233f424ec68caa68548bede6e575fb.zip |
ipalib.config: Don't autoconvert values to float
When api.env is loaded, strings that "look like" floats got
auto-converted to floats.
This is wrong, as the conversion to float can lose precision.
Case in point: the api_version (e.g. '2.88') should never be
interpreted as float.
Do not automatically convert to float.
We have two numeric options: startup_timeout and wait_for_dns.
wait_for_dns is already converted to int when used in the code.
Convert startup_timeout to float explicitly when used, so
configuration that specified it with a decimal point continues
to work.
Reviewed-By: Fraser Tweedale <ftweedal@redhat.com>
Diffstat (limited to 'ipapython')
-rw-r--r-- | ipapython/ipautil.py | 2 | ||||
-rw-r--r-- | ipapython/platform/fedora16/service.py | 2 |
2 files changed, 3 insertions, 1 deletions
diff --git a/ipapython/ipautil.py b/ipapython/ipautil.py index 844dbb687..d95983b20 100644 --- a/ipapython/ipautil.py +++ b/ipapython/ipautil.py @@ -1135,6 +1135,7 @@ def wait_for_open_ports(host, ports, timeout=0): in seconds may be specified to limit the wait. If the timeout is exceeded, socket.timeout exception is raised. """ + timeout = float(timeout) if not isinstance(ports, (tuple, list)): ports = [ports] @@ -1156,6 +1157,7 @@ def wait_for_open_socket(socket_name, timeout=0): Wait until the specified socket on the local host is open. Timeout in seconds may be specified to limit the wait. """ + timeout = float(timeout) op_timeout = time.time() + timeout while True: diff --git a/ipapython/platform/fedora16/service.py b/ipapython/platform/fedora16/service.py index 41c241ae5..86403d825 100644 --- a/ipapython/platform/fedora16/service.py +++ b/ipapython/platform/fedora16/service.py @@ -152,7 +152,7 @@ class Fedora16CAService(Fedora16Service): 'The httpd proxy is not installed, wait on local port') use_proxy = False root_logger.debug('Waiting until the CA is running') - timeout = api.env.startup_timeout + timeout = float(api.env.startup_timeout) op_timeout = time.time() + timeout while time.time() < op_timeout: try: |