Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #36874
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!nuzba.szn.dk!pnx.dk!news.stack.nl!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <dreadpiratejeff@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.001 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'jeff': 0.04; 'output': 0.04; 'defaults': 0.05; 'none,': 0.05; 'exit': 0.07; 'tests,': 0.07; 'tool,': 0.07; 'wrapper': 0.07; 'none.': 0.09; 'properly': 0.15; 'skip:f 30': 0.15; 'assigns': 0.16; 'diagnostic': 0.16; 'failed.': 0.16; 'simplified': 0.16; 'summarize': 0.16; 'to:name:python list': 0.16; 'tool:': 0.16; 'implementing': 0.17; 'skip:{ 20': 0.17; 'variables': 0.17; 'tests': 0.18; '(or': 0.18; 'written': 0.20; 'tells': 0.22; 'defined': 0.22; 'runs': 0.22; 'this:': 0.23; 'idea': 0.24; 'script': 0.24; 'looks': 0.26; 'wrote': 0.26; 'values': 0.26; '(e.g.': 0.27; 'message- id:@mail.gmail.com': 0.27; 'correct': 0.28; 'run': 0.28; 'necessary,': 0.29; 'priority': 0.29; 'summary': 0.29; "skip:' 10": 0.30; 'code': 0.31; 'point': 0.31; 'running': 0.32; 'problem': 0.33; 'to:addr:python-list': 0.33; 'that,': 0.34; "can't": 0.34; 'received:google.com': 0.34; 'thanks': 0.34; 'direction': 0.35; 'fail': 0.35; 'so,': 0.35; 'doing': 0.35; 'subject:?': 0.35; "won't": 0.35; 'received:209.85': 0.35; 'explain': 0.36; 'tool': 0.36; 'but': 0.36; 'level.': 0.36; 'enough': 0.36; 'ok,': 0.37; 'level': 0.37; 'passed': 0.37; 'received:209': 0.37; 'to:addr:python.org': 0.39; 'received:209.85.214': 0.39; 'header:Received:5': 0.40; 'high': 0.61; 'provide': 0.62; 'series': 0.63; 'our': 0.65; 'results': 0.65; 'else.': 0.65; 'subject:there': 0.65; 'aggregated': 0.84; 'subject:handle': 0.84; 'subject:status': 0.84; 'this...': 0.84 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:from:date:message-id:subject:to:content-type; bh=MjMv7h87Rx8n6ee7qaWDLUVR11IocUWleWKfW1JwpkY=; b=f+0xDmkZruVbhj0dZUjSo9MtsDcXuOX+cc7diWOBZeM8jIGyjNaEiLYs7b8rOwzYjX wRTwVddEFJ9S9C04iqSW0CDqECmO7beoGnXkRrswusjB86CuyvLGkU6ZkcfHcDAaMZTh 3Oww0TNmn77G5jBM/MQhpFModlklibD207CImQcsJBY9WqbhdK92ZCvBe4l+PKHVP4Cx BrT7pKZ9sBPCNcwajcHE1BvkAGilQPdB4eVRjQL+/4vL16B3g4jnhWCSFc8gLGm8GUlj 1jTavWGUz4ldoiQVwJYsXKVYkALotzgEf47FGbmdoWmeV7AnUGjjpziNfCxuHeJVtz4m sycA== |
| MIME-Version | 1.0 |
| From | J <dreadpiratejeff@gmail.com> |
| Date | Tue, 15 Jan 2013 18:24:44 -0500 |
| Subject | Is there a more elegant way to handle determing fail status? |
| To | Python List <python-list@python.org> |
| Content-Type | text/plain; charset=ISO-8859-1 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.554.1358292312.2939.python-list@python.org> (permalink) |
| Lines | 89 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1358292312 news.xs4all.nl 6968 [2001:888:2000:d::a6]:48600 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:36874 |
Show key headers only | View raw
Ok, so I have a diagnostic tool, written by someone else. That tool
runs a series of small tests defined by the user and can simplified
summary output that can be one of the following:
FAILED_CRITICAL
FAILED_HIGH
FAILED_MEDIUM
FAILED_LOW
PASSED
I also have a wrapper script I wrote to run these tests, summarize the
results of all tests aggregated and then fail based on a particular
fail level.
The idea is that if I run 3 tests with the diagnostic tool and it
tells me the following:
testA: PASSED
testB: FAILED_MEDIUM
testC: PASSED
AND I told the wrapper to only fail on HIGH or above, the wrapper will
tell me that I had a medium failure, but the wrapper will still exit
with a 0 (success)
if I get the same results as above, but tell the wrapper to fail on
LOW, then it will tell me I had that medium failure, but the wrapper
will exit with a 1 (failure).
The problem is that my exit determination looks like this:
if fail_priority == fail_levels['FAILED_CRITICAL']:
if critical_fails:
return 1
if fail_priority == fail_levels['FAILED_HIGH']:
if critical_fails or high_fails:
return 1
if fail_priority == fail_levels['FAILED_MEDIUM']:
if critical_fails or high_fails or medium_fails:
return 1
if fail_priority == fail_levels['FAILED_LOW']:
if critical_fails or high_fails or medium_fails or low_fails:
return 1
return 0
So, to explain the above... the fail level can be set by the user when
running the wrapper using -f (or it defaults to 'high')
the wrapper assigns a number to each level using this:
# Set correct fail level
args.fail_level = 'FAILED_%s' % args.fail_level.upper()
# Get our failure priority and create the priority values
fail_levels = {'FAILED_CRITICAL':4,
'FAILED_HIGH':3,
'FAILED_MEDIUM':2,
'FAILED_LOW':1}
fail_priority = fail_levels[args.fail_level]
the variables critical_fails, high_fails, medium_fails, low_fails are
all counters that are etiher None, or the number of tests that were
failed.
So using this output from the diagnostic tool:
testA: PASSED
testB: FAILED_HIGH
testC: PASSED
testD: FAILED_MEDIUM
testE: PASSED
critical_fails would be None
high_fails would be 1
medium_fails would be 1
low_fails would be None.
The exit code determination above works, but it just feels inelegant.
It feels like there's a better way of implementing that, but I can't
come up with one that still honors the fail level properly (e.g. other
solutions will fail on medium, but won't fail properly on medium OR
higher).
I can provide the full script if necessary, if the above isn't enough
to point me in a direction that has a better way of doing this...
Thanks for looking,
Jeff
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
Is there a more elegant way to handle determing fail status? J <dreadpiratejeff@gmail.com> - 2013-01-15 18:24 -0500 Re: Is there a more elegant way to handle determing fail status? donarb <donarb@nwlink.com> - 2013-01-15 15:52 -0800 Re: Is there a more elegant way to handle determing fail status? donarb <donarb@nwlink.com> - 2013-01-15 15:52 -0800 Re: Is there a more elegant way to handle determing fail status? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-01-16 02:55 +0000
csiph-web