[redistricter] r217 committed - make runallstates.py --config-include better explained and more useful

1 view
Skip to first unread message

redist...@googlecode.com

unread,
Jun 6, 2011, 12:35:08 AM6/6/11
to redistrict...@googlegroups.com
Revision: 217
Author: brian.olson
Date: Sun Jun 5 20:12:11 2011
Log: make runallstates.py --config-include better explained and more
useful

http://code.google.com/p/redistricter/source/detail?r=217

Modified:
/trunk/run_redistricter.py
/trunk/runallstates.py

=======================================
--- /trunk/run_redistricter.py Wed Feb 16 08:01:49 2011
+++ /trunk/run_redistricter.py Sun Jun 5 20:12:11 2011
@@ -38,6 +38,7 @@
op.add_option('--port', dest='port', type='int', default=9988)
op.add_option('--threads', dest='threads', type='int', default=2)
op.add_option('--flagfile', dest='flagfile', default=None)
+ op.add_option('--log', dest='logname', default=None)
(options, args) = op.parse_args()

if options.flagfile:
@@ -72,7 +73,18 @@
print 'status should be available on'
print 'http://localhost:%d/' % (options.port,)

- log = RotatingLogWriter(os.path.join(workdir, 'dblog_'))
+ log = None
+ if options.logname:
+ if options.logname == '-':
+ logpath = None
+ log = sys.stdout
+ else:
+ logpath = options.logname
+ else:
+ logpath = os.path.join(workdir, 'dblog_')
+ if log is None:
+ log = RotatingLogWriter(logpath)
+ log.write('# cmd: "%s"\n' % ('" "'.join(cmd),))
piped_run(proc, log)
log.close()

=======================================
--- /trunk/runallstates.py Sun Jun 5 08:32:18 2011
+++ /trunk/runallstates.py Sun Jun 5 20:12:11 2011
@@ -697,8 +697,8 @@
argp.add_option('--exe', dest='exepath', default=None)
argp.add_option('--runsecs', dest='runsecs', type='float', default=None)
argp.add_option('--config', dest='configList', action='append',
default=[])
- argp.add_option('--config-include', dest='config_include',
action='append', default=[])
- argp.add_option('--config-exclude', dest='config_exclude',
action='append', default=[])
+ argp.add_option('--config-include', dest='config_include',
action='append', default=[], help='regex compared to unpacked config file
path, like "AZ/config/Senate". partial match includes the config. overrides
--config-exclude')
+ argp.add_option('--config-exclude', dest='config_exclude',
action='append', default=[], help='regex compared to config file path.
partial match causes config to not be used. overriden by --config-include')
argp.add_option('--configdir', dest='configdir', default=None)
argp.add_option('--config-override', dest='config_override_path',
default='configoverride')
argp.add_option('--threads', dest='threads', type='int', default=1)
@@ -810,11 +810,12 @@
sys.exit(1)

def allowConfigPath(self, path):
+ for pattern in self.config_include:
+ if pattern.search(path):
+ return True
if self.config_include:
- # must match all
- for pattern in self.config_include:
- if not pattern.search(path):
- return False
+ # if include was specified, but none hit, default to exclude
+ return False
for pattern in self.config_exclude:
if pattern.search(path):
return False
@@ -1152,7 +1153,7 @@
self.doDrend(stu, mb)
self.doBestlog(stu, mb)
bestPath = None
- if len(mb.they) > 0:
+ if mb.they:
bestPath = os.path.join(stu, mb.they[0].root)
sconf = self.config[stu]
if (

Reply all
Reply to author
Forward
0 new messages