~mdw
/
hippotat
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
process putatives: break out log_ignore
[hippotat]
/
hippotatlib
/
__init__.py
diff --git
a/hippotatlib/__init__.py
b/hippotatlib/__init__.py
index
ce94a86
..
19a6aef
100644
(file)
--- a/
hippotatlib/__init__.py
+++ b/
hippotatlib/__init__.py
@@
-126,7
+126,7
@@
class LogNotBoringTwisted:
#---------- default config ----------
defcfg = '''
#---------- default config ----------
defcfg = '''
-[
DEFAULT
]
+[
COMMON
]
max_batch_down = 65536
max_queue_time = 10
target_requests_outstanding = 3
max_batch_down = 65536
max_queue_time = 10
target_requests_outstanding = 3
@@
-386,11
+386,16
@@
def _cfg_process_putatives():
server_pat = r'[-.0-9A-Za-z]+'
client_pat = r'[.:0-9a-f]+'
server_re = regexp.compile(server_pat)
server_pat = r'[-.0-9A-Za-z]+'
client_pat = r'[.:0-9a-f]+'
server_re = regexp.compile(server_pat)
- serverclient_re = regexp.compile(server_pat + r' ' + client_pat)
+ serverclient_re = regexp.compile(
+ server_pat + r' ' + '(?:' + client_pat + '|LIMIT)')
for cs in cfg.sections():
for cs in cfg.sections():
- if cs == 'LIMIT':
- # plan A "[LIMIT]"
+ def log_ignore(why):
+ print('warning: ignoring config section [%s] (%s)' % (cs, why),
+ file=sys.stderr)
+
+ if cs == 'LIMIT' or cs == 'COMMON':
+ # plan A "[LIMIT]" or "[COMMON]"
continue
try:
continue
try:
@@
-416,8
+421,7
@@
def _cfg_process_putatives():
ci = ipaddr(pc)
except AddressValueError:
# plan F "[<some thing we do not understand>]"
ci = ipaddr(pc)
except AddressValueError:
# plan F "[<some thing we do not understand>]"
- # well, we ignore this
- print('warning: ignoring config section %s' % cs, file=sys.stderr)
+ log_ignore('bad-addr')
continue
else: # no AddressValueError
continue
else: # no AddressValueError
@@
-492,11
+496,12
@@
def cfg_search(getter,key,sections):
section = cfg_search_section(key,sections)
return getter(section, key)
section = cfg_search_section(key,sections)
return getter(section, key)
-def cfg1get(*args, **kwargs):
- return cfg.get(*args, **kwargs)
+def cfg1get(section,key, getter=cfg.get,**kwargs):
+ section = cfg_search_section(key,[section,'COMMON'])
+ return getter(section,key,**kwargs)
-def cfg1getint(
*args
, **kwargs):
- return cfg
.getint(*args, **kwargs)
+def cfg1getint(
section,key
, **kwargs):
+ return cfg
1get(section,key, getter=cfg.getint,**kwargs);
def cfg_process_client_limited(cc,ss,sections,key):
val = cfg_search(cfg1getint, key, sections)
def cfg_process_client_limited(cc,ss,sections,key):
val = cfg_search(cfg1getint, key, sections)
@@
-510,7
+515,7
@@
def cfg_process_client_common(cc,ss,cs,ci):
sections = ['%s %s' % (ss,cs),
cs,
ss,
sections = ['%s %s' % (ss,cs),
cs,
ss,
- '
DEFAULT
']
+ '
COMMON
']
try: pwsection = cfg_search_section('password', sections)
except NoOptionError: return None
try: pwsection = cfg_search_section('password', sections)
except NoOptionError: return None