| Server IP : 172.67.134.114 / Your IP : 104.23.197.122 Web Server : Apache/2.4.37 System : Linux almalinux.duckdns.org 4.18.0-553.111.1.el8_10.x86_64 #1 SMP Sun Mar 8 20:06:07 EDT 2026 x86_64 User : ricodeal ( 1046) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /usr/bin/ |
Upload File : |
#!/usr/libexec/platform-python
# coding=UTF-8
## Copyright (C) 2012 ABRT team <[email protected]>
## Copyright (C) 2001-2005 Red Hat, Inc.
## 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, write to the Free Software
## Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA
import os
import sys
import logging
import signal
import locale
from argparse import ArgumentParser
from gnome_abrt.wrappers import (show_events_list_dialog,
can_connect_to_xserver)
if not can_connect_to_xserver():
sys.stderr.write("Cannot connect to X server\n")
sys.exit(1)
# pygobject
#pylint: disable=C0411, C0413
import gi
gi.require_version('Gtk', '3.0')
#pylint: disable=E0611, C0411, C0413
from gi.repository import Gtk
#pylint: disable=E0611, C0411, C0413
from gi.repository import GLib
#pylint: disable=E0611, C0411, C0413
from gi.repository import Gio
# gnome-abrt
#pylint: disable=C0413, C0412
import gnome_abrt
gnome_abrt.init()
#pylint: disable=C0413
import gnome_abrt.url
#pylint: disable=C0413
from gnome_abrt.views import OopsWindow
#pylint: disable=C0413
from gnome_abrt.controller import Controller
#pylint: disable=C0413
from gnome_abrt.signals import glib_sigchld_signal_handler
#pylint: disable=C0413
from gnome_abrt.problems import MultipleSources
#pylint: disable=C0413
from gnome_abrt.directory_problems import DirectoryProblemSource
#pylint: disable=C0413
from gnome_abrt.dbus_problems import (get_standard_problems_source,
get_foreign_problems_source)
#pylint: disable=C0413
from gnome_abrt.errors import UnavailableSource
#pylint: disable=C0413
from gnome_abrt.l10n import _, C_
#pylint: disable=C0413
from gnome_abrt.config import get_configuration
#pylint: disable=C0413
from gnome_abrt.url.gliburltitle import (GetURLTitleSourcePool,
GetURLTitleSourceCache)
# dbus
#pylint: disable=C0413
import dbus
#pylint: disable=C0413
import dbus.service
#pylint: disable=C0413
from dbus.mainloop.glib import DBusGMainLoop
GNOME_ABRT_APPLICATION_ID = 'org.freedesktop.GnomeAbrt'
GNOME_ABRT_INTERFACE = 'org.freedesktop.GnomeAbrt'
GNOME_ABRT_OBJECT_PATH = '/org/freedesktop/GnomeAbrt'
GNOME_ABRT_URL_POOL_CAPACITY = 10
# because of https://bugzilla.gnome.org/show_bug.cgi?id=682331
class GtkAppDBUSImpl:
"""A proxy for primary application
"""
#pylint: disable=R0923
class Service(dbus.service.Object):
"""DBus service sitting on session bus
"""
def __init__(self, bus, bus_name, application):
bus_name = dbus.service.BusName(bus_name, bus)
dbus.service.Object.__init__(self, bus_name, GNOME_ABRT_OBJECT_PATH)
self._app = application
@dbus.service.method(dbus_interface=GNOME_ABRT_INTERFACE,
in_signature='as', out_signature='')
def command_line(self, argv):
"""DBus service method accepting a new command line arguments
"""
class Arguments:
"""Adapter for Gtk class
"""
def __init__(self, argv):
self._argv = argv
def get_arguments(self):
return self._argv
args = Arguments([str(a) for a in argv])
self._app._parse_command_line(self, args)
def __init__(self, bus_name, application):
self._app = application
self.mainloop = DBusGMainLoop()
self._primary_obj = None
self._primary_iface = None
self._service = None
try:
bus = dbus.SessionBus(mainloop=self.mainloop)
if bus.name_has_owner(bus_name):
self._primary_obj = bus.get_object(bus_name,
GNOME_ABRT_OBJECT_PATH)
else:
self._service = GtkAppDBUSImpl.Service(bus, bus_name, self._app)
except dbus.exceptions.DBusException as ex:
logging.warning("Can't initialize gnome-abrt's DBus services: {0}"
.format(ex))
self._primary_obj = None
self._service = None
def is_remote(self):
"""Application is remote if connection to primary application succeeded
"""
return self._primary_obj is not None
def send_command_line(self, argv):
"""Sends command line arguments to the primary application.
Raises RuntimeError if an instance is not remote.
"""
if not self.is_remote():
raise RuntimeError("Can't send command-line message because "
"instance is not a remote application")
try:
if not self._primary_iface:
self._primary_iface = dbus.Interface(self._primary_obj,
GNOME_ABRT_INTERFACE)
if not argv:
argv = dbus.Array([], signature='s')
self._primary_iface.command_line(argv)
return True
except dbus.exceptions.DBusException as ex:
logging.debug("Can't send command line over DBus: {0}"
.format(ex))
return False
class OopsApplication(Gtk.Application):
def __init__(self):
Gtk.Application.__init__(self)
self._dbus_srv = GtkAppDBUSImpl(GNOME_ABRT_APPLICATION_ID, self)
self.connect("command-line", self._parse_command_line)
self.set_flags(Gio.ApplicationFlags.HANDLES_COMMAND_LINE)
self.gcontext = None
self.all_sources = None
self._url_pool = GetURLTitleSourcePool(GNOME_ABRT_URL_POOL_CAPACITY)
self._url_cache = GetURLTitleSourceCache(self._url_pool)
#gnome_abrt.url.set_async_worker(self._url_cache.get_url_title_async)
# Disable because of https://bugzilla.redhat.com/show_bug.cgi?id=959811
gnome_abrt.url.set_async_worker(lambda *args: None)
self.gnome_settings = None
def _bind_to_gsettings(self, conf):
def set_time_format(conf, gsettings):
clck_fmt = None
try:
clck_fmt = gsettings.get_value('clock-format').get_string()
# What exception types is less general?
#pylint: disable=W0703
except Exception as ex:
logging.exception(ex)
return
if clck_fmt == '24h':
conf['T_FMT'] = '%k:%M'
conf['D_T_FMT'] = '%Y-%m-%d %k:%M'
else:
conf['T_FMT'] = '%l:%M %p'
conf['D_T_FMT'] = '%Y-%m-%d %l:%M %p'
def settings_changed(settings, key, conf):
if key == 'clock-format':
set_time_format(conf, settings)
if self.gnome_settings is None:
self.gnome_settings = Gio.Settings(
schema='org.gnome.desktop.interface')
self.gnome_settings.connect(
'changed', settings_changed, conf)
conf.add_option('T_FMT',
default_value=locale.nl_langinfo(locale.T_FMT))
conf.add_option('D_T_FMT',
default_value=locale.nl_langinfo(locale.D_T_FMT))
set_time_format(conf, self.gnome_settings)
#pylint: disable=W0613
def _parse_command_line(self, sender, gcmdargs):
argv = gcmdargs.get_arguments()
if self._dbus_srv.is_remote():
if self._dbus_srv.send_command_line(argv):
return 0
if argv:
conf = get_configuration()
conf['problemid'] = argv[0]
self.activate()
return 0
#pylint: disable=W0221
def do_activate(self):
try:
windows = self.get_windows()
if windows:
windows[0].present()
else:
conf = get_configuration()
conf.add_option("all_problems", default_value=False)
self._bind_to_gsettings(conf)
sources = []
try:
sources.append(
get_standard_problems_source(self._dbus_srv.mainloop))
except UnavailableSource as ex:
logging.warning(str(ex))
self.gcontext = GLib.main_context_default()
try:
path = os.path.join(GLib.get_user_cache_dir(), "abrt/spool")
dps = DirectoryProblemSource(path, context=self.gcontext)
sources.append(dps)
except UnavailableSource:
logging.warning(str(ex))
if not sources:
raise UnavailableSource(None, None,
message="No available problem source.")
# pylint: disable=W0105
'''
This is a trick to make xgettext think we are C language
and emit the translators comment correctly. It's a bug
in xgettext that it recognizes Python files only after
their .py extension, there is no way to force the format.
See: bugs.launchpad.net/intltool/+bug/377872
// Translators: a list header, "My" is a shortcut for "My bugs"
_("My")
'''
self.all_sources = [(_("My"), MultipleSources(sources))]
try:
# pylint: disable=W0105
'''
The same trick as above:
// Translators: a list header, a shortcut for "System
// bugs". In this context "System" may be an adjective
// or a genitive noun, as required by your language.
C_("bugs", "System")
'''
self.all_sources.append((C_("bugs", "System"),
get_foreign_problems_source()))
except UnavailableSource as ex:
logging.warning(str(ex))
controller = Controller(self.all_sources,
glib_sigchld_signal_handler)
main_window = OopsWindow(self, self.all_sources, controller)
main_window.show_all()
self.add_window(main_window)
#pylint: disable=W0703
except Exception as ex:
logging.exception(ex)
sys.exit(1)
#pylint: disable=W0221
def do_startup(self):
Gtk.Application.do_startup(self)
menu = Gio.Menu()
menu.append(_("_Preferences"), "app.preferences")
sub_menu = Gio.Menu()
sub_menu.append(_("_About"), "app.about")
sub_menu.append(_("_Quit"), "app.quit")
menu.append_section(None, sub_menu)
action = Gio.SimpleAction.new("preferences", None)
action.connect("activate", self.on_action_prefrences)
self.add_action(action)
action = Gio.SimpleAction.new("about", None)
action.connect("activate", self.on_action_about)
self.add_action(action)
action = Gio.SimpleAction.new("quit", None)
action.connect("activate", self.on_action_quit)
self.add_action(action)
self.add_accelerator("<Control>q", "app.quit")
self.set_app_menu(menu)
#pylint: disable=W0613
def on_action_prefrences(self, action, parameter):
windows = self.get_windows()
if windows:
show_events_list_dialog(windows[0])
else:
show_events_list_dialog()
#pylint: disable=W0613
def on_action_about(self, action, parameter):
#pylint: disable=E1120
dialog = Gtk.AboutDialog.new()
dialog.set_icon_name("abrt")
dialog.set_version(gnome_abrt.VERSION)
dialog.set_logo_icon_name("abrt")
dialog.set_program_name(_("Problem Reporting"))
dialog.set_copyright("Copyright © 2012 Red Hat, Inc")
dialog.set_license(
"This program is free software; you can redistribut"
"e 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 Li"
"cense, or (at your option) any later version.\n\nThis program is distrib"
"uted in the hope that it will be useful, but WITHOUT ANY WARRANTY; witho"
"ut even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICU"
"LAR PURPOSE. See the GNU General Public License for more details.\n\nYo"
"u should have received a copy of the GNU General Public License along wi"
"th this program. If not, see <http://www.gnu.org/licenses/>.")
dialog.set_wrap_license(True)
dialog.set_website("https://github.com/abrt/gnome-abrt")
dialog.set_authors(["aboobed <[email protected]>",
"Allan Day <[email protected]>",
"Bastien Nocera <[email protected]>",
"Chris Lockfort <[email protected]>",
"Daniel Aleksandersen <[email protected]>",
"Denys Vlasenko <[email protected]>",
"Elad Alfassa <[email protected]>",
"Francesco Frassinelli <[email protected]>",
"Jakub Filák <[email protected]>",
"Jiri Moskovčák <[email protected]>",
"Martin Milata <[email protected]>",
"Matěj Habrnál <[email protected]>",
"Marek Bryša <[email protected]>",
"Michael Catanzaro <[email protected]>",
"Michal Toman <[email protected]>",
"Rafał Lużyński <[email protected]>",
"Richard Marko <[email protected]>"])
#dialog.set_artists(artists)
#dialog.set_translator_credits(_("translator-credits"))
windows = self.get_windows()
if windows:
dialog.set_transient_for(windows[0])
dialog.run()
dialog.destroy()
#pylint: disable=W0613
def on_action_quit(self, action, parameter):
self.quit()
if __name__ == "__main__":
signal.signal(signal.SIGINT, lambda signum, frame: sys.exit(1))
CMDARGS = ArgumentParser(
description=_('View and report application crashes'))
# pylint: disable=W0105
'''
Again a trick to make xgettext think we are C language and emit the
translators comment correctly.
See: bugs.launchpad.net/intltool/+bug/377872
// Translators: This is a description of --verbose command line option
// displayed when a user runs: `gnome-abrt --help'
_("Be verbose")
'''
CMDARGS.add_argument('-v', '--verbose', action='count',
help=_('Be verbose'))
# pylint: disable=W0105
'''
// Translators: This is a description of --problem command line option
// displayed when a user runs: `gnome-abrt --help'
_("Selected problem ID")
'''
CMDARGS.add_argument('-p', '--problem',
help=_('Selected problem ID'))
OPTIONS = CMDARGS.parse_args()
if OPTIONS.verbose is not None:
logging.getLogger().setLevel(logging.DEBUG)
VARS = vars(OPTIONS)
CONF = get_configuration()
# TODO : mark this option as hidden or something like that
CONF.add_option('problemid', default_value=None)
APP_CMDLINE = []
if 'problem' in VARS:
APP_CMDLINE.append(VARS['problem'])
EXIT_CODE = 1
APP = OopsApplication()
try:
EXIT_CODE = APP.run(APP_CMDLINE)
except UnavailableSource as ex:
logging.error(ex)
sys.exit(EXIT_CODE)