[Ocfs2-tools-commits] manish commits r657 -
trunk/ocfs2console/ocfs2interface
svn-commits at oss.oracle.com
svn-commits at oss.oracle.com
Thu Mar 17 21:04:59 CST 2005
Author: manish
Date: 2005-03-17 21:04:57 -0600 (Thu, 17 Mar 2005)
New Revision: 657
Added:
trunk/ocfs2console/ocfs2interface/fsck.py
Modified:
trunk/ocfs2console/ocfs2interface/menu.py
Log:
fsck in a vte terminal widget
Added: trunk/ocfs2console/ocfs2interface/fsck.py
===================================================================
--- trunk/ocfs2console/ocfs2interface/fsck.py 2005-03-18 02:31:05 UTC (rev 656)
+++ trunk/ocfs2console/ocfs2interface/fsck.py 2005-03-18 03:04:57 UTC (rev 657)
@@ -0,0 +1,116 @@
+# 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 os
+
+import gobject
+import gtk
+
+from guiutil import set_props
+
+try:
+ import vte
+except ImportError:
+ fsck_ok = False
+else:
+ fsck_ok = True
+
+def fsck(parent, device, check=False):
+ if check:
+ check_str = 'check'
+ else:
+ check_str = 'repair'
+
+ title = 'File System ' + check_str.capitalize()
+
+ dialog = gtk.Dialog(parent=parent, title=title,
+ buttons=(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE))
+
+ label = gtk.Label(title)
+ label.set_alignment(xalign=0.0, yalign=0.5)
+ dialog.vbox.pack_start(label)
+
+ frame = gtk.Frame()
+ frame.set_shadow_type(gtk.SHADOW_IN)
+ dialog.vbox.pack_end(frame)
+
+ hbox = gtk.HBox()
+ frame.add(hbox)
+
+ terminal = vte.Terminal()
+ terminal.set_scrollback_lines(2048)
+ terminal.set_font_from_string('monospace 12')
+ hbox.pack_start(terminal)
+
+ scrollbar = gtk.VScrollbar()
+ scrollbar.set_adjustment(terminal.get_adjustment())
+ hbox.pack_end(scrollbar)
+
+ dialog.finished = False
+ terminal.connect('child-exited', child_exited, dialog)
+
+ dialog.pid = -1
+ command = fsck_command(device, check)
+ gobject.idle_add(start_command, terminal, command, dialog)
+
+ dialog.show_all()
+
+ while 1:
+ dialog.run()
+
+ if dialog.finished:
+ break
+
+ msg = ('File system %s is still running. You should not shut close '
+ 'this window until it is finished' % check_str)
+
+ info = gtk.MessageDialog(parent=dialog,
+ flags=gtk.DIALOG_DESTROY_WITH_PARENT,
+ type=gtk.MESSAGE_WARNING,
+ buttons=gtk.BUTTONS_CLOSE,
+ message_format=msg)
+ info.run()
+ info.destroy()
+
+ dialog.destroy()
+
+def start_command(terminal, command, dialog):
+ terminal.fork_command(command=command[0], argv=command)
+ return False
+
+def child_exited(terminal, dialog):
+ dialog.finished = True
+
+def fsck_command(device, check):
+ command = ['fsck.ocfs2']
+
+ if check:
+ command.append('-n')
+ else:
+ command.append('-y')
+
+ command.append(device)
+
+ realcommand = '%s; sleep 60' % ' '.join(command)
+
+ return ['/bin/sh', '-c', realcommand]
+
+def main():
+ fsck(None, '/dev/sdb1', check=True)
+
+if __name__ == '__main__':
+ main()
Modified: trunk/ocfs2console/ocfs2interface/menu.py
===================================================================
--- trunk/ocfs2console/ocfs2interface/menu.py 2005-03-18 02:31:05 UTC (rev 656)
+++ trunk/ocfs2console/ocfs2interface/menu.py 2005-03-18 03:04:57 UTC (rev 657)
@@ -17,27 +17,49 @@
import gtk
+from fsck import fsck_ok
+
try:
stock_about = gtk.STOCK_ABOUT
except AttributeError:
stock_about = ''
-menu_data = (
+file_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'),
+ gtk.STOCK_QUIT)
+)
+
+help_menu_data = (
('/_Help', None, None, 0, '<Branch>'),
('/Help/_About', None, 'about', 0, '<StockItem>',
stock_about)
)
+if fsck_ok:
+ task_menu_fsck_data = (
+ ('/Tasks/---', None, None, 0,
+ '<Separator>'),
+ ('/Tasks/Chec_k...', '<control>K', 'check'),
+ ('/Tasks/_Repair...', '<control>R', 'repair'),
+ )
+else:
+ task_menu_fsck_data = ()
+
+task_menu_head_data = (
+ ('/_Tasks', None, None, 0, '<Branch>'),
+ ('/Tasks/_Format...', '<control>F', 'format')
+)
+
+task_menu_tail_data = (
+ ('/Tasks/---', None, None, 0, '<Separator>'),
+ ('/Tasks/_Cluster Config...', '<control>C', 'clconfig'),
+)
+
+task_menu_data = task_menu_head_data + task_menu_fsck_data + task_menu_tail_data
+
+menu_data = file_menu_data + task_menu_data + help_menu_data
+
class Menu:
def __init__(self, **callbacks):
self.items = []
More information about the Ocfs2-tools-commits
mailing list