Now detects errors when running a program, and shows a window that allows to copy to clipboard the debugging data
Now hides the main window when creating the disc, and shows it again at the end
This commit is contained in:
parent
8de307fd73
commit
70fadeef22
5 changed files with 225 additions and 10 deletions
136
data/interface/werror.ui
Normal file
136
data/interface/werror.ui
Normal file
|
|
@ -0,0 +1,136 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Generated with glade 3.16.1 -->
|
||||
<interface>
|
||||
<requires lib="gtk+" version="3.10"/>
|
||||
<object class="GtkTextBuffer" id="debug_buffer"/>
|
||||
<object class="GtkDialog" id="dialog_error">
|
||||
<property name="width_request">640</property>
|
||||
<property name="height_request">240</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="modal">True</property>
|
||||
<property name="window_position">center</property>
|
||||
<property name="type_hint">dialog</property>
|
||||
<child internal-child="vbox">
|
||||
<object class="GtkBox" id="dialog-vbox1">
|
||||
<property name="can_focus">False</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<property name="spacing">2</property>
|
||||
<child internal-child="action_area">
|
||||
<object class="GtkButtonBox" id="dialog-action_area1">
|
||||
<property name="can_focus">False</property>
|
||||
<property name="layout_style">center</property>
|
||||
<child>
|
||||
<object class="GtkButton" id="button1">
|
||||
<property name="label">gtk-ok</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="use_stock">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="pack_type">end</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox" id="box1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="label1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">There was an error while creating the disc.</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkExpander" id="expander1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="resize_toplevel">True</property>
|
||||
<child>
|
||||
<object class="GtkBox" id="box3">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<child>
|
||||
<object class="GtkScrolledWindow" id="scrolledwindow1">
|
||||
<property name="height_request">200</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="shadow_type">in</property>
|
||||
<child>
|
||||
<object class="GtkTextView" id="debug">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="buffer">debug_buffer</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="copy">
|
||||
<property name="label">gtk-copy</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="use_stock">True</property>
|
||||
<signal name="clicked" handler="on_copy_clicked" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child type="label">
|
||||
<object class="GtkLabel" id="label2">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">Debugging data</property>
|
||||
<property name="ellipsize">start</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<action-widgets>
|
||||
<action-widget response="1">button1</action-widget>
|
||||
</action-widgets>
|
||||
</object>
|
||||
</interface>
|
||||
47
src/devede/error.py
Normal file
47
src/devede/error.py
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
# Copyright 2014 (C) Raster Software Vigo (Sergio Costas)
|
||||
#
|
||||
# This file is part of DeVeDe-NG
|
||||
#
|
||||
# DeVeDe-NG 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 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# DeVeDe-NG 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, see <http://www.gnu.org/licenses/>
|
||||
|
||||
from gi.repository import Gtk,Gdk
|
||||
import os
|
||||
import devede.configuration_data
|
||||
|
||||
class error_window:
|
||||
|
||||
def __init__(self):
|
||||
|
||||
self.config = devede.configuration_data.configuration.get_config()
|
||||
|
||||
builder = Gtk.Builder()
|
||||
builder.set_translation_domain(self.config.gettext_domain)
|
||||
|
||||
builder.add_from_file(os.path.join(self.config.glade,"werror.ui"))
|
||||
builder.connect_signals(self)
|
||||
werror_window = builder.get_object("dialog_error")
|
||||
wdebug_buffer = builder.get_object("debug_buffer")
|
||||
wdebug_buffer.insert_at_cursor(self.config.get_log())
|
||||
|
||||
werror_window.show_all()
|
||||
werror_window.run()
|
||||
werror_window.destroy()
|
||||
|
||||
|
||||
def on_copy_clicked(self,b):
|
||||
|
||||
clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD)
|
||||
data =self.config.get_log()
|
||||
clipboard.set_text(data,len(data))
|
||||
return
|
||||
|
|
@ -45,6 +45,7 @@ class executor(GObject.GObject):
|
|||
self.dependencies = None
|
||||
self.childs = []
|
||||
self.progress_bar = None
|
||||
self.killed = False
|
||||
|
||||
def add_dependency(self, dep):
|
||||
|
||||
|
|
@ -131,6 +132,7 @@ class executor(GObject.GObject):
|
|||
else:
|
||||
self.handle = subprocess.Popen(command,stdout = subprocess.PIPE, stderr = subprocess.PIPE)
|
||||
except Exception as error_launch:
|
||||
self.handle = None
|
||||
self.stderr_data += str(error_launch)
|
||||
self.wait_end()
|
||||
return
|
||||
|
|
@ -148,6 +150,7 @@ class executor(GObject.GObject):
|
|||
self.channel_stderr.add_watch(GLib.IO_IN | GLib.IO_HUP,self.read_stderr)
|
||||
else:
|
||||
(stdout_r, stderr_r) = self.handle.communicate()
|
||||
self.handle = None
|
||||
self.config.append_log(self.launch_command)
|
||||
try:
|
||||
self.config.append_log(stdout_r.decode("utf-8"))
|
||||
|
|
@ -160,7 +163,6 @@ class executor(GObject.GObject):
|
|||
return (stdout_r, stderr_r)
|
||||
|
||||
|
||||
|
||||
def read_stdout_to_file(self,source,condition):
|
||||
|
||||
if (condition != GLib.IO_IN):
|
||||
|
|
@ -244,17 +246,24 @@ class executor(GObject.GObject):
|
|||
|
||||
if self.handle==None:
|
||||
return
|
||||
self.killed = True
|
||||
os.kill(self.handle.pid,signal.SIGKILL)
|
||||
|
||||
|
||||
def wait_end(self):
|
||||
|
||||
if self.handle != None:
|
||||
retval = self.handle.wait()
|
||||
self.handle = None
|
||||
else:
|
||||
retval = -1
|
||||
|
||||
if self.killed:
|
||||
retval = 0
|
||||
else:
|
||||
self.config.append_log(self.text)
|
||||
self.config.append_log(self.launch_command)
|
||||
self.config.append_log(self.stdout_data)
|
||||
self.config.append_log(self.stderr_data)
|
||||
if self.handle != None:
|
||||
retval = self.handle.wait()
|
||||
else:
|
||||
retval = -1
|
||||
|
||||
self.emit("ended",retval)
|
||||
|
|
@ -177,7 +177,6 @@ class devede_project:
|
|||
|
||||
ask = devede.ask.ask_window()
|
||||
if (ask.run(_("Abort the current DVD and exit?"),_("Exit DeVeDe"))):
|
||||
print(self.config.get_log())
|
||||
Gtk.main_quit()
|
||||
return True
|
||||
|
||||
|
|
@ -276,4 +275,10 @@ class devede_project:
|
|||
p = movie.do_conversion(os.path.join(movie_folder,"movie_"+str(counter)+".mpg"))
|
||||
run_window.add_process(p)
|
||||
counter += 1
|
||||
run_window.connect("done",self.disc_done)
|
||||
self.wmain_window.hide()
|
||||
run_window.run()
|
||||
|
||||
def disc_done(self,object,value):
|
||||
|
||||
self.wmain_window.show()
|
||||
|
|
@ -18,11 +18,16 @@
|
|||
from gi.repository import Gtk,GObject
|
||||
import os
|
||||
import devede.configuration_data
|
||||
import devede.error
|
||||
|
||||
class runner(GObject.GObject):
|
||||
|
||||
__gsignals__ = {'done': (GObject.SIGNAL_RUN_FIRST, None,(int,))}
|
||||
|
||||
def __init__(self):
|
||||
|
||||
GObject.GObject.__init__(self)
|
||||
|
||||
self.config = devede.configuration_data.configuration.get_config()
|
||||
if (self.config.multicore):
|
||||
self.count_cores()
|
||||
|
|
@ -81,7 +86,10 @@ class runner(GObject.GObject):
|
|||
if (line.startswith("processor")):
|
||||
self.cores += 1
|
||||
|
||||
def run(self):
|
||||
def run(self, clear_log = True):
|
||||
|
||||
if clear_log:
|
||||
self.config.clear_log()
|
||||
|
||||
for element in self.proc_list:
|
||||
# each element has three items:
|
||||
|
|
@ -100,8 +108,17 @@ class runner(GObject.GObject):
|
|||
break
|
||||
self.wtotal.set_text(str(self.total_processes - len(self.proc_list))+"/"+str(self.total_processes))
|
||||
|
||||
|
||||
def process_ended(self,process, retval):
|
||||
|
||||
if retval != 0:
|
||||
for element in self.proc_list:
|
||||
element.cancel()
|
||||
self.wprogress.destroy()
|
||||
devede.error.error_window()
|
||||
self.emit("done",1)
|
||||
return
|
||||
|
||||
# move the progress bar used by this process to the list of available progress bars
|
||||
tmp = []
|
||||
for e in self.used_progress_bars:
|
||||
|
|
@ -122,6 +139,7 @@ class runner(GObject.GObject):
|
|||
|
||||
# launch a new process
|
||||
if (len(self.proc_list) != 0):
|
||||
self.run()
|
||||
self.run(False)
|
||||
else:
|
||||
self.wprogress.destroy()
|
||||
self.emit("done",0)
|
||||
Loading…
Add table
Add a link
Reference in a new issue