/usr/lib/python2.7/dist-packages/ocfs2interface/general.py is in ocfs2console 1.6.4-3.1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 | # OCFS2Console - GUI frontend for OCFS2 management and debugging
# Copyright (C) 2002, 2005 Oracle. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 021110-1307, USA.
import gtk
import ocfs2
from classlabel import class_label
from guiutil import set_props, format_bytes
EMPTY_TEXT = 'N/A'
class Field(object):
def __init__(self, fs, super, dinode):
self.fs = fs
self.super = super
self.dinode = dinode
def get_text(self):
if self.super:
return self.real_get_text()
else:
return EMPTY_TEXT
text = property(get_text)
label = class_label
class Version(Field):
def real_get_text(self):
return '%d.%d' % (self.super.s_major_rev_level,
self.super.s_minor_rev_level)
class Label(Field):
def real_get_text(self):
text = self.super.s_label
if not text:
text = EMPTY_TEXT
return text
class UUID(Field):
def real_get_text(self):
return self.super.uuid_unparsed
class MaximumNodes(Field):
def real_get_text(self):
return str(self.super.s_max_slots)
class FSSize(Field):
def real_get_text(self):
return format_bytes(getattr(self.fs, self.member))
class ClusterSize(FSSize):
member = 'fs_clustersize'
class BlockSize(FSSize):
member = 'fs_blocksize'
class Space(Field):
def real_get_text(self):
if self.dinode:
block_bits = self.fs.fs_clustersize >> self.super.s_blocksize_bits
bytes = self.get_bits() * block_bits * self.fs.fs_blocksize
return format_bytes(bytes, show_bytes=True)
else:
return EMPTY_TEXT
class FreeSpace(Space):
def get_bits(self):
return self.dinode.i_total - self.dinode.i_used
class TotalSpace(Space):
def get_bits(self):
return self.dinode.i_total
fields = (Version, Label, UUID, MaximumNodes,
ClusterSize, BlockSize,
FreeSpace, TotalSpace)
class General(gtk.Table):
def __init__(self, device=None):
gtk.Table.__init__(self, rows=5, columns=2)
set_props(self, row_spacing=4,
column_spacing=4,
border_width=4)
fs = super = dinode = None
if device:
try:
fs = ocfs2.Filesystem(device)
super = fs.fs_super
blkno = fs.lookup_system_inode(ocfs2.GLOBAL_BITMAP_SYSTEM_INODE)
dinode = fs.read_cached_inode(blkno)
except ocfs2.error:
pass
for row, field_type in enumerate(fields):
field = field_type(fs, super, dinode)
label = gtk.Label(field.label + ':')
set_props(label, xalign=1.0)
self.attach(label, 0, 1, row, row + 1,
xoptions=gtk.FILL, yoptions=gtk.FILL)
label = gtk.Label(field.text)
set_props(label, xalign=0.0)
self.attach(label, 1, 2, row, row + 1,
xoptions=gtk.FILL, yoptions=gtk.FILL)
def main():
import sys
def dummy(*args):
gtk.main_quit()
window = gtk.Window()
window.connect('delete_event', dummy)
general = General(sys.argv[1])
window.add(general)
window.show_all()
gtk.main()
if __name__ == '__main__':
main()
|