This email list is read-only. Emails sent to this list will be discarded ---------------------------------- src/kvm-launcher.glade | 99 +++++++++++++++++++++++++++++++++++++++++++ src/kvm-launcher.py | 110 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 209 insertions(+), 0 deletions(-)
New commits: commit 531b47a6f3e330c0972d1ac218ad33332a3450c9 Author: Prajwal Mohan <[email protected]> Date: Tue Jan 13 10:11:24 2009 -0800 Adding the glade and py file Diff in this email is a maximum of 400 lines. diff --git a/src/kvm-launcher.glade b/src/kvm-launcher.glade new file mode 100755 index 0000000..cd660cf --- /dev/null +++ b/src/kvm-launcher.glade @@ -0,0 +1,99 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd"> +<!--Generated with glade3 3.4.0 on Mon Jan 12 22:07:11 2009 --> +<glade-interface> + <widget class="GtkWindow" id="main"> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> + <signal name="destroy" handler="on_main_destroy_event"/> + <child> + <widget class="GtkVBox" id="vbox1"> + <property name="visible">True</property> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> + <child> + <widget class="GtkLabel" id="launcher_label1"> + <property name="visible">True</property> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> + <property name="label" translatable="yes">KVM Launcher</property> + </widget> + </child> + <child> + <widget class="GtkHBox" id="hbox2"> + <property name="visible">True</property> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> + <child> + <widget class="GtkLabel" id="path"> + <property name="visible">True</property> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> + <property name="label" translatable="yes">Path</property> + </widget> + </child> + <child> + <widget class="GtkEntry" id="image_path_entry"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> + </widget> + <packing> + <property name="position">1</property> + </packing> + </child> + <child> + <widget class="GtkButton" id="browse"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> + <property name="label" translatable="yes">Browse</property> + <property name="response_id">0</property> + <signal name="clicked" handler="on_browse_clicked"/> + </widget> + <packing> + <property name="position">2</property> + </packing> + </child> + </widget> + <packing> + <property name="position">1</property> + </packing> + </child> + <child> + <widget class="GtkHBox" id="hbox1"> + <property name="visible">True</property> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> + <child> + <widget class="GtkButton" id="launch_kvm"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> + <property name="label" translatable="yes">Launch KVM</property> + <property name="response_id">0</property> + <signal name="clicked" handler="on_launch_kvm_clicked"/> + </widget> + </child> + <child> + <placeholder/> + </child> + <child> + <widget class="GtkButton" id="launch_qemu"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> + <property name="label" translatable="yes">Launch QEMU</property> + <property name="response_id">0</property> + <signal name="clicked" handler="on_launch_qemu_clicked"/> + </widget> + <packing> + <property name="position">2</property> + </packing> + </child> + </widget> + <packing> + <property name="position">2</property> + </packing> + </child> + </widget> + </child> + </widget> +</glade-interface> diff --git a/src/kvm-launcher.py b/src/kvm-launcher.py new file mode 100755 index 0000000..7b2b01b --- /dev/null +++ b/src/kvm-launcher.py @@ -0,0 +1,110 @@ +#!/usr/bin/python -tt +# vim: ai ts=4 sts=4 et sw=4 + +# Copyright (c) 2009 Intel Corporation +# +# 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; version 2 of the License +# +# 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. + +import gettext +import gnome +import gobject +import gtk +import gtk.glade +import os +import pygtk +import re +import shutil +import sys +import time +import traceback +import signal + +debug = False + +_ = gettext.lgettext + +ENVIRONMENT_VARS = { + 'PATH' : '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', +} + + +class App(object): + """This is our main""" + def __init__(self): + self.gladefile = "kvm-launcher.glade" #os.path.join(self.sdk.path, "kvm-launcher.glade") + if not os.path.isfile(self.gladefile): + raise IOError, "Glade file is missing from: %s" % self.gladefile + gnome.init('kvm-launcher', "1.0", properties = {'app-datadir':""}) + self.widgets = gtk.glade.XML (self.gladefile, 'main') + dic = {"on_main_destroy_event" : self.quit, + "on_browse_clicked" : self.browse_clicked, + "on_launch_kvm_clicked" : self.launch_kvm_clicked, + "on_launch_qemu_clicked" : self.launch_qemu_clicked + } + self.widgets.signal_autoconnect(dic) + + main_window = self.widgets.get_widget("main") + main_window.set_resizable(True) + main_window.show_all() + + self.image_path_entry = self.widgets.get_widget("image_path_entry") + + + def run(self): + gtk.main() + + def quit(self, value): + gtk.main_quit() + + def browse_clicked(self, widget): + dialog = gtk.FileChooserDialog(action=gtk.FILE_CHOOSER_ACTION_OPEN, title=_("Choose an image")) + dialog.set_current_folder("~/") + dialog.add_button(gtk.STOCK_OK, gtk.RESPONSE_OK) + dialog.add_button(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL) + filter_image = gtk.FileFilter() + filter_image.set_name("Image files"); + filter_image.add_pattern("*.img"); + dialog.add_filter(filter_image); + filter_any = gtk.FileFilter(); + filter_any.set_name("Any files"); + filter_any.add_pattern("*"); + dialog.add_filter(filter_any); + if dialog.run() == gtk.RESPONSE_OK: + live_img = dialog.get_filename() + self.image_path_entry.set_text(live_img) + dialog.destroy() + else: + dialog.destroy() + return + + + def launch_kvm_clicked(self, widget): + # boot the live usb image in KVM in background + image_path = self.image_path_entry.get_text() + print "Launching KVM: %s" % image_path + os.popen("kvm -no-acpi -m 512 -hda " + image_path + " -hdb /var/lib/moblin-image-creator/kvm/mic_vm_share.img -boot c &") + + + def launch_qemu_clicked(self, widget): + image_path = self.image_path_entry.get_text() + print "Launching QEMU: %s" % image_path + os.popen("qemu-kvm -no-acpi -m 512 -hda " + image_path + " -hdb /var/lib/moblin-image-creator/kvm/mic_vm_share.img -boot c &") + +def main(): + App().run() + + +if __name__ == '__main__': + if debug: sys.excepthook = print_exc_plus + sys.exit(main()) _______________________________________________ Commits mailing list [email protected] https://lists.moblin.org/mailman/listinfo/commits
