Commit 9a39ba18 authored by gotcha's avatar gotcha

revert changes moved to branch gotcha-timeout-cfg


git-svn-id: http://svn.zope.org/repos/main/zc.buildout/trunk@110962 62d5b8a3-27da-0310-9561-8e5933582275
parent bf963f92
......@@ -4,10 +4,6 @@ Change History
1.4.4 (?)
=========
New feature:
- Added buildout:socket-timout option so that socket timeout can be configured
both from command line and from config files. (gotcha)
1.4.3 (2009-12-10)
==================
......
......@@ -32,7 +32,6 @@ import pkg_resources
import re
import shutil
import sys
import socket
import tempfile
import UserDict
import zc.buildout
......@@ -122,20 +121,8 @@ _buildout_default_options = _annotate_section({
'executable': sys.executable,
'log-level': 'INFO',
'log-format': '',
'socket-timeout': '',
}, 'DEFAULT_VALUE')
DEFAULT_SOCKET_TIMEOUT = socket.getdefaulttimeout()
def _setup_socket_timeout(timeout_string):
try:
timeout = int(timeout_string)
except ValueError:
_error("Timeout value must be numeric [%s]." % timeout_string)
current_timeout = socket.getdefaulttimeout()
if current_timeout <> timeout:
socket.setdefaulttimeout(timeout)
class Buildout(UserDict.DictMixin):
......@@ -258,7 +245,6 @@ class Buildout(UserDict.DictMixin):
options['installed'])
self._setup_logging()
self._display_socket_timeout()
offline = options.get('offline', 'false')
if offline not in ('true', 'false'):
......@@ -763,12 +749,6 @@ class Buildout(UserDict.DictMixin):
def _error(self, message, *args):
raise zc.buildout.UserError(message % args)
def _display_socket_timeout(self):
current_timeout = socket.getdefaulttimeout()
if current_timeout <> DEFAULT_SOCKET_TIMEOUT:
info_msg = 'Socket timeout is set to %d seconds.' % current_timeout
self._logger.info(info_msg)
def _setup_logging(self):
root_logger = logging.getLogger()
self._logger = logging.getLogger('zc.buildout')
......@@ -1336,18 +1316,13 @@ def _open(base, filename, seen, dl_options, override):
os.remove(path)
extends = extended_by = None
socket_timeout = None
for section in parser.sections():
options = dict(parser.items(section))
if section == 'buildout':
extends = options.pop('extends', extends)
extended_by = options.pop('extended-by', extended_by)
socket_timeout = options.pop('socket-timeout', socket_timeout)
result[section] = options
if socket_timeout is not None:
_setup_socket_timeout(socket_timeout)
result = _annotate(result, filename)
if root_config_file and 'buildout' in result:
......@@ -1640,11 +1615,16 @@ def main(args=None):
_error("No file name specified for option", orig_op)
elif op_ == 't':
try:
timeout_string = args.pop(0)
_setup_socket_timeout(timeout_string)
options.append(('buildout', 'socket-timeout', timeout_string))
timeout = int(args.pop(0))
except IndexError:
_error("No timeout value specified for option t", orig_op)
_error("No timeout value specified for option", orig_op)
except ValueError:
_error("No timeout value must be numeric", orig_op)
import socket
print 'Setting socket time out to %d seconds' % timeout
socket.setdefaulttimeout(timeout)
elif op:
if orig_op == '--help':
_help()
......
......@@ -748,8 +748,6 @@ COMMAND_LINE_VALUE).
DEFAULT_VALUE
python= buildout
DEFAULT_VALUE
socket-timeout=
DEFAULT_VALUE
<BLANKLINE>
[data-dir]
path= foo bins
......@@ -1493,49 +1491,6 @@ set the logging level to WARNING
op3 b2 3
recipe recipes:debug
Socket timeout
--------------
The timeout of the connections to egg and configuration servers can be
configured in the buildout section. Its value is configured in seconds.
>>> write(sample_buildout, 'buildout.cfg',
... """
... [buildout]
... socket-timeout = 5
... develop = recipes
... parts = debug
...
... [debug]
... recipe = recipes:debug
... op = timeout
... """)
>>> print system(buildout),
Socket timeout is set to 5 seconds.
Develop: '/sample-buildout/recipes'
Uninstalling debug.
Installing debug.
op timeout
recipe recipes:debug
If socket-timeout is not numeric, an error message is issued.
>>> write(sample_buildout, 'buildout.cfg',
... """
... [buildout]
... socket-timeout = 5s
... develop = recipes
... parts = debug
...
... [debug]
... recipe = recipes:debug
... op = timeout
... """)
>>> print system(buildout),
Error: Timeout value must be numeric [5s].
Uninstall recipes
-----------------
......@@ -2258,7 +2213,6 @@ database is shown.
parts =
parts-directory = /sample-buildout/parts
python = buildout
socket-timeout =
verbosity = 20
<BLANKLINE>
......
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