[Fedora-livecd-list] liveusb-creator-gtk to be included on livecds
مؤيد السعدي
muayyad.alsadi at ojuba.org
Wed Nov 12 11:46:35 UTC 2008
hi,
as I said on the IRC, I'm going to make a pyGTK tool to install the livecd
into a usb pendrive
I'm releasing it under GPLv2 to allow fedora shipping it with their rpms
What I have done so far is the GUI which automatically know source cds and
target partitions from dbus (no refresh button as it sense the change)
all options and we can add more at any time as I made them a python dict
the header is a gtk.Label() surrounded by two icons
the fedora/ojuba/gnome logo by using start-here icon name (to make branding
easy)
and drive-removable-media-usb icon name (from gnome icon theme)
I want to make sure that those icons are suitable for the KDE/XFCE/LXDE
spins
I did not implement the real creation of the livecd yet, simply because I
don't want to reinvent the wheel
I guess that would be 10 lines to code after we split liveusb-creator into
liveusb-creator and liveusb-creator-qt (and maybe adding
liveusb-creator-cli)
I need to do small changes
like to add tooltips and gettext
to make the min and max values of layer size to be read from dbus or to set
it at a sane default
I'm think about "all" checkbox beside target device that is display all
devices not only usb devices
so any suggestion
-------------- next part --------------
A non-text attachment was scrubbed...
Name: LiveUSB Creator.png
Type: image/png
Size: 57034 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/fedora-livecd-list/attachments/20081112/2addc3b3/attachment.png>
-------------- next part --------------
#! /usr/bin/env python
# -*- coding: utf-8 -*-
"""
Make your (usb) disk a Live OS - a front end for the fedora livecd-tools
Copyright © 2008 Muayyad Saleh Alsadi <alsadi at ojuba.org>
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, visit http://www.gnu.org/copyleft/gpl.html
"""
import gtk
import dbus
from dbus.mainloop.glib import DBusGMainLoop
dbus_loop = DBusGMainLoop(set_as_default=True)
bus = dbus.SystemBus()
class LiveUsbCreatorApp:
def quit(self,*args):
gtk.main_quit()
return False
#"block.device","info.product","volume.partition.media_size","volume.fsversion":"FAT32"
def device_as_item(self,udi,p):
return ('%(block.device)s (%(volume.label)s)' % p,)
def device_is_cd(self,p):
if not p.get("volume.is_disc",False): return False
if not p.get("volume.disc.type","").startswith('cd_') and not p.get("volume.disc.type","").startswith('dvd_'): return False
if not p.get("volume.disc.has_data",False) or p.get("volume.disc.is_blank",True): return False
# TODO: do we need to check "volume.fstype"=="iso9660" or to check some files in the CD
return True
def device_is_target(self,p):
if not p.get("volume.fstype","").startswith('vfat') and not p.get("volume.fstype","").startswith('ext'): return False
if p.get("volume.is_disc",False): return False
if not p.get("volume.is_partition",False): return False
if "usb" not in p.get("linux.sysfs_path",""): return False
return True
def devices_first_run(self):
self.cds=[]
self.targets=[]
dev = bus.get_object("org.freedesktop.Hal","/org/freedesktop/Hal/Manager")
l=dev.GetAllDevices(dbus_interface='org.freedesktop.Hal.Manager')
for udi in l:
d = bus.get_object("org.freedesktop.Hal",udi)
try:
p=d.GetAllProperties(dbus_interface='org.freedesktop.Hal.Device')
except: continue
if self.device_is_cd(p): self.cds.append(self.device_as_item(udi,p))
if self.device_is_target(p): self.targets.append(self.device_as_item(udi,p))
self.media.popdown()
self.media.get_model().clear()
for i in self.cds: self.media.append_text(i[0])
self.media.set_active(len(self.cds)-1)
self.target.popdown()
self.target.get_model().clear()
for i in self.targets: self.target.append_text(i[0])
self.target.set_active(len(self.targets)-1)
# TODO: it could be better if we just inspect the added/removed device only
def device_added_cb(self,udi, *args, **kwargs): self.devices_first_run()
def device_removed_cb(self,udi, *args, **kwargs): self.devices_first_run()
def __init__(self):
global dbus_loop, bus
bus.add_signal_receiver(self.device_added_cb, dbus_interface = "org.freedesktop.Hal.Manager", signal_name = "DeviceAdded")
bus.add_signal_receiver(self.device_removed_cb, dbus_interface = "org.freedesktop.Hal.Manager", signal_name = "DeviceRemoved")
self.build_about()
self.w=gtk.Window()
self.w.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DIALOG)
self.w.set_title('LiveUSB Creator')
self.w.set_icon_name("system-software-install")
self.w.set_resizable(False)
self.w.connect("delete_event", self.quit)
f1=gtk.Frame(label="LiveCD Origin:")
vb=gtk.VBox(False,2); f1.add(vb)
self.is_media=gtk.RadioButton(label="from _CDROM/DVD Media")
self.media=gtk.combo_box_new_text()
self.is_iso=gtk.RadioButton(group=self.is_media,label="from ISO _file")
self.iso=gtk.FileChooserButton("Choose an ISO file:")
for i,j in [(self.is_media,self.media),(self.is_iso,self.iso)]:
hb=gtk.HBox(False,0); vb.pack_start(hb, True,True,0)
i.connect('toggled', lambda a,b: b.set_sensitive(a.get_active()),j)
hb.pack_start(i, False,False,0)
hb.pack_start(j, True,True,0)
f2=gtk.Frame(label="Target Options:")
vb=gtk.VBox(False,2); f2.add(vb)
hb=gtk.HBox(False,0); vb.pack_start(hb, True,True,0)
self.target=gtk.combo_box_new_text()
hb.pack_start(gtk.Label("Target Device:"), False,False,0)
hb.pack_start(self.target, True,True,0)
vb.pack_start(gtk.Label("Target should be vfat/ext3 partition"), False,False,0)
self.is_per=gtk.CheckButton("Persistent _layer size")
self.per_size=gtk.SpinButton(gtk.Adjustment(200, 0, 1000000, 10, 50, 0))
hb=gtk.HBox(False,0); vb.pack_start(hb, True,True,0)
for i in (self.is_per, self.per_size, gtk.Label("MB")): hb.pack_start(i, False,False,0)
self.is_home=gtk.CheckButton("Persistent _Home")
self.home_size=gtk.SpinButton(gtk.Adjustment(200, 0, 1000000, 10, 50, 0))
self.is_home_enc=gtk.CheckButton("_Encrypted")
hb=gtk.HBox(False,0); vb.pack_start(hb, True,True,0)
for i in (self.is_home, self.home_size, gtk.Label("MB"),self.is_home_enc): hb.pack_start(i, False,False,0)
#f3=gtk.Frame(label="Advanced options:")
f3=gtk.Expander(label="Advanced options:")
vb=gtk.VBox(False,2); f3.add(vb)
hb=gtk.HBox(False,0); vb.pack_start(hb, True,True,0)
self.opt={}
for i,j,k in [('noverify',"Skip verify",0),('reset-mbr',"reset MBR",1),('force',"Force",0)]:
self.opt[i]=gtk.CheckButton(j)
self.opt[i].set_active(k)
hb.pack_start(self.opt[i], False,False,0)
hb=gtk.HBox(False,0); vb.pack_start(hb, True,True,0)
for i,j,k in [('mactel',"Intel Macs",0),('xo',"XO",0), ('xo-no-home',"No XO Home",0)]:
self.opt[i]=gtk.CheckButton(j)
self.opt[i].set_active(k)
hb.pack_start(self.opt[i], False,False,0)
f4=gtk.HBox(False,0)
self.progress=gtk.ProgressBar()
self.ok=gtk.Button(stock=gtk.STOCK_OK)
self.about=gtk.Button(stock=gtk.STOCK_ABOUT)
f4.pack_start(self.progress, True,True,0)
f4.pack_start(self.ok, False,False,0)
f4.pack_start(self.about, False,False,0)
self.about.connect("clicked", lambda *args: self.about_dlg.run())
self.progress.set_fraction(0.3)
self.progress.set_text('Working ... 30% complete')
vb=gtk.VBox(False,2); self.w.add(vb)
hb=gtk.HBox(False,0); vb.pack_start(hb, True,True,0)
title=gtk.Label()
title.set_markup('<span size="xx-large" fgcolor="#004400" bgcolor="#ffffff"><b> Live<sub><i>USB</i></sub></b> Creator </span>')
hb.pack_start(gtk.image_new_from_icon_name("start-here", gtk.ICON_SIZE_DIALOG), False,False,0)
hb.pack_start(title, True,True,0) # in fedora-logos
hb.pack_start(gtk.image_new_from_icon_name("drive-removable-media-usb", gtk.ICON_SIZE_DIALOG), False,False,0) # it's in gnome icon themes # TODO: make sure to use a name the works if gnome is not installed
vb.pack_start(f1, False,False,0)
vb.pack_start(f2, False,False,0)
vb.pack_start(f3, True,True,0)
vb.pack_start(f4, False,False,0)
self.devices_first_run()
self.w.show_all()
def build_about(self):
self.about_dlg=gtk.AboutDialog()
self.about_dlg.set_default_response(gtk.RESPONSE_CLOSE)
self.about_dlg.connect('delete-event', lambda w,*args: w.hide() or True)
self.about_dlg.connect('response', lambda w,*args: w.hide() or True)
try: self.about_dlg.set_program_name("LiveUSB Creator")
except AttributeError: pass
self.about_dlg.set_name("LiveUSB Creator")
self.about_dlg.set_copyright("Copyright (c) 2008 Muayyad Saleh Alsadi <alsadi at ojuba.org>")
self.about_dlg.set_comments("Live OS on your USB pendrive")
self.about_dlg.set_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, visit http://www.gnu.org/copyleft/gpl.html""")
self.about_dlg.set_website("http://www.ojuba.org/")
self.about_dlg.set_website_label("http://www.ojuba.org")
self.about_dlg.set_authors(["Muayyad Saleh Alsadi <alsadi at ojuba.org>"])
if __name__ == '__main__':
app=LiveUsbCreatorApp()
gtk.main()
More information about the Fedora-livecd-list
mailing list