1 # BiaGen - front end to genisoimage
2 # Copyright 2010 V.Harishankar
3 # Licensed under the GNU GPL v3 or above
5 # window to run the executable
11 import os
, sys
, subprocess
, signal
15 class burningprocess (threading
.Thread
):
16 def update_ui (self
, data
):
17 lines
= data
.split ("\n")
18 lastline
= lines
[len (lines
) - 1]
19 words
= lastline
.split ("%")
20 pbar
= self
.parent
.ui
.get_object ("progress")
22 perc
= float (words
[0].strip ()) / 100.0
23 if perc
>= 0 and perc
<= 1:
24 pbar
.set_fraction (perc
)
26 pbar
.set_pulse_step (0.3)
31 textview
= self
.parent
.ui
.get_object ("progressmessages")
32 textbuf
= textview
.get_buffer ()
33 textbuf
.set_text (data
)
34 endmark
= textbuf
.get_insert ()
35 textview
.scroll_to_mark (endmark
, 0.0)
38 proc
= subprocess
.Popen (self
.parent
.command
, stdout
=subprocess
.PIPE
,
39 stdin
=subprocess
.PIPE
, stderr
=subprocess
.STDOUT
, bufsize
=1)
43 ch
= proc
.stdout
.read (1)
49 gobject
.idle_add (self
.update_ui
, data
)
51 ch
= proc
.stdout
.read (1)
56 data
+= "\ngenisoimage has completed. You can close this window now."
57 #gobject.idle_add (self.update_ui, data)
58 self
.parent
.ui
.get_object ("progressmessages").get_buffer ().set_text (data
)
59 self
.parent
.ui
.get_object ("btnclose").set_sensitive (True)
60 self
.parent
.ui
.get_object ("btncancel").set_sensitive (False)
61 self
.parent
.ui
.get_object ("progress").set_fraction (1.0)
63 def __init__ (self
, parent
):
64 super (BiaGenProgress
.burningprocess
, self
).__init
__ ()
66 self
.command
= self
.parent
.command
68 def on_btnclose_clicked (self
, *args
):
69 self
.ui
.get_object ("progress_window").destroy ()
71 def __init__ (self
, parent_ui
, command_args
):
72 # initialize the window
73 self
.parent_ui
= parent_ui
74 self
.command
= command_args
75 self
.ui
= gtk
.Builder ()
76 self
.ui
.add_from_file ("progress_window.xml")
77 self
.ui
.connect_signals (self
)
79 self
.ui
.get_object ("progress_window").show ()
81 # now start the burning process in a separate thread
82 self
.burn_proc
= self
.burningprocess (self
)
83 self
.burn_proc
.start ()