summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornicolargo <nicolargo@nicolargo-fujitsu.(none)>2011-12-04 21:10:22 +0100
committernicolargo <nicolargo@nicolargo-fujitsu.(none)>2011-12-04 21:10:22 +0100
commit91efbc6ace6701404c7a55130b20f6ed42a669b2 (patch)
tree3d9c206859ed2f5dc605771cf8456014e48385fe
parent85fd725d0dc227168055b4ee1e37a2b86412097a (diff)
Add control before division
-rw-r--r--NEWS4
-rw-r--r--TODO1
-rw-r--r--autom4te.cache/output.020
-rw-r--r--autom4te.cache/output.120
-rw-r--r--autom4te.cache/traces.12
-rwxr-xr-xconfigure20
-rwxr-xr-xsrc/glances.py18
7 files changed, 49 insertions, 36 deletions
diff --git a/NEWS b/NEWS
index e69de29b..98242792 100644
--- a/NEWS
+++ b/NEWS
@@ -0,0 +1,4 @@
+Version 1.1
+===========
+
+ * Check if mem.total = 0 before division (Bug #1)
diff --git a/TODO b/TODO
new file mode 100644
index 00000000..3f4005ef
--- /dev/null
+++ b/TODO
@@ -0,0 +1 @@
+- Add color indicators in the last line (right)
diff --git a/autom4te.cache/output.0 b/autom4te.cache/output.0
index bbd2b19d..392aeb1b 100644
--- a/autom4te.cache/output.0
+++ b/autom4te.cache/output.0
@@ -1,6 +1,6 @@
@%:@! /bin/sh
@%:@ Guess values for system-dependent variables and create Makefiles.
-@%:@ Generated by GNU Autoconf 2.68 for Glances 0.1.
+@%:@ Generated by GNU Autoconf 2.68 for Glances 1.0.
@%:@
@%:@
@%:@ Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
@@ -556,8 +556,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='Glances'
PACKAGE_TARNAME='glances'
-PACKAGE_VERSION='0.1'
-PACKAGE_STRING='Glances 0.1'
+PACKAGE_VERSION='1.0'
+PACKAGE_STRING='Glances 1.0'
PACKAGE_BUGREPORT=''
PACKAGE_URL=''
@@ -1185,7 +1185,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
-\`configure' configures Glances 0.1 to adapt to many kinds of systems.
+\`configure' configures Glances 1.0 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -1251,7 +1251,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
- short | recursive ) echo "Configuration of Glances 0.1:";;
+ short | recursive ) echo "Configuration of Glances 1.0:";;
esac
cat <<\_ACEOF
@@ -1325,7 +1325,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
-Glances configure 0.1
+Glances configure 1.0
generated by GNU Autoconf 2.68
Copyright (C) 2010 Free Software Foundation, Inc.
@@ -1342,7 +1342,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
-It was created by Glances $as_me 0.1, which was
+It was created by Glances $as_me 1.0, which was
generated by GNU Autoconf 2.68. Invocation command line was
$ $0 $@
@@ -2163,7 +2163,7 @@ fi
# Define the identity of the package.
PACKAGE='glances'
- VERSION='0.1'
+ VERSION='1.0'
cat >>confdefs.h <<_ACEOF
@@ -2970,7 +2970,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
-This file was extended by Glances $as_me 0.1, which was
+This file was extended by Glances $as_me 1.0, which was
generated by GNU Autoconf 2.68. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -3032,7 +3032,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
-Glances config.status 0.1
+Glances config.status 1.0
configured by $0, generated by GNU Autoconf 2.68,
with options \\"\$ac_cs_config\\"
diff --git a/autom4te.cache/output.1 b/autom4te.cache/output.1
index bbd2b19d..392aeb1b 100644
--- a/autom4te.cache/output.1
+++ b/autom4te.cache/output.1
@@ -1,6 +1,6 @@
@%:@! /bin/sh
@%:@ Guess values for system-dependent variables and create Makefiles.
-@%:@ Generated by GNU Autoconf 2.68 for Glances 0.1.
+@%:@ Generated by GNU Autoconf 2.68 for Glances 1.0.
@%:@
@%:@
@%:@ Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
@@ -556,8 +556,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='Glances'
PACKAGE_TARNAME='glances'
-PACKAGE_VERSION='0.1'
-PACKAGE_STRING='Glances 0.1'
+PACKAGE_VERSION='1.0'
+PACKAGE_STRING='Glances 1.0'
PACKAGE_BUGREPORT=''
PACKAGE_URL=''
@@ -1185,7 +1185,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
-\`configure' configures Glances 0.1 to adapt to many kinds of systems.
+\`configure' configures Glances 1.0 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -1251,7 +1251,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
- short | recursive ) echo "Configuration of Glances 0.1:";;
+ short | recursive ) echo "Configuration of Glances 1.0:";;
esac
cat <<\_ACEOF
@@ -1325,7 +1325,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
-Glances configure 0.1
+Glances configure 1.0
generated by GNU Autoconf 2.68
Copyright (C) 2010 Free Software Foundation, Inc.
@@ -1342,7 +1342,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
-It was created by Glances $as_me 0.1, which was
+It was created by Glances $as_me 1.0, which was
generated by GNU Autoconf 2.68. Invocation command line was
$ $0 $@
@@ -2163,7 +2163,7 @@ fi
# Define the identity of the package.
PACKAGE='glances'
- VERSION='0.1'
+ VERSION='1.0'
cat >>confdefs.h <<_ACEOF
@@ -2970,7 +2970,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
-This file was extended by Glances $as_me 0.1, which was
+This file was extended by Glances $as_me 1.0, which was
generated by GNU Autoconf 2.68. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -3032,7 +3032,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
-Glances config.status 0.1
+Glances config.status 1.0
configured by $0, generated by GNU Autoconf 2.68,
with options \\"\$ac_cs_config\\"
diff --git a/autom4te.cache/traces.1 b/autom4te.cache/traces.1
index 784152be..9834ce08 100644
--- a/autom4te.cache/traces.1
+++ b/autom4te.cache/traces.1
@@ -1,4 +1,4 @@
-m4trace:configure.ac:4: -1- AC_INIT([Glances], [0.1], [], [glances])
+m4trace:configure.ac:4: -1- AC_INIT([Glances], [1.0], [], [glances])
m4trace:configure.ac:4: -1- m4_pattern_forbid([^_?A[CHUM]_])
m4trace:configure.ac:4: -1- m4_pattern_forbid([_AC_])
m4trace:configure.ac:4: -1- m4_pattern_forbid([^LIBOBJS$], [do not use LIBOBJS directly, use AC_LIBOBJ (see section `AC_LIBOBJ vs LIBOBJS'])
diff --git a/configure b/configure
index 75d1e4e3..33027a61 100755
--- a/configure
+++ b/configure
@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.68 for Glances 0.1.
+# Generated by GNU Autoconf 2.68 for Glances 1.0.
#
#
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
@@ -556,8 +556,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='Glances'
PACKAGE_TARNAME='glances'
-PACKAGE_VERSION='0.1'
-PACKAGE_STRING='Glances 0.1'
+PACKAGE_VERSION='1.0'
+PACKAGE_STRING='Glances 1.0'
PACKAGE_BUGREPORT=''
PACKAGE_URL=''
@@ -1185,7 +1185,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
-\`configure' configures Glances 0.1 to adapt to many kinds of systems.
+\`configure' configures Glances 1.0 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -1251,7 +1251,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
- short | recursive ) echo "Configuration of Glances 0.1:";;
+ short | recursive ) echo "Configuration of Glances 1.0:";;
esac
cat <<\_ACEOF
@@ -1325,7 +1325,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
-Glances configure 0.1
+Glances configure 1.0
generated by GNU Autoconf 2.68
Copyright (C) 2010 Free Software Foundation, Inc.
@@ -1342,7 +1342,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
-It was created by Glances $as_me 0.1, which was
+It was created by Glances $as_me 1.0, which was
generated by GNU Autoconf 2.68. Invocation command line was
$ $0 $@
@@ -2163,7 +2163,7 @@ fi
# Define the identity of the package.
PACKAGE='glances'
- VERSION='0.1'
+ VERSION='1.0'
cat >>confdefs.h <<_ACEOF
@@ -2970,7 +2970,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
-This file was extended by Glances $as_me 0.1, which was
+This file was extended by Glances $as_me 1.0, which was
generated by GNU Autoconf 2.68. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -3032,7 +3032,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
-Glances config.status 0.1
+Glances config.status 1.0
configured by $0, generated by GNU Autoconf 2.68,
with options \\"\$ac_cs_config\\"
diff --git a/src/glances.py b/src/glances.py
index bdd98e51..f593e3e7 100755
--- a/src/glances.py
+++ b/src/glances.py
@@ -33,7 +33,7 @@ import statgrab
#==================
# The glances version id
-__version__ = "1.0"
+__version__ = "1.1"
# Class
#======
@@ -124,10 +124,10 @@ class glancesStats():
if sortedby == 'auto':
# If global Mem > 70% sort by process size
# Else sort by cpu comsoption
- if ( ( (self.mem['used'] - self.mem['cache']) * 100 / self.mem['total']) > 70):
- sortedby = 'proc_size'
- else:
- sortedby = 'cpu_percent'
+ sortedby = 'cpu_percent'
+ if ( self.mem['total'] != 0):
+ if ( ( (self.mem['used'] - self.mem['cache']) * 100 / self.mem['total']) > 70):
+ sortedby = 'proc_size'
return sorted(self.process, key=lambda process: process[sortedby], reverse=True)
@@ -183,6 +183,7 @@ class glancesScreen():
# Text colors/styles
self.title_color = curses.A_BOLD|curses.A_UNDERLINE
+ self.no_color = curses.color_pair(1)
self.default_color = curses.color_pair(3)|curses.A_BOLD
self.if50pc_color = curses.color_pair(4)|curses.A_BOLD
self.if70pc_color = curses.color_pair(5)|curses.A_BOLD
@@ -212,7 +213,14 @@ class glancesScreen():
# If current > 70% of max then color = self.if70pc_color / A_BOLD
# If current > 90% of max then color = self.if90pc_color / A_REVERSE
# By default: color = self.default_color / 0
+ max = 0
+ try:
+ (current * 100) / max
+ except ZeroDivisionError:
+ return self.no_color
+
variable = (current * 100) / max
+
if variable > 90:
if self.hascolors:
return self.if90pc_color