/search.css" rel="stylesheet" type="text/css"/> /search.js">
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

Public Member Functions | Static Public Attributes
DybPython::fsutils::disk_usage Class Reference
Collaboration diagram for DybPython::fsutils::disk_usage:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def __repr__

Static Public Attributes

string tmpl = " free %(gb_free)-4.2f G [%(percent_free)-3.2f %%] used %(gb_used)-4.2f G [%(percent_used)-3.2f %%] total %(gb_total)-4.2f G "

Detailed Description

http://docs.python.org/2/library/statvfs.html

::

    statvfs.F_BSIZE Preferred file system block size.
    statvfs.F_FRSIZE Fundamental file system block size.
    statvfs.F_BLOCKS Total number of blocks in the filesystem.
    statvfs.F_BFREE Total number of free blocks.
    statvfs.F_BAVAIL Free blocks available to non-super user.
    statvfs.F_FILES Total number of file nodes.
    statvfs.F_FFREE Total number of free file nodes.
    statvfs.F_FAVAIL Free nodes available to non-super user.

Values are a bit different to those from `df` maybe rounding ? Or perhaps:

* http://larsmichelsen.com/open-source/answer-why-does-df-k-show-wrong-percentage-usage/

::

    [blyth@belle7 DybPython]$ df -h
    Filesystem            Size  Used Avail Use% Mounted on
    ...                   865G  333G  487G  41% /

    [blyth@belle7 DybPython]$ ./fstools.py 
    disk_usage   free 486.83 G [56.33 %]    used 332.78 G [38.51 %]       total 864.21 G  


Definition at line 13 of file fsutils.py.


Constructor & Destructor Documentation

def DybPython::fsutils::disk_usage::__init__ (   self,
  path = None 
)

Definition at line 44 of file fsutils.py.

00045                                  :
00046         dict.__init__(self)
00047         if not path:
00048             path = os.getcwd()
00049         if not os.path.exists(path):
00050             path = os.path.dirname(path)
00051 
00052         st = os.statvfs(path)
00053         self['bytes_free'] = float(st.f_bavail * st.f_frsize)
00054         self['bytes_total'] = float(st.f_blocks * st.f_frsize)
00055         self['bytes_used'] = float((st.f_blocks - st.f_bfree) * st.f_frsize)
00056 
00057         self['percent_used'] = _percent(self['bytes_used'], self['bytes_total'] )
00058         self['percent_free'] = _percent(self['bytes_free'], self['bytes_total'] )
00059 
00060         b2gb = 1./float(1024*1024*1024)
00061         self['gb_free'] = self['bytes_free']*b2gb
00062         self['gb_total'] = self['bytes_total']*b2gb
00063         self['gb_used'] = self['bytes_used']*b2gb


Member Function Documentation

def DybPython::fsutils::disk_usage::__repr__ (   self)

Definition at line 64 of file fsutils.py.

00065                       :
00066         return self.__class__.__name__ + self.tmpl % self
00067 


Member Data Documentation

string DybPython::fsutils::disk_usage::tmpl = " free %(gb_free)-4.2f G [%(percent_free)-3.2f %%] used %(gb_used)-4.2f G [%(percent_used)-3.2f %%] total %(gb_total)-4.2f G " [static]

Definition at line 43 of file fsutils.py.


The documentation for this class was generated from the following file:
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Fri May 16 2014 09:55:41 for DybPython by doxygen 1.7.4