Commit ba9639d4 authored by Roman Alifanov's avatar Roman Alifanov

errordialog: improved error preparation for bug reporting

parent 4d83504d
......@@ -89,6 +89,8 @@ class CommandRunner:
env = os.environ.copy()
env['TERM'] = 'xterm'
self.append_log(f"command: {command}\n")
process = subprocess.Popen(command, shell=True,
stdout=slave_fd, stderr=slave_fd, stdin=slave_fd,
text=True, env=env)
......
import webbrowser
import webbrowser, subprocess, re
from gi.repository import Gtk, GLib, Gdk, Adw
@Gtk.Template(resource_path='/ru/eepm/PlayGUI/widgets/errordialog.ui')
......@@ -24,10 +24,32 @@ class ErrorDialog(Adw.Dialog):
self.textbuffer.get_insert(), 0, False, 0.0, 1.0)
def present_error(self, win, error):
self.error = error
self.append_log(error)
self.error = None
self.build_log(error)
self.append_log(self.error)
self.present(win)
def build_log(self, error):
separator = "_________________"
distro_info = subprocess.run(
["epm", "print", "info"],
capture_output=True, text=True, check=True).stdout
filtered_error_lines = [
line for line in error.splitlines() if '%' not in line
]
filtered_error = '\n'.join(filtered_error_lines)
filtered_error = re.sub(r'\n{3,}', '\n\n', filtered_error)
if filtered_error_lines and "command:" in filtered_error_lines[0].lower():
first_line = filtered_error_lines[0]
self.error = f"{first_line}\n{separator}\n{distro_info}\n{separator}\n" + '\n'.join(
filtered_error.splitlines()[-30:])
else:
self.error = f"{distro_info}\n{separator}\n" + '\n'.join(filtered_error.splitlines()[-30:])
def copy_error(self):
display = Gdk.Display.get_default()
clipboard = display.get_clipboard()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment