[Ocfs2-tools-commits] manish commits r590 - in trunk/ocfs2console:
. ocfs2interface
svn-commits at oss.oracle.com
svn-commits at oss.oracle.com
Tue Jan 25 21:39:23 CST 2005
Author: manish
Date: 2005-01-25 21:39:21 -0600 (Tue, 25 Jan 2005)
New Revision: 590
Added:
trunk/ocfs2console/ocfs2interface/
trunk/ocfs2console/ocfs2interface/Makefile
trunk/ocfs2console/ocfs2interface/__init__.py
trunk/ocfs2console/ocfs2interface/about.py
trunk/ocfs2console/ocfs2interface/browser.py
trunk/ocfs2console/ocfs2interface/clconfig.py
trunk/ocfs2console/ocfs2interface/format.py
trunk/ocfs2console/ocfs2interface/general.py
trunk/ocfs2console/ocfs2interface/guiutil.py
trunk/ocfs2console/ocfs2interface/interface.py
trunk/ocfs2console/ocfs2interface/menu.py
trunk/ocfs2console/ocfs2interface/nodemap.py
trunk/ocfs2console/ocfs2interface/ocfs2module.c
trunk/ocfs2console/ocfs2interface/ocfsplist.c
trunk/ocfs2console/ocfs2interface/ocfsplist.h
trunk/ocfs2console/ocfs2interface/process.py
trunk/ocfs2console/ocfs2interface/toolbar.py
Removed:
trunk/ocfs2console/__init__.py
trunk/ocfs2console/about.py
trunk/ocfs2console/browser.py
trunk/ocfs2console/clconfig.py
trunk/ocfs2console/format.py
trunk/ocfs2console/general.py
trunk/ocfs2console/guiutil.py
trunk/ocfs2console/interface.py
trunk/ocfs2console/menu.py
trunk/ocfs2console/nodemap.py
trunk/ocfs2console/ocfs2module.c
trunk/ocfs2console/ocfsplist.c
trunk/ocfs2console/ocfsplist.h
trunk/ocfs2console/process.py
trunk/ocfs2console/toolbar.py
Modified:
trunk/ocfs2console/Makefile
trunk/ocfs2console/ocfs2console
Log:
Move python GUI code to a module subdir
Modified: trunk/ocfs2console/Makefile
===================================================================
--- trunk/ocfs2console/Makefile 2005-01-26 03:34:01 UTC (rev 589)
+++ trunk/ocfs2console/Makefile 2005-01-26 03:39:21 UTC (rev 590)
@@ -2,70 +2,12 @@
include $(TOPDIR)/Preamble.make
-WARNINGS = -Wall
+SUBDIRS = ocfs2interface
-ifdef OCFS_DEBUG
-OPTS = -g
-endif
-OPTS = -g
-
-CFLAGS = $(OPTS) $(WARNINGS) -fPIC
-
-LIBOCFS2_CFLAGS = -I$(TOPDIR)/libocfs2/include
-LIBOCFS2_LIBS = -L$(TOPDIR)/libocfs2 -locfs2
-LIBOCFS2_DEPS = $(TOPDIR)/libocfs2/libocfs2.a
-
-DEFINES = -DOCFS2_FLAT_INCLUDES -DG_DISABLE_DEPRECATED
-INCLUDES = $(LIBOCFS2_CFLAGS) $(PYTHON_INCLUDES) $(GLIB_CFLAGS)
-
-OPTIMIZE = -O2
-OPTIMIZE = -O0
-
-CFLAGS += $(OPTIMIZE)
-
-CBITS = \
- ocfsplist.c
-
-HBITS = $(subst .c,.h,$(CBITS))
-
-CFILES = $(CBITS) ocfs2module.c
-HFILES = $(HBITS)
-
-OBJS = $(subst .c,.o,$(CFILES))
-
MANS = ocfs2console.8
SBIN_EXTRA = ocfs2console
-LIBRARIES = ocfs2module.so
+DIST_FILES = ocfs2console ocfs2console.8.in
-PYSRC = \
- __init__.py \
- about.py \
- browser.py \
- clconfig.py \
- format.py \
- general.py \
- guiutil.py \
- interface.py \
- menu.py \
- nodemap.py \
- process.py \
- toolbar.py
-
-PYLIB = $(LIBRARIES) $(PYSRC)
-
-INSTALL_RULES = install-pylib
-
-DIST_FILES = $(CFILES) $(HFILES) $(PYSRC) ocfs2console ocfs2console.8.in
-
-ocfs2module.so: $(OBJS) $(LIBOCFS2_DEPS)
- $(LINK) -shared $(LIBOCFS2_LIBS) $(COM_ERR_LIBS) $(GLIB_LIBS)
-
-install-pylib:
- $(SHELL) $(TOPDIR)/mkinstalldirs $(DESTDIR)$(pyexecdir)/ocfs2console
- for f in $(PYLIB); do \
- $(INSTALL_DATA) $$f $(DESTDIR)$(pyexecdir)/ocfs2console/$$f; \
- done
-
include $(TOPDIR)/Postamble.make
Deleted: trunk/ocfs2console/__init__.py
===================================================================
--- trunk/ocfs2console/__init__.py 2005-01-26 03:34:01 UTC (rev 589)
+++ trunk/ocfs2console/__init__.py 2005-01-26 03:39:21 UTC (rev 590)
@@ -1 +0,0 @@
-"""Dummy file so modules work"""
Deleted: trunk/ocfs2console/about.py
===================================================================
--- trunk/ocfs2console/about.py 2005-01-26 03:34:01 UTC (rev 589)
+++ trunk/ocfs2console/about.py 2005-01-26 03:39:21 UTC (rev 590)
@@ -1,108 +0,0 @@
-# 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.
-
-OCFS2TOOL_VERSION = '0.0.2'
-
-def print_version():
- print 'OCFS2Console version %s' % OCFS2TOOL_VERSION
-
-def print_usage(name):
- print '''Usage: %s [OPTION]...
-Options:
- -V, --version print version information and exit
- --help display this help and exit''' % name
-
-def process_info_args():
- import sys
-
- for arg in sys.argv[1:]:
- if arg == '--version' or arg == '-V':
- print_version()
- sys.exit(0)
- elif arg == '--help':
- print_usage(sys.argv[0])
- sys.exit(0)
- else:
- print_usage(sys.argv[0])
- sys.exit(1)
-
-def about(pv):
- import gtk
-
- from guiutil import set_props
-
- if hasattr(gtk, 'AboutDialog'):
- copyright = 'Copyright (C) 2002, 2005 Oracle. All rights reserved.'
- license = '''
-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 02111-1307, USA.
-'''
- blurb = 'GUI frontend for OCFS2 management and debugging'
-
- #logo = gtk.gdk.pixbuf_new_from_file('logo.png')
-
- dialog = gtk.AboutDialog()
- dialog.set_transient_for(pv.toplevel)
- dialog.set_destroy_with_parent(True)
-
- set_props(dialog, name='OCFS2 Console',
- version=OCFS2TOOL_VERSION,
- copyright=copyright,
- license=license,
- website='http://oss.oracle.com',
- comments=blurb)
- #logo=logo)
-
- else:
- dialog = gtk.MessageDialog(parent=pv.toplevel,
- flags=gtk.DIALOG_DESTROY_WITH_PARENT,
- buttons=gtk.BUTTONS_CLOSE)
- dialog.label.set_text(
-'''OCFS2 Console
-Version %s
-Copyright (C) 2002, 2005 Oracle.
-All Rights Reserved.''' % OCFS2TOOL_VERSION)
-
- dialog.run()
- dialog.destroy()
-
-def main():
- process_info_args()
-
- class Dummy: pass
-
- pv = Dummy()
- pv.toplevel = None
-
- about(pv)
-
-if __name__ == '__main__':
- main()
Deleted: trunk/ocfs2console/browser.py
===================================================================
--- trunk/ocfs2console/browser.py 2005-01-26 03:34:01 UTC (rev 589)
+++ trunk/ocfs2console/browser.py 2005-01-26 03:39:21 UTC (rev 590)
@@ -1,82 +0,0 @@
-# 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 pango
-
-import ocfs2
-
-from guiutil import set_props
-
-fields = ('Perms', '# Links', 'Owner', 'Group', 'Size', 'Alloc Size',
- 'Timestamp', 'Name')
-sample = ('-rw-r--r--', '1', 'manish', 'manish', '133194', '262144', 'Sep 29 12:46', 'closobo.c')
-
-class Browser:
- def __init__(self, device=None):
- self.widget = gtk.VBox(spacing=4)
-
- scrl_win = gtk.ScrolledWindow()
- scrl_win.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
- self.widget.add(scrl_win)
-
- tv = gtk.TreeView()
- scrl_win.add(tv)
-
- tv.insert_column_with_attributes(-1, 'File', gtk.CellRendererText(),
- text=0)
-
- table = gtk.Table(rows=2, columns=7)
- set_props(table, row_spacing=4,
- column_spacing=4,
- border_width=4)
- self.widget.pack_end(table, expand=False, fill=False)
-
- font = pango.FontDescription('Monospace')
-
- for i in range(0, len(fields)):
- label = gtk.Label(fields[i])
- set_props(label, xalign=0.0)
- table.attach(label, i, i + 1, 0, 1)
-
- label = gtk.Label(sample[i])
- if i == 1 or i == 4 or i == 5:
- set_props(label, xalign=1.0)
- else:
- set_props(label, xalign=0.0)
- table.attach(label, i, i + 1, 1, 2)
-
- label.modify_font(font)
-
-def main():
- import sys
-
- def dummy(*args):
- gtk.main_quit()
-
- window = gtk.Window()
- window.connect('delete_event', dummy)
-
- browser = Browser(sys.argv[1]).widget
- window.add(browser)
-
- window.show_all()
-
- gtk.main()
-
-if __name__ == '__main__':
- main()
Deleted: trunk/ocfs2console/clconfig.py
===================================================================
--- trunk/ocfs2console/clconfig.py 2005-01-26 03:34:01 UTC (rev 589)
+++ trunk/ocfs2console/clconfig.py 2005-01-26 03:39:21 UTC (rev 590)
@@ -1,66 +0,0 @@
-# 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
-
-from guiutil import set_props, error_box
-
-def cluster_configurator(parent):
- dialog = gtk.Dialog(parent=parent, title='Cluster Configurator',
- buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
- gtk.STOCK_OK, gtk.RESPONSE_OK))
-
- hbox = gtk.HBox(spacing=4)
- hbox.set_border_width(4)
- dialog.vbox.add(hbox)
-
- tv = gtk.TreeView()
-
- scrl_win = gtk.ScrolledWindow()
- set_props(scrl_win, hscrollbar_policy=gtk.POLICY_AUTOMATIC,
- vscrollbar_policy=gtk.POLICY_AUTOMATIC,
- parent=hbox)
-
- scrl_win.add(tv)
-
- frame = gtk.Frame()
- frame.set_shadow_type(gtk.SHADOW_IN)
- hbox.pack_end(frame, expand=False, fill=False)
-
- vbbox = gtk.VButtonBox()
- set_props(vbbox, layout_style=gtk.BUTTONBOX_START,
- spacing=5,
- border_width=5,
- parent=frame)
-
- button = gtk.Button('Add')
- vbbox.add(button)
-
- dialog.show_all()
-
- if dialog.run() != gtk.RESPONSE_OK:
- dialog.destroy()
- return False
-
- dialog.destroy()
- return True
-
-def main():
- cluster_configurator(None)
-
-if __name__ == '__main__':
- main()
Deleted: trunk/ocfs2console/format.py
===================================================================
--- trunk/ocfs2console/format.py 2005-01-26 03:34:01 UTC (rev 589)
+++ trunk/ocfs2console/format.py 2005-01-26 03:39:21 UTC (rev 590)
@@ -1,228 +0,0 @@
-# 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 guiutil import set_props, error_box, format_bytes
-from process import Process
-
-if hasattr(gtk, 'ComboBox'):
- class BaseCombo(gtk.ComboBox):
- def __init__(self):
- self.store = gtk.ListStore(str)
- gtk.ComboBox.__init__(self, model=self.store)
-
- cell = gtk.CellRendererText()
- self.pack_start(cell)
- self.set_attributes(cell, text=0)
-
- def get_choice(self):
- return self.store[self.get_active_iter()][0]
-
- def set_choices(self, choices):
- selected = False
-
- for choice, select in choices:
- iter = self.store.append((choice,))
-
- if select:
- self.set_active_iter(iter)
- selected = True
-
- if not selected:
- self.set_active(0)
-
-else:
- class BaseCombo(gtk.Combo):
- def __init__(self):
- gtk.Combo.__init__(self)
- self.entry.set_editable(False)
-
- def get_choice(self):
- return self.entry.get_text()
-
- def set_choices(self, choices):
- for choice, select in choices:
- item = gtk.ListItem(choice)
- item.show()
- self.list.add(item)
-
- if select:
- item.select()
-
-class ValueCombo(BaseCombo):
- def __init__(self, minimum, maximum):
- BaseCombo.__init__(self)
-
- choices = [('Auto', False)]
-
- size = minimum
- while size <= maximum:
- choices.append((format_bytes(size), False))
- size = size << 1
-
- self.set_choices(choices)
-
- def get_arg(self):
- text = self.get_choice()
-
- if text != 'Auto':
- s = text.replace(' ', '')
- s = s.replace('B', '')
- s = s.replace('bytes', '')
- return (self.arg, s)
- else:
- return None
-
-class NumNodes(gtk.SpinButton):
- def __init__(self):
- adjustment = gtk.Adjustment(4, 2, ocfs2.MAX_NODES, 1, 10)
- gtk.SpinButton.__init__(self, adjustment=adjustment)
-
- def get_arg(self):
- s = self.get_text()
-
- if s:
- return ('-n', s)
- else:
- return None
-
-class Device(BaseCombo):
- def fill(self, partitions, device):
- self.set_choices([(p, p == device) for p in partitions])
-
- def get_device(self):
- return self.get_choice()
-
-class VolumeLabel(gtk.Entry):
- def __init__(self):
- gtk.Entry.__init__(self, max=ocfs2.MAX_VOL_LABEL_LEN)
- self.set_text('oracle')
-
- def get_arg(self):
- s = self.get_text()
-
- if s:
- return ('-L', s)
- else:
- return None
-
-class ClusterSize(ValueCombo):
- def __init__(self):
- ValueCombo.__init__(self, ocfs2.MIN_CLUSTER_SIZE,
- ocfs2.MAX_CLUSTER_SIZE)
- self.arg = '-c'
-
-class BlockSize(ValueCombo):
- def __init__(self):
- ValueCombo.__init__(self, ocfs2.MIN_BLOCKSIZE,
- ocfs2.MAX_BLOCKSIZE)
- self.arg = '-b'
-
-entries = (
- ('Device', Device),
- ('Volume Label', VolumeLabel),
- ('Cluster Size', ClusterSize),
- ('Number of Nodes', NumNodes),
- ('Block Size', BlockSize)
-)
-
-def format_partition(parent, device):
- partitions = ocfs2.partition_list(unmounted=True)
-
- if not partitions:
- error_box(parent, 'No unmounted partitions')
- return False
-
- dialog = gtk.Dialog(parent=parent, title='Format',
- buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
- gtk.STOCK_OK, gtk.RESPONSE_OK))
-
- table = gtk.Table(rows=5, columns=2)
- set_props(table, row_spacing=4,
- column_spacing=4,
- border_width=4,
- parent=dialog.vbox)
-
- partitions.sort()
-
- widgets = []
- row = 0
-
- for desc, widget_type in entries:
- label = gtk.Label(desc + ':')
- set_props(label, xalign=1.0)
- table.attach(label, 0, 1, row, row + 1)
-
- widget = widget_type()
- table.attach(widget, 1, 2, row, row + 1)
-
- if widget_type == Device:
- widget.fill(partitions, device)
-
- widgets.append(widget)
-
- row = row + 1
-
- widgets[0].grab_focus()
-
- dialog.show_all()
-
- if dialog.run() != gtk.RESPONSE_OK:
- dialog.destroy()
- return False
-
- dev = widgets[0].get_device()
- msg = 'Are you sure you want to format %s?' % dev
-
- ask = gtk.MessageDialog(parent=dialog,
- flags=gtk.DIALOG_DESTROY_WITH_PARENT,
- type=gtk.MESSAGE_QUESTION,
- buttons=gtk.BUTTONS_YES_NO,
- message_format=msg)
-
- if ask.run() != gtk.RESPONSE_YES:
- dialog.destroy()
- return False
-
- command = ['mkfs.ocfs2']
- for widget in widgets[1:]:
- arg = widget.get_arg()
-
- if arg:
- command.extend(arg)
-
- command.append(dev)
-
- dialog.destroy()
-
- mkfs = Process(command, 'Format', 'Formatting...', parent)
- success, output, k = mkfs.reap()
-
- if not success:
- error_box(parent, 'Format error: %s' % output)
- return False
-
- return True
-
-def main():
- format_partition(None, None)
-
-if __name__ == '__main__':
- main()
Deleted: trunk/ocfs2console/general.py
===================================================================
--- trunk/ocfs2console/general.py 2005-01-26 03:34:01 UTC (rev 589)
+++ trunk/ocfs2console/general.py 2005-01-26 03:39:21 UTC (rev 590)
@@ -1,99 +0,0 @@
-# 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 guiutil import set_props, format_bytes
-
-fields = (
- ('Version', 'version'),
- ('Label', 's_label'),
- ('UUID', 's_uuid'),
- ('Maximum Nodes', 's_max_nodes'),
- ('Cluster Size', 's_clustersize_bits'),
- ('Block Size', 's_blocksize_bits')
-)
-
-class General:
- def __init__(self, device=None):
- self.widget = gtk.Table(rows=5, columns=2)
-
- set_props(self.widget, row_spacing=4,
- column_spacing=4,
- border_width=4)
-
- super = None
-
- if device:
- try:
- super = ocfs2.get_super(device)
- except ocfs2.error:
- pass
-
- self.pos = 0
-
- for desc, member in fields:
- if super:
- if member == 'version':
- val = '%d.%d' % super[0:2]
- elif member == 's_label':
- val = super.s_label
- if not val:
- val = 'N/A'
- else:
- val = getattr(super, member)
-
- if member.endswith('_bits'):
- val = format_bytes(1 << val)
- else:
- val = 'N/A'
-
- self.add_field(desc, val)
-
- def add_field(self, desc, val):
- label = gtk.Label(desc + ':')
- set_props(label, xalign=1.0)
- self.widget.attach(label, 0, 1, self.pos, self.pos + 1,
- xoptions=gtk.FILL, yoptions=gtk.FILL)
-
- label = gtk.Label(str(val))
- set_props(label, xalign=0.0)
- self.widget.attach(label, 1, 2, self.pos, self.pos + 1,
- xoptions=gtk.FILL, yoptions=gtk.FILL)
-
- self.pos += 1
-
-def main():
- import sys
-
- def dummy(*args):
- gtk.main_quit()
-
- window = gtk.Window()
- window.connect('delete_event', dummy)
-
- general = General(sys.argv[1]).widget
- window.add(general)
-
- window.show_all()
-
- gtk.main()
-
-if __name__ == '__main__':
- main()
Deleted: trunk/ocfs2console/guiutil.py
===================================================================
--- trunk/ocfs2console/guiutil.py 2005-01-26 03:34:01 UTC (rev 589)
+++ trunk/ocfs2console/guiutil.py 2005-01-26 03:39:21 UTC (rev 590)
@@ -1,80 +0,0 @@
-# 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
-
-def set_props(obj, **kwargs):
- for k, v in kwargs.items():
- obj.set_property(k, v)
-
-suffixes = ['K', 'MB', 'GB', 'TB']
-
-def format_bytes(bytes, show_bytes=False):
- if bytes == 1:
- return '1 byte'
- elif bytes < 1024:
- return str(bytes) + ' bytes'
-
- fbytes = float(bytes)
-
- i = -1
- while i < 3 and fbytes >= 1024:
- fbytes /= 1024
- i += 1
-
- if show_bytes:
- return '%.1f %s (%sb)' % (fbytes, suffixes[i], bytes)
- else:
- return '%.0f %s' % (fbytes, suffixes[i])
-
-def error_box(parent, msg):
- dialog = gtk.MessageDialog(parent=parent,
- flags=gtk.DIALOG_DESTROY_WITH_PARENT,
- type=gtk.MESSAGE_ERROR,
- buttons=gtk.BUTTONS_OK, message_format=msg)
- dialog.run()
- dialog.destroy()
-
-def query_text(parent, prompt):
- dialog = gtk.Dialog(parent=parent,
- flags=gtk.DIALOG_DESTROY_WITH_PARENT,
- buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
- gtk.STOCK_OK, gtk.RESPONSE_OK))
-
- table = gtk.Table(rows=1, columns=2)
- set_props(table, row_spacing=4,
- column_spacing=4,
- border_width=4,
- parent=dialog.vbox)
-
- label = gtk.Label(prompt + ':')
- set_props(label, xalign=1.0)
- table.attach(label, 0, 1, 0, 1)
-
- entry = gtk.Entry()
- table.attach(entry, 1, 2, 0, 1)
-
- dialog.show_all()
-
- if dialog.run() == gtk.RESPONSE_OK:
- text = entry.get_text()
- else:
- text = None
-
- dialog.destroy()
-
- return text
Deleted: trunk/ocfs2console/interface.py
===================================================================
--- trunk/ocfs2console/interface.py 2005-01-26 03:34:01 UTC (rev 589)
+++ trunk/ocfs2console/interface.py 2005-01-26 03:39:21 UTC (rev 590)
@@ -1,277 +0,0 @@
-# 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 guiutil import set_props, error_box, query_text
-
-from menu import Menu
-from toolbar import Toolbar
-from about import about
-from process import Process
-from format import format_partition
-from general import General
-from nodemap import NodeMap
-from browser import Browser
-from clconfig import cluster_configurator
-
-COLUMN_DEVICE = 0
-COLUMN_MOUNTPOINT = 1
-
-notebook_items = (
- ('general', 'General', General),
- ('browser', 'File Listing', Browser),
- ('nodemap', 'Configured Nodes', NodeMap),
-)
-
-def cleanup(*args):
- gtk.main_quit()
-
-class PartitionView(gtk.TreeView):
- def __init__(self, toplevel):
- store = gtk.ListStore(str, str, str)
-
- gtk.TreeView.__init__(self, store)
-
- self.toplevel = toplevel
-
- self.insert_column_with_attributes(-1, 'Device',
- gtk.CellRendererText(),
- text=COLUMN_DEVICE)
- self.insert_column_with_attributes(-1, 'Mountpoint',
- gtk.CellRendererText(),
- text=COLUMN_MOUNTPOINT)
-
- sel = self.get_selection()
- sel.connect('changed', self.on_select)
-
- def get_sel_values(self):
- sel = self.get_selection()
- store, iter = sel.get_selected()
-
- if store and iter:
- return store[iter]
- else:
- return None
-
- def get_device(self):
- selection = self.get_sel_values()
-
- if selection:
- return selection[COLUMN_DEVICE]
- else:
- return None
-
- def on_select(self, sel):
- device, mountpoint = self.get_sel_values()
-
- if mountpoint:
- self.mount_button.set_sensitive(False)
- self.unmount_button.set_sensitive(True)
- else:
- self.mount_button.set_sensitive(True)
- self.unmount_button.set_sensitive(False)
-
- update_notebook(self, device)
-
- def select_device(self, device):
- for row in self.get_model():
- if row[COLUMN_DEVICE] == device:
- sel = self.get_selection()
- sel.select_iter(row.iter)
-
- def refresh_partitions(self):
- def list_compare(store, a, b):
- d1, m1 = store[a]
- d2, m2 = store[b]
-
- if m1 and not m2:
- return -1
- elif not m1 and m2:
- return 1
- else:
- return cmp(d1, d2)
-
- self.mount_button.set_sensitive(False)
- self.unmount_button.set_sensitive(False)
-
- filter = self.filter_entry.get_text()
-
- old_device = self.get_device()
-
- store = gtk.ListStore(str, str)
- self.set_model(store)
-
- sel = self.get_selection()
- selected = False
-
- for partition in ocfs2.partition_list(filter=filter):
- iter = store.append(partition)
-
- if partition[0] == old_device:
- sel.select_iter(iter)
- selected = True
-
- store.set_sort_func(COLUMN_DEVICE, list_compare)
- store.set_sort_column_id(COLUMN_DEVICE, gtk.SORT_ASCENDING)
-
- if len(store) and not selected:
- sel.select_iter(store.get_iter_first())
-
-def mount(pv):
- device, mountpoint = pv.get_sel_values()
-
- mountpoint = query_text(pv.toplevel, 'Mountpoint')
- if not mountpoint:
- return
-
- command = ('mount', '-t', 'ocfs2', device, mountpoint)
-
- p = Process(command, 'Mount', 'Mounting...', pv.toplevel, spin_now=False)
- success, output, killed = p.reap()
-
- if not success:
- if killed:
- error_box(pv.toplevel,
- 'mount died unexpectedly! Your system is probably in '
- 'an inconsistent state. You should reboot at the '
- 'earliest opportunity')
- else:
- error_box(pv.toplevel, '%s: Could not mount %s' % (output, device))
-
- pv.refresh_partitions()
-
-def unmount(pv):
- device, mountpoint = pv.get_sel_values()
-
- command = ('umount', mountpoint)
-
- p = Process(command, 'Unmount', 'Unmounting...', pv.toplevel,
- spin_now=False)
- success, output, killed = p.reap()
-
- if success:
- pv.refresh_partitions()
- else:
- if killed:
- error_box(pv.toplevel,
- 'umount died unexpectedly! Your system is probably in '
- 'an inconsistent state. You should reboot at the '
- 'earliest opportunity')
- else:
- error_box(pv.toplevel,
- '%s: Could not unmount %s mounted on %s' %
- (output, device, mountpoint))
-
-def refresh(pv):
- pv.refresh_partitions()
-
- if len(pv.get_model()) == 0:
- update_notebook(pv, None)
-
-def update_notebook(pv, device):
- for tag, d, info in notebook_items:
- frame = getattr(pv, tag + '_frame')
- frame.child.destroy()
-
- frame.add(info(device).widget)
- frame.show_all()
-
-def format(pv):
- format_partition(pv.toplevel, pv.get_device())
- pv.refresh_partitions()
-
-def check(pv):
- pass
-
-def repair(pv):
- pass
-
-def clconfig(pv):
- cluster_configurator(pv.toplevel)
-
-def filter_update(entry, pv):
- refresh(pv)
-
-def create_window():
- window = gtk.Window()
- set_props(window, title='OCFS2 Console',
- default_width=520,
- default_height=420,
- border_width=0)
- window.connect('delete_event', cleanup)
-
- pv = PartitionView(window)
-
- vbox = gtk.VBox()
- window.add(vbox)
-
- menu = Menu(cleanup=cleanup, format=format, check=check, repair=repair,
- clconfig=clconfig, about=about)
-
- menubar = menu.get_widget(window, pv)
- vbox.pack_start(menubar, expand=False, fill=False)
-
- toolbar = Toolbar(mount=mount, unmount=unmount, refresh=refresh)
-
- tb, buttons, pv.filter_entry = toolbar.get_widgets(pv)
- vbox.pack_start(tb, expand=False, fill=False)
-
- for k, v in buttons.iteritems():
- setattr(pv, k + '_button', v)
-
- pv.filter_entry.connect('activate', filter_update, pv)
-
- vpaned = gtk.VPaned()
- vpaned.set_border_width(4)
- vbox.pack_start(vpaned, expand=True, fill=True)
-
- scrl_win = gtk.ScrolledWindow()
- set_props(scrl_win, hscrollbar_policy=gtk.POLICY_AUTOMATIC,
- vscrollbar_policy=gtk.POLICY_AUTOMATIC)
- scrl_win.add(pv)
- vpaned.pack1(scrl_win)
-
- notebook = gtk.Notebook()
- notebook.set_tab_pos(gtk.POS_TOP)
- vpaned.pack2(notebook)
-
- for tag, desc, info in notebook_items:
- frame = gtk.Frame()
- set_props(frame, shadow=gtk.SHADOW_NONE,
- border_width=0)
-
- tag = tag + '_frame'
- setattr(pv, tag, frame)
-
- frame.add(info().widget)
- frame.show_all()
-
- notebook.add_with_properties(frame, 'tab_label', desc)
-
- pv.refresh_partitions()
-
- window.show_all()
-
-def main():
- create_window()
- gtk.main()
-
-if __name__ == '__main__':
- main()
Deleted: trunk/ocfs2console/menu.py
===================================================================
--- trunk/ocfs2console/menu.py 2005-01-26 03:34:01 UTC (rev 589)
+++ trunk/ocfs2console/menu.py 2005-01-26 03:39:21 UTC (rev 590)
@@ -1,94 +0,0 @@
-# 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
-
-try:
- stock_about = gtk.STOCK_ABOUT
-except AttributeError:
- stock_about = ''
-
-menu_data = (
- ('/_File', None, None, 0, '<Branch>'),
- ('/File/_Quit', None, 'cleanup', 0, '<StockItem>',
- gtk.STOCK_QUIT),
- ('/_Tasks', None, None, 0, '<Branch>'),
- ('/Tasks/_Format...', '<control>F', 'format'),
- ('/Tasks/---', None, None, 0, '<Separator>'),
- ('/Tasks/Chec_k...', '<control>K', 'check'),
- ('/Tasks/_Repair...', '<control>R', 'repair'),
- ('/Tasks/---', None, None, 0, '<Separator>'),
- ('/Tasks/_Cluster Config...', '<control>C', 'clconfig'),
- ('/_Help', None, None, 0, '<Branch>'),
- ('/Help/_About', None, 'about', 0, '<StockItem>',
- stock_about)
-)
-
-class Menu:
- def __init__(self, **callbacks):
- self.items = []
-
- for i in menu_data:
- item = list(i)
-
- if i[2]:
- def make_cb():
- callback = callbacks[i[2]]
-
- def cb(d, a, w):
- callback(d)
-
- return cb
-
- item[2] = make_cb()
-
- self.items.append(tuple(item))
-
- def get_widget(self, window, data=None):
- accel_group = gtk.AccelGroup()
- window.add_accel_group(accel_group)
-
- item_factory = gtk.ItemFactory(gtk.MenuBar, '<main>', accel_group)
- item_factory.create_items(self.items, data)
-
- return item_factory.get_widget('<main>')
-
-def main():
- def dummy(*args):
- gtk.main_quit()
-
- cb = {}
- for i in menu_data:
- if i[2]:
- cb[i[2]] = dummy
-
- menubar = Menu(**cb)
-
- window = gtk.Window()
- window.connect('delete_event', dummy)
-
- vbox = gtk.VBox()
- window.add(vbox)
-
- vbox.add(menubar.get_widget(window))
-
- window.show_all()
-
- gtk.main()
-
-if __name__ == '__main__':
- main()
Deleted: trunk/ocfs2console/nodemap.py
===================================================================
--- trunk/ocfs2console/nodemap.py 2005-01-26 03:34:01 UTC (rev 589)
+++ trunk/ocfs2console/nodemap.py 2005-01-26 03:39:21 UTC (rev 590)
@@ -1,84 +0,0 @@
-# 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
-
-COLUMN_SLOT = 0
-COLUMN_NAME = 1
-COLUMN_IP = 2
-COLUMN_PORT = 3
-COLUMN_UUID = 4
-
-class NodeMap:
- def __init__(self, device=None):
- self.device = device
-
- info = self.info()
-
- if info:
- self.widget = gtk.ScrolledWindow()
- self.widget.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
- self.widget.add(info)
- else:
- self.widget = gtk.Label('Invalid device')
-
- def info(self):
- if not self.device:
- return None
-
- store = gtk.ListStore(int, str, str, int, str)
-
- tv = gtk.TreeView(store)
-
- tv.insert_column_with_attributes(-1, 'Slot #',
- gtk.CellRendererText(),
- text=COLUMN_SLOT)
- tv.insert_column_with_attributes(-1, 'Node Name',
- gtk.CellRendererText(),
- text=COLUMN_NAME)
- tv.insert_column_with_attributes(-1, 'IP Address',
- gtk.CellRendererText(),
- text=COLUMN_IP)
- tv.insert_column_with_attributes(-1, 'Port',
- gtk.CellRendererText(),
- text=COLUMN_PORT)
- tv.insert_column_with_attributes(-1, 'UUID',
- gtk.CellRendererText(),
- text=COLUMN_UUID)
-
- return tv
-
-def main():
- import sys
-
- def dummy(*args):
- gtk.main_quit()
-
- window = gtk.Window()
- window.connect('delete_event', dummy)
-
- nodemap = NodeMap(sys.argv[1]).widget
- window.add(nodemap)
-
- window.show_all()
-
- gtk.main()
-
-if __name__ == '__main__':
- main()
Modified: trunk/ocfs2console/ocfs2console
===================================================================
--- trunk/ocfs2console/ocfs2console 2005-01-26 03:34:01 UTC (rev 589)
+++ trunk/ocfs2console/ocfs2console 2005-01-26 03:39:21 UTC (rev 590)
@@ -3,15 +3,16 @@
# XXX: for production
#!/usr/bin/python -W ignore::DeprecationWarning
-from ocfs2console.about import process_info_args
+from ocfs2interface.about import process_info_args
process_info_args()
try:
import gtk
except RuntimeError:
import sys
- print >>sys.stderr, 'ocfs2console needs an X11 display'
+ print >>sys.stderr, '''ERROR: ocfs2console needs an X11 display.
+Make sure a proper setup for your display environment exists.\n'''
sys.exit(1)
-from ocfs2console.interface import main
+from ocfs2interface.main import main
main()
Added: trunk/ocfs2console/ocfs2interface/Makefile
===================================================================
--- trunk/ocfs2console/ocfs2interface/Makefile 2005-01-26 03:34:01 UTC (rev 589)
+++ trunk/ocfs2console/ocfs2interface/Makefile 2005-01-26 03:39:21 UTC (rev 590)
@@ -0,0 +1,67 @@
+TOPDIR = ../..
+
+include $(TOPDIR)/Preamble.make
+
+WARNINGS = -Wall
+
+ifdef OCFS_DEBUG
+OPTS = -g
+endif
+OPTS = -g
+
+CFLAGS = $(OPTS) $(WARNINGS) -fPIC
+
+LIBOCFS2_CFLAGS = -I$(TOPDIR)/libocfs2/include
+LIBOCFS2_LIBS = -L$(TOPDIR)/libocfs2 -locfs2
+LIBOCFS2_DEPS = $(TOPDIR)/libocfs2/libocfs2.a
+
+DEFINES = -DOCFS2_FLAT_INCLUDES -DG_DISABLE_DEPRECATED
+INCLUDES = $(LIBOCFS2_CFLAGS) $(PYTHON_INCLUDES) $(GLIB_CFLAGS)
+
+OPTIMIZE = -O2
+OPTIMIZE = -O0
+
+CFLAGS += $(OPTIMIZE)
+
+CBITS = \
+ ocfsplist.c
+
+HBITS = $(subst .c,.h,$(CBITS))
+
+CFILES = $(CBITS) ocfs2module.c
+HFILES = $(HBITS)
+
+OBJS = $(subst .c,.o,$(CFILES))
+
+LIBRARIES = ocfs2module.so
+
+PYSRC = \
+ __init__.py \
+ about.py \
+ browser.py \
+ clconfig.py \
+ format.py \
+ general.py \
+ guiutil.py \
+ interface.py \
+ menu.py \
+ nodemap.py \
+ process.py \
+ toolbar.py
+
+PYLIB = $(LIBRARIES) $(PYSRC)
+
+INSTALL_RULES = install-pylib
+
+DIST_FILES = $(CFILES) $(HFILES) $(PYSRC)
+
+ocfs2module.so: $(OBJS) $(LIBOCFS2_DEPS)
+ $(LINK) -shared $(LIBOCFS2_LIBS) $(COM_ERR_LIBS) $(GLIB_LIBS)
+
+install-pylib:
+ $(SHELL) $(TOPDIR)/mkinstalldirs $(DESTDIR)$(pyexecdir)/ocfs2interface
+ for f in $(PYLIB); do \
+ $(INSTALL_DATA) $$f $(DESTDIR)$(pyexecdir)/ocfs2interface/$$f; \
+ done
+
+include $(TOPDIR)/Postamble.make
Copied: trunk/ocfs2console/ocfs2interface/__init__.py (from rev 588, trunk/ocfs2console/__init__.py)
Copied: trunk/ocfs2console/ocfs2interface/about.py (from rev 588, trunk/ocfs2console/about.py)
Copied: trunk/ocfs2console/ocfs2interface/browser.py (from rev 588, trunk/ocfs2console/browser.py)
Copied: trunk/ocfs2console/ocfs2interface/clconfig.py (from rev 588, trunk/ocfs2console/clconfig.py)
Copied: trunk/ocfs2console/ocfs2interface/format.py (from rev 588, trunk/ocfs2console/format.py)
Copied: trunk/ocfs2console/ocfs2interface/general.py (from rev 588, trunk/ocfs2console/general.py)
Copied: trunk/ocfs2console/ocfs2interface/guiutil.py (from rev 588, trunk/ocfs2console/guiutil.py)
Copied: trunk/ocfs2console/ocfs2interface/interface.py (from rev 588, trunk/ocfs2console/interface.py)
Copied: trunk/ocfs2console/ocfs2interface/menu.py (from rev 588, trunk/ocfs2console/menu.py)
Copied: trunk/ocfs2console/ocfs2interface/nodemap.py (from rev 588, trunk/ocfs2console/nodemap.py)
Copied: trunk/ocfs2console/ocfs2interface/ocfs2module.c (from rev 588, trunk/ocfs2console/ocfs2module.c)
Copied: trunk/ocfs2console/ocfs2interface/ocfsplist.c (from rev 588, trunk/ocfs2console/ocfsplist.c)
Copied: trunk/ocfs2console/ocfs2interface/ocfsplist.h (from rev 588, trunk/ocfs2console/ocfsplist.h)
Copied: trunk/ocfs2console/ocfs2interface/process.py (from rev 588, trunk/ocfs2console/process.py)
Copied: trunk/ocfs2console/ocfs2interface/toolbar.py (from rev 588, trunk/ocfs2console/toolbar.py)
Deleted: trunk/ocfs2console/ocfs2module.c
===================================================================
--- trunk/ocfs2console/ocfs2module.c 2005-01-26 03:34:01 UTC (rev 589)
+++ trunk/ocfs2console/ocfs2module.c 2005-01-26 03:39:21 UTC (rev 590)
@@ -1,241 +0,0 @@
-/*
- * ocfs2module.c
- *
- * OCFS2 python binding.
- *
- * Copyright (C) 2004, 2005 Oracle. All rights reserved.
- *
- * Author: Manish Singh <manish.singh at oracle.com>
- *
- * 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 recieved 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.
- */
-
-#include "Python.h"
-#include "structseq.h"
-
-#include <glib.h>
-
-#include "ocfs2.h"
-
-#include "ocfsplist.h"
-
-
-#define MAX_CLUSTER_SIZE 1048576
-#define MIN_CLUSTER_SIZE 4096
-
-
-static PyObject *ocfs2_error;
-
-static PyObject *
-partition_list (PyObject *self,
- PyObject *args,
- PyObject *kwargs)
-{
- gchar *filter = NULL;
- gboolean unmounted = FALSE, bail = FALSE;
- GList *list, *last;
- PyObject *ret, *val;
- OcfsPartitionInfo *info;
-
- static gchar *kwlist[] = { "filter", "unmounted", NULL };
-
- if (!PyArg_ParseTupleAndKeywords (args, kwargs,
- "|si:partition_list", kwlist,
- &filter, &unmounted))
- return NULL;
-
- list = ocfs_partition_list (filter, unmounted);
-
- ret = PyList_New (0);
- if (ret == NULL)
- bail = TRUE;
-
- while (list)
- {
-
- if (!bail)
- {
- if (!unmounted)
- {
- info = list->data;
- val = Py_BuildValue ("(ss)", info->device, info->mountpoint);
- }
- else
- val = PyString_FromString (list->data);
-
- if (val)
- {
- PyList_Append (ret, val);
- Py_DECREF (val);
- }
- else
- bail = TRUE;
- }
-
- if (!unmounted)
- {
- g_free (info->device);
- g_free (info->mountpoint);
- g_free (info);
- }
- else
- g_free (list->data);
-
- last = list;
- list = list->next;
-
- g_list_free_1 (last);
- }
-
- if (bail)
- {
- Py_XDECREF (ret);
- return NULL;
- }
- else
- return ret;
-}
-
-static PyStructSequence_Field struct_ocfs2_super_fields[] = {
- {"s_major_rev_level", "major revision level"},
- {"s_minor_rev_level", "minor revision level"},
- {"s_blocksize_bits", "blocksize bits"},
- {"s_clustersize_bits", "cluster size bits"},
- {"s_max_nodes", "maximum nodes"},
- {"s_label", "volume label"},
- {"s_uuid", "UUID"},
- {0}
-};
-
-struct PyStructSequence_Desc struct_ocfs2_super_desc = {
- "ocfs2.struct_ocfs2_super",
- NULL,
- struct_ocfs2_super_fields,
- 7,
-};
-
-static PyTypeObject StructOcfs2SuperType;
-
-static PyObject *
-get_super (PyObject *self,
- PyObject *args)
-{
- gchar *device;
- errcode_t ret;
- ocfs2_filesys *fs;
- PyObject *v;
- gint index = 0;
- GString *uuid;
- gint i;
-
- static gchar *fmt[] = { "%02x", "%02x", "%02x", "%02x",
- "-%02x", "%02x", "-%02x", "%02x", "-%02x", "%02x",
- "-%02x", "%02x", "%02x", "%02x", "%02x", "%02x" };
-
- if (!PyArg_ParseTuple (args, "s:get_super", &device))
- return NULL;
-
- ret = ocfs2_open (device, OCFS2_FLAG_RO, 0, 0, &fs);
- if (ret)
- {
- PyErr_SetString (ocfs2_error, error_message (ret));
- return NULL;
- }
-
- v = PyStructSequence_New (&StructOcfs2SuperType);
- if (v == NULL)
- return NULL;
-
-#define SET(m) \
- PyStructSequence_SET_ITEM (v, index++, PyInt_FromLong \
- (OCFS2_RAW_SB (fs->fs_super)->m));
-
- SET (s_major_rev_level);
- SET (s_minor_rev_level);
- SET (s_blocksize_bits);
- SET (s_clustersize_bits);
- SET (s_max_nodes);
-
-#undef SET
-#define SET(m) \
- PyStructSequence_SET_ITEM \
- (v, index++, PyString_FromString (OCFS2_RAW_SB (fs->fs_super)->m));
-
- PyStructSequence_SET_ITEM
- (v, index++, PyString_FromString (OCFS2_RAW_SB (fs->fs_super)->s_label));
-
-#undef SET
-
- uuid = g_string_sized_new (32);
-
- for (i = 0; i < 16; i++)
- g_string_append_printf (uuid, fmt[i],
- OCFS2_RAW_SB (fs->fs_super)->s_uuid[i]);
-
- PyStructSequence_SET_ITEM (v, index++, PyString_FromString (uuid->str));
-
- g_string_free (uuid, TRUE);
-
- ocfs2_close (fs);
-
- if (PyErr_Occurred())
- {
- Py_DECREF (v);
- return NULL;
- }
-
- return v;
-}
-
-static PyMethodDef ocfs2_methods[] = {
- {"partition_list", (PyCFunction)partition_list, METH_VARARGS | METH_KEYWORDS},
- {"get_super", (PyCFunction)get_super, METH_VARARGS},
- {NULL, NULL} /* sentinel */
-};
-
-void
-initocfs2 (void)
-{
- PyObject *m;
-
- initialize_ocfs_error_table ();
-
- m = Py_InitModule ("ocfs2", ocfs2_methods);
-
- PyStructSequence_InitType (&StructOcfs2SuperType, &struct_ocfs2_super_desc);
- Py_INCREF (&StructOcfs2SuperType);
- PyModule_AddObject (m, "struct_ocfs2_super",
- (PyObject *) &StructOcfs2SuperType);
-
- ocfs2_error = PyErr_NewException ("ocfs2.error", PyExc_RuntimeError, NULL);
- if (ocfs2_error)
- {
- Py_INCREF (ocfs2_error);
- PyModule_AddObject (m, "error", ocfs2_error);
- }
-
- PyModule_AddIntConstant (m, "MAX_VOL_LABEL_LEN", MAX_VOL_LABEL_LEN);
- PyModule_AddIntConstant (m, "MAX_NODES", OCFS2_MAX_NODES);
-
- PyModule_AddIntConstant (m, "MIN_BLOCKSIZE", OCFS2_MIN_BLOCKSIZE);
- PyModule_AddIntConstant (m, "MAX_BLOCKSIZE", OCFS2_MAX_BLOCKSIZE);
-
- PyModule_AddIntConstant (m, "MIN_CLUSTER_SIZE", MIN_CLUSTER_SIZE);
- PyModule_AddIntConstant (m, "MAX_CLUSTER_SIZE", MAX_CLUSTER_SIZE);
-
- if (PyErr_Occurred ())
- Py_FatalError ("can't initialise module ocfs2");
-}
Deleted: trunk/ocfs2console/ocfsplist.c
===================================================================
--- trunk/ocfs2console/ocfsplist.c 2005-01-26 03:34:01 UTC (rev 589)
+++ trunk/ocfs2console/ocfsplist.c 2005-01-26 03:39:21 UTC (rev 590)
@@ -1,326 +0,0 @@
-/*
- * ocfsplist.c
- *
- * Create a list of valid partitions
- *
- * Copyright (C) 2002 Oracle Corporation. 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.
- *
- * Author: Manish Singh
- */
-
-#include <ctype.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <fcntl.h>
-
-#include <glib.h>
-
-#include "ocfs2.h"
-
-#include "ocfsplist.h"
-
-
-typedef struct _BuildData BuildData;
-
-struct _BuildData
-{
- GPatternSpec *filter;
- gboolean unmounted;
-
- GList *list;
-};
-
-
-static gboolean is_ocfs2_partition (const gchar *device);
-static gboolean valid_device (const gchar *device,
- GPatternSpec *filter,
- gboolean no_ocfs_check);
-static void partition_info_fill (GHashTable *info);
-static gboolean list_builder (gpointer key,
- gpointer value,
- gpointer user_data);
-
-
-static gboolean
-is_ocfs2_partition (const gchar *device)
-{
- errcode_t ret;
- ocfs2_filesys *fs;
-
- ret = ocfs2_open (device, OCFS2_FLAG_RO, 0, 0, &fs);
-
- if (ret)
- return FALSE;
-
- ocfs2_close (fs);
- return TRUE;
-}
-
-static gboolean
-valid_device (const gchar *device,
- GPatternSpec *filter,
- gboolean no_ocfs_check)
-{
- gboolean is_bad = FALSE;
- struct stat sbuf;
- FILE *f;
- gchar buf[100], *proc, *d;
- gint i, fd;
-
- if (filter && !g_pattern_match_string (filter, device))
- return FALSE;
-
- if ((stat (device, &sbuf) != 0) ||
- (!S_ISBLK (sbuf.st_mode)) ||
- ((sbuf.st_mode & 0222) == 0))
- return FALSE;
-
- if (strncmp ("/dev/hd", device, 7) == 0)
- {
- i = strlen (device) - 1;
- while (i > 5 && isdigit (device[i]))
- i--;
-
- d = g_strndup (device + 5, i + 1);
- proc = g_strconcat ("/proc/ide/", d, "/media", NULL);
- g_free (d);
-
- f = fopen (proc, "r");
- g_free (proc);
-
- if (f != NULL && fgets (buf, sizeof (buf), f))
- is_bad = ((strncmp (buf, "cdrom", 5) == 0) ||
- (strncmp (buf, "tape", 4) == 0));
-
- if (f)
- fclose (f);
-
- if (is_bad)
- return FALSE;
- }
-
-#ifndef DEVEL_MACHINE
- fd = open (device, O_RDWR);
- if (fd == -1)
- return FALSE;
- close (fd);
-
- return no_ocfs_check ? TRUE : is_ocfs2_partition (device);
-#else
- fd = 0;
- return TRUE;
-#endif
-}
-
-static void
-partition_info_fill (GHashTable *info)
-{
- FILE *proc;
- gchar line[100], name[100], *device;
- GSList *list;
- gint i;
- gchar *p;
-
- proc = fopen ("/proc/partitions", "r");
- if (proc == NULL)
- return;
-
- while (fgets (line, sizeof(line), proc) != NULL)
- {
- if (sscanf(line, "%*d %*d %*d %99[^ \t\n]", name) != 1)
- continue;
-
- device = g_strconcat ("/dev/", name, NULL);
-
- i = strlen (device) - 1;
- if (isdigit (device[i]))
- {
- while (i > 0 && isdigit (device[i]))
- i--;
-
- p = g_strndup (device, i + 1);
- list = g_hash_table_lookup (info, p);
-
- if (list == NULL)
- {
- list = g_slist_prepend (NULL, device);
- g_hash_table_insert (info, p, list);
- }
- else
- {
- if (strcmp (p, list->data) == 0)
- {
- g_free (list->data);
- list->data = device;
- }
- else
- g_slist_append (list, device);
-
- g_free (p);
- }
- }
- else if (!g_hash_table_lookup (info, device))
- {
- list = g_slist_prepend (NULL, g_strdup (device));
- g_hash_table_insert (info, device, list);
- }
- else
- g_free (device);
- }
-
- fclose (proc);
-}
-
-static gboolean
-list_builder (gpointer key,
- gpointer value,
- gpointer user_data)
-{
- BuildData *bdata;
- GSList *list, *last;
- gchar *device;
- gchar mountpoint[PATH_MAX];
- OcfsPartitionInfo *info;
- gint flags;
- errcode_t ret;
-
- bdata = user_data;
- list = value;
-
- while (list)
- {
- device = list->data;
-
- if (valid_device (device, bdata->filter, bdata->unmounted))
- {
- info = g_new (OcfsPartitionInfo, 1);
-
- info->device = g_strdup (device);
-
- ret = ocfs2_check_mount_point (device, &flags, mountpoint, PATH_MAX);
-
- if (ret == 0)
- {
- if (flags & OCFS2_MF_MOUNTED)
- info->mountpoint = g_strdup (mountpoint);
- else
- info->mountpoint = NULL;
- }
- else
- info->mountpoint = NULL;
-
- if (bdata->unmounted)
- {
- if (info->mountpoint)
- {
- g_free (info->mountpoint);
- g_free (info->device);
- }
- else
- bdata->list = g_list_prepend (bdata->list, info->device);
-
- g_free (info);
- }
- else
- bdata->list = g_list_prepend (bdata->list, info);
- }
-
- last = list;
- list = list->next;
-
- g_free (device);
- g_slist_free_1 (last);
- }
-
- g_free (key);
-
- return TRUE;
-}
-
-#ifdef LIST_TEST_HASH
-static void
-print_hash (gpointer key,
- gpointer value,
- gpointer user_data)
-{
- GSList *list;
-
- g_print ("Key: %s; Values:", (gchar *) key);
- for (list = value; list != NULL; list = list->next)
- g_print (" %s", (gchar *) list->data);
- g_print ("\n");
-}
-#endif
-
-GList *
-ocfs_partition_list (const gchar *filter,
- gboolean unmounted)
-{
- GHashTable *info;
- BuildData bdata = { NULL, unmounted, NULL };
-
- if (filter && *filter)
- bdata.filter = g_pattern_spec_new (filter);
-
- info = g_hash_table_new (g_str_hash, g_str_equal);
-
- partition_info_fill (info);
-
-#ifdef LIST_TEST_HASH
- g_hash_table_foreach (info, print_hash, NULL);
-#endif
-
- g_hash_table_foreach_remove (info, list_builder, &bdata);
-
- g_hash_table_destroy (info);
-
- return bdata.list;
-}
-
-#ifdef LIST_TEST
-int
-main (int argc,
- char **argv)
-{
- GList *plist, *list;
- OcfsPartitionInfo *info;
-
- g_print ("All:\n");
-
- plist = ocfs_partition_list (NULL, FALSE);
-
- for (list = plist; list; list = list->next)
- {
- info = list->data;
- g_print ("Device: %s; Mountpoint %s\n", info->device, info->mountpoint);
- }
-
- g_print ("Unmounted:\n");
-
- plist = ocfs_partition_list (TRUE);
-
- for (list = plist; list; list = list->next)
- g_print ("Device: %s\n", (gchar *) list->data);
-
- return 0;
-}
-#endif
Deleted: trunk/ocfs2console/ocfsplist.h
===================================================================
--- trunk/ocfs2console/ocfsplist.h 2005-01-26 03:34:01 UTC (rev 589)
+++ trunk/ocfs2console/ocfsplist.h 2005-01-26 03:39:21 UTC (rev 590)
@@ -1,45 +0,0 @@
-/*
- * ocfsplist.h
- *
- * Function prototypes for related 'C' file.
- *
- * Copyright (C) 2002 Oracle Corporation. 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.
- *
- * Author: Manish Singh
- */
-
-#ifndef __OCFS_PARTITION_LIST_H__
-#define __OCFS_PARTITION_LIST_H__
-
-#include <glib.h>
-
-
-typedef struct _OcfsPartitionInfo OcfsPartitionInfo;
-
-struct _OcfsPartitionInfo
-{
- gchar *device;
- gchar *mountpoint;
-};
-
-
-GList *ocfs_partition_list (const gchar *filter,
- gboolean unmounted);
-
-
-#endif /* __OCFS_PARTITION_LIST_H__ */
Deleted: trunk/ocfs2console/process.py
===================================================================
--- trunk/ocfs2console/process.py 2005-01-26 03:34:01 UTC (rev 589)
+++ trunk/ocfs2console/process.py 2005-01-26 03:39:21 UTC (rev 590)
@@ -1,169 +0,0 @@
-# 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 os
-import types
-import fcntl
-import popen2
-
-import gobject
-import gtk
-
-from guiutil import set_props
-
-INTERVAL = 100
-TIMEOUT = 10000
-
-class Process:
- def __init__(self, command, title, desc, parent=None, spin_now=True):
- if isinstance(command, types.StringTypes):
- if len(command.split(None, 1)) < 2:
- command = (command,)
-
- self.command = command
-
- self.title = title
- self.desc = desc
-
- self.parent = parent
-
- self.spin_now = spin_now
-
- self.pipe = popen2.Popen4(self.command)
-
- def reap(self):
- self.success = False
- self.killed = False
-
- self.count = TIMEOUT // INTERVAL
- self.threshold = self.count - INTERVAL * 10
-
- self.dialog = None
-
- if self.spin_now:
- self.count = TIMEOUT * 60
- self.make_progress_box()
-
- timeout_id = gobject.timeout_add(INTERVAL, self.timeout)
-
- fromchild = self.pipe.fromchild
-
- fileno = fromchild.fileno()
- flags = fcntl.fcntl(fileno, fcntl.F_GETFL, 0)
- flags = flags | os.O_NONBLOCK
- fcntl.fcntl(fileno, fcntl.F_SETFL, flags)
-
- self.output = ''
- output_id = gobject.io_add_watch(fromchild, gobject.IO_IN, self.read)
-
- gtk.main()
-
- if self.dialog:
- self.dialog.destroy()
-
- gobject.source_remove(output_id)
- gobject.source_remove(timeout_id)
-
- if not self.success:
- if self.killed:
- if self.output:
- self.output += '\n'
-
- self.output += 'Killed prematurely.'
-
- return self.success, self.output, self.killed
-
- def timeout(self):
- self.count = self.count - 1
-
- ret = self.pipe.poll()
-
- if ret != -1:
- self.success = not os.WEXITSTATUS(ret)
- gtk.main_quit()
- return True
-
- if self.count < 1:
- self.kill()
- return True
-
- if self.count < self.threshold and not self.dialog:
- self.make_progess_box()
-
- if self.dialog:
- self.pbar.pulse()
-
- return True
-
- def kill(self):
- self.success = False
- self.killed = True
-
- os.kill(self.pipe.pid, 15)
- gobject.timeout_add(INTERVAL * 5, self.kill_timeout)
-
- gtk.main_quit()
-
- def kill_timeout(self):
- if self.pipe.poll() == -1:
- os.kill(self.pipe.pid, 9)
- self.kill_9 = True
-
- return False
-
- def make_progress_box(self):
- self.dialog = gtk.Window()
- set_props(self.dialog, title=self.title,
- resizable=False,
- modal=True,
- type_hint=gtk.gdk.WINDOW_TYPE_HINT_DIALOG)
-
- def ignore(w, e):
- return True
- self.dialog.connect('delete-event', ignore)
-
- self.dialog.set_transient_for(self.parent)
-
- vbox = gtk.VBox()
- set_props(vbox, spacing=0,
- homogeneous=False,
- border_width=4,
- parent=self.dialog)
-
- label = gtk.Label(self.desc + '...')
- vbox.pack_start(label, expand=False, fill=False)
-
- self.pbar = gtk.ProgressBar()
- vbox.pack_start(self.pbar, expand=False, fill=False)
-
- self.dialog.show_all()
-
- def read(self, fd, cond):
- if cond & gtk.gdk.INPUT_READ:
- try:
- self.output += fd.read(1024)
- except IOError, e:
- return False
-
- return True
-
-def main():
- process = Process('echo Hello; sleep 10', 'Sleep', 'Sleeping')
- print process.reap()
-
-if __name__ == '__main__':
- main()
Deleted: trunk/ocfs2console/toolbar.py
===================================================================
--- trunk/ocfs2console/toolbar.py 2005-01-26 03:34:01 UTC (rev 589)
+++ trunk/ocfs2console/toolbar.py 2005-01-26 03:39:21 UTC (rev 590)
@@ -1,89 +0,0 @@
-# OCFS2Console - GUI frontend for OCFS2 management and debugging
-# Copyright (C) 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
-
-toolbar_data = (
- ('Mount', gtk.STOCK_EXECUTE, 'mount'),
- ('Unmount', gtk.STOCK_STOP, 'unmount'),
- ('Refresh', gtk.STOCK_REFRESH, 'refresh')
-)
-
-class Toolbar:
- def __init__(self, **callbacks):
- self.callbacks = callbacks
-
- def get_widgets(self, data=None):
- toolbar = gtk.Toolbar()
- items = {}
-
- for i in toolbar_data:
- def make_cb():
- callback = self.callbacks[i[2]]
-
- def cb(w, d=None):
- callback(d)
-
- return cb
-
- icon = gtk.Image()
- icon.set_from_stock(i[1], gtk.ICON_SIZE_BUTTON)
- items[i[2]] = toolbar.append_item(i[0], i[0], None, icon,
- make_cb(), data)
-
- toolbar.append_space()
-
- filter_box, entry = self.get_filter_box()
- toolbar.append_widget(filter_box, 'Partition name filter', None)
-
- return toolbar, items, entry
-
- def get_filter_box(self):
- hbox = gtk.HBox(False, 4)
-
- label = gtk.Label('Filter:')
- hbox.pack_start(label, expand=False, fill=False)
-
- entry = gtk.Entry()
- hbox.pack_end(entry)
-
- return hbox, entry
-
-def main():
- def dummy(*args):
- gtk.main_quit()
-
- cb = {}
- for i in toolbar_data:
- cb[i[2]] = dummy
-
- toolbar = Toolbar(**cb)
-
- window = gtk.Window()
- window.connect('delete_event', dummy)
-
- vbox = gtk.VBox()
- window.add(vbox)
-
- vbox.add(toolbar.get_widgets()[0])
-
- window.show_all()
-
- gtk.main()
-
-if __name__ == '__main__':
- main()
More information about the Ocfs2-tools-commits
mailing list