Skip to content

Commit

Permalink
[Folders] Differentiate permission issue and non-existence of a direc…
Browse files Browse the repository at this point in the history
…tory (issue #828)
  • Loading branch information
nicolargo committed Mar 28, 2016
1 parent fd2c2f2 commit ee471b9
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 10 deletions.
6 changes: 5 additions & 1 deletion NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@ Glances Version 2
Version 2.7
===========

Enhancements and new features:

* [Folders] Differentiate permission issue and non-existence of a directory #828

Bugs corrected:

* Crash on launch when viewing temperature of laptop HDD in sleep mode (issue #824)
* Crash on launch when viewing temperature of laptop HDD in sleep mode (issue #824)
* [Web UI] Fix folders plugin never displayed (issue #829)

Version 2.6.1
Expand Down
3 changes: 2 additions & 1 deletion conf/glances.conf
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ critical=90
# Allow additional file system types (comma-separated FS type)
#allow=zfs

#[folders]
[folders]
# Define a folder list to monitor
# The list is composed of items (list_#nb <= 10)
# An item is defined by:
Expand All @@ -117,6 +117,7 @@ critical=90
#folder_2_warning=17000
#folder_2_critical=20000
#folder_3_path=/nonexisting
#folder_4_path=/root

[sensors]
# Sensors core thresholds (in Celsius...)
Expand Down
2 changes: 1 addition & 1 deletion docs/aoa/folders.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ monitor size of a predefined folders list.

.. image:: ../_static/folders.png

If the size can not be computed (non existing folder, read right error), a '?' is displayed.
If the size can not be computed, a '?' (non existing folder) or a '!' (read right error) is displayed.

Each item is defined by:

Expand Down
2 changes: 1 addition & 1 deletion docs/man/glances.1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.\" Man page generated from reStructuredText.
.
.TH "GLANCES" "1" "March 26, 2016" "2.6.1" "Glances"
.TH "GLANCES" "1" "March 28, 2016" "2.7_BETA" "Glances"
.SH NAME
glances \- An eye on your system
.
Expand Down
6 changes: 5 additions & 1 deletion glances/folder_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,12 @@ def update(self):
try:
self.__folder_list[i]['size'] = self.__folder_size(self.path(i))
except Exception as e:
self.__folder_list[i]['size'] = None
logger.debug('Can get folder size ({0}). Error: {1}'.format(self.path(i), e))
if e.errno == 13:
# Permission denied
self.__folder_list[i]['size'] = '!'
else:
self.__folder_list[i]['size'] = '?'

return self.__folder_list

Expand Down
10 changes: 6 additions & 4 deletions glances/plugins/glances_folders.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# This file is part of Glances.
#
# Copyright (C) 2015 Nicolargo <nicolas@nicolargo.com>
# Copyright (C) 2016 Nicolargo <nicolas@nicolargo.com>
#
# Glances is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
Expand All @@ -19,6 +19,8 @@

"""Folder plugin."""

import numbers

from glances.folder_list import FolderList as glancesFolderList
from glances.plugins.glances_plugin import GlancesPlugin

Expand Down Expand Up @@ -74,7 +76,7 @@ def update(self):
def get_alert(self, stat):
"""Manage limits of the folder list"""

if stat['size'] is None:
if not isinstance(stat['size'], numbers.Number):
return 'DEFAULT'
else:
ret = 'OK'
Expand Down Expand Up @@ -114,8 +116,8 @@ def msg_curse(self, args=None):
ret.append(self.curse_add_line(msg))
try:
msg = '{0:>6}'.format(self.auto_unit(i['size']))
except TypeError:
msg = '{0:>6}'.format('?')
except (TypeError, ValueError):
msg = '{0:>6}'.format(i['size'])
ret.append(self.curse_add_line(msg, self.get_alert(i)))

return ret
1 change: 0 additions & 1 deletion glances/plugins/glances_hddtemp.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

import os
import socket
import numbers

from glances.compat import nativestr, range
from glances.logger import logger
Expand Down

0 comments on commit ee471b9

Please sign in to comment.