From: "André Erdmann" <dywi@mailerd.de>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/R_overlay:master commit in: roverlay/db/, roverlay/stats/
Date: Fri, 16 Aug 2013 13:13:38 +0000 (UTC) [thread overview]
Message-ID: <1376658713.63f53086f703b1e7e85ebffecdbe3522beb516d4.dywi@gentoo> (raw)
commit: 63f53086f703b1e7e85ebffecdbe3522beb516d4
Author: André Erdmann <dywi <AT> mailerd <DOT> de>
AuthorDate: Fri Aug 16 13:11:53 2013 +0000
Commit: André Erdmann <dywi <AT> mailerd <DOT> de>
CommitDate: Fri Aug 16 13:11:53 2013 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/R_overlay.git;a=commit;h=63f53086
roverlay, stats rating: fixup
* KNOWN_UNKNOWN must not contain mixed/uppercase words
* using has_issues() instead of "not is_ok()" when generating suggestions
* search for unknown values, not keys when generating suggestions
---
roverlay/db/rrdtool.py | 2 +-
roverlay/stats/rating.py | 45 +++++++++++++++++++++++++++++----------------
2 files changed, 30 insertions(+), 17 deletions(-)
diff --git a/roverlay/db/rrdtool.py b/roverlay/db/rrdtool.py
index bd98492..b326e7d 100644
--- a/roverlay/db/rrdtool.py
+++ b/roverlay/db/rrdtool.py
@@ -132,7 +132,7 @@ class RRDArchive ( object ):
class RRD ( object ):
# should be subclassed 'cause _do_create() is not implemented here
- KNOWN_UNKNOWN = frozenset ({ 'U', 'UNKNOWN', '-nan', 'nan', })
+ KNOWN_UNKNOWN = frozenset ({ 'u', 'unknown', '-nan', 'nan', })
RRDTOOL_CMDV_HEAD = ( 'rrdtool', )
diff --git a/roverlay/stats/rating.py b/roverlay/stats/rating.py
index 3f6b9e0..eb0559e 100644
--- a/roverlay/stats/rating.py
+++ b/roverlay/stats/rating.py
@@ -51,6 +51,8 @@ class StatsRating ( object ):
STATUS_CRIT_LOW = STATUS_CRIT | STATUS_TOO_LOW
STATUS_CRIT_HIGH = STATUS_CRIT | STATUS_TOO_HIGH
+ STATUS_ISSUES = STATUS_WARN | STATUS_ERR | STATUS_CRIT
+
STATUS_FAIL = ( ( 2**8 ) - 1 ) ^ STATUS_OK
@@ -89,9 +91,20 @@ class NumStatsCounterRating ( StatsRating ):
# --- end of new_fail_counter (...) ---
def get_value ( self, unknown_value=0 ):
- return self.value or unknown_value
+ v = self.value
+ return v if v is not None else unknown_value
# --- end of get_value (...) ---
+ def get_value_str ( self, unknown_value="unknown" ):
+ v = self.value
+ return str ( v ) if v is not None else unknown_value
+ # --- end of get_value_str (...) ---
+
+ @property
+ def value_str ( self ):
+ return self.get_value_str()
+ # --- end of value_str (...) ---
+
def get_rating ( self, value ):
if value is None:
return self.STATUS_UNDEF
@@ -134,6 +147,10 @@ class NumStatsCounterRating ( StatsRating ):
return self.status & self.STATUS_CRIT
# --- end of is_critical (...) ---
+ def has_issues ( self ):
+ return self.status & self.STATUS_ISSUES
+ # --- end of has_issues (...) ---
+
def is_ok ( self ):
return self.status == self.STATUS_OK
# --- end of is_ok (...) ---
@@ -152,7 +169,9 @@ class NumStatsCounterRating ( StatsRating ):
def get_item ( self, item_ok, item_warn, item_err, item_crit, item_undef ):
status = self.status
- if self.status & self.STATUS_CRIT:
+ if self.status & self.STATUS_UNDEF:
+ return item_undef
+ elif self.status & self.STATUS_CRIT:
return item_crit
elif self.status & self.STATUS_ERR:
return item_err
@@ -326,19 +345,19 @@ class RoverlayNumStatsRating ( NumStatsRating ):
code_format = { 'cstart': "<code>", 'cend': "</code>", }
- if any ( value is None for value in self.values ):
+ if any ( value is None for value in self.values.values() ):
yield (
"database contains UNKNOWNS",
[ "run roverlay", ]
)
- if not self.pc_repo.is_ok():
+ if self.pc_repo.has_issues():
yield (
"low repo package count",
[ "check the repo config file", "drop repos without packages" ]
)
- if not self.pc_distmap.is_ok():
+ if self.pc_distmap.has_issues():
details = [
'run {cstart}roverlay --distmap-verify{cend} to fix '
'the distmap'.format ( **code_format )
@@ -365,13 +384,9 @@ class RoverlayNumStatsRating ( NumStatsRating ):
"no ebuilds created (not an issue in incremental mode)",
None
)
- elif not self.pc_success.is_ok():
- yield (
- "only a few ebuilds created (not an issue in incremental mode)",
- None
- )
- if self.pc_fail.get_value() > 0 or not self.pc_success.is_ok():
+
+ if self.pc_fail.get_value() > 0 or self.pc_success.has_issues():
details = []
if self.pc_fail_dep.get_value() > 0:
details.append ( "write dependency rules" )
@@ -387,23 +402,21 @@ class RoverlayNumStatsRating ( NumStatsRating ):
)
- if not self.pc_fail_err.is_ok():
+ if self.pc_fail_err.has_issues():
yield (
"failures due to unknown errors",
[ 'check the log files for python exceptions and report them', ]
)
- if not self.ec_pre.is_ok() or not self.ec_post.is_ok():
+ if self.ec_pre.has_issues() or self.ec_post.has_issues():
yield ( "ebuild loss occurred (no suggestions available)", None )
- if not self.ec_revbump.is_ok():
+ if self.ec_revbump.has_issues():
yield (
"unexpected ebuild revbump count (no suggestions available)",
None
)
- # +++ UNKNOWNS
-
# --- end of get_suggestions (...) ---
# --- end of RoverlayNumStatsRating ---
next reply other threads:[~2013-08-16 13:13 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-16 13:13 André Erdmann [this message]
-- strict thread matches above, loose matches on Subject: below --
2013-08-14 14:56 [gentoo-commits] proj/R_overlay:master commit in: roverlay/db/, roverlay/stats/ André Erdmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1376658713.63f53086f703b1e7e85ebffecdbe3522beb516d4.dywi@gentoo \
--to=dywi@mailerd.de \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox