mirror of
https://github.com/servo/servo.git
synced 2025-07-19 05:13:55 +01:00
Fix DBus warning when running mach
(#37818)
I get the following warning message I run ./mach build: ```console Could not generate notification: No module named 'dbus' ``` I asked in the Zulip chat[1] if anyone was still using the feature and it sounds like most people do not use it anymore. It has been broken a while too and no one has stepped up to fix it. Gnome Terminal will automatically show a notification when a long running command is done. Some other terminals can also be configured to automatically show a notification when a long running command is done. I think it is safe to remove the feature. [1] https://servo.zulipchat.com/#narrow/channel/263398-general/topic/DBus.20warning.20when.20running.20.60.2E.2Fmach.20build.60 Testing: I manually tested it on Linux by running ./mach bootstrap followed by ./mach build Signed-off-by: Michael Mc Donnell <michael@mcdonnell.dk>
This commit is contained in:
parent
6e8a0518d7
commit
9aa06b2c17
3 changed files with 2 additions and 63 deletions
|
@ -19,8 +19,6 @@ import sys
|
|||
from time import time
|
||||
from typing import Optional, List, Dict
|
||||
|
||||
import notifypy
|
||||
|
||||
from mach.decorators import (
|
||||
CommandArgument,
|
||||
CommandProvider,
|
||||
|
@ -33,7 +31,7 @@ import servo.platform.macos
|
|||
import servo.util
|
||||
import servo.visual_studio
|
||||
|
||||
from servo.command_base import BuildType, CommandBase, call, check_call
|
||||
from servo.command_base import BuildType, CommandBase, check_call
|
||||
from servo.gstreamer import windows_dlls, windows_plugins, package_gstreamer_dylibs
|
||||
from servo.platform.build_target import BuildTarget
|
||||
|
||||
|
@ -189,12 +187,10 @@ class MachCommands(CommandBase):
|
|||
except ImportError:
|
||||
pass
|
||||
|
||||
# Generate Desktop Notification if elapsed-time > some threshold value
|
||||
|
||||
# Print how long the build took
|
||||
elapsed = time() - build_start
|
||||
elapsed_delta = datetime.timedelta(seconds=int(elapsed))
|
||||
build_message = f"{'Succeeded' if status == 0 else 'Failed'} in {elapsed_delta}"
|
||||
self.notify("Servo build", build_message)
|
||||
print(build_message)
|
||||
|
||||
return status
|
||||
|
@ -287,56 +283,6 @@ class MachCommands(CommandBase):
|
|||
env["TARGET_CFLAGS"] += " -fsanitize=thread"
|
||||
env["TARGET_CXXFLAGS"] += " -fsanitize=thread"
|
||||
|
||||
def notify(self, title: str, message: str):
|
||||
"""Generate desktop notification when build is complete and the
|
||||
elapsed build time was longer than 30 seconds.
|
||||
|
||||
If notify-command is set in the [tools] section of the configuration,
|
||||
that is used instead."""
|
||||
notify_command = self.config["tools"].get("notify-command")
|
||||
|
||||
# notifypy does not know how to send transient notifications, so we use a custom
|
||||
# notifier on Linux. If transient notifications are not used, then notifications
|
||||
# pile up in the notification center and must be cleared manually.
|
||||
class LinuxNotifier(notifypy.BaseNotifier):
|
||||
def __init__(self, **kwargs):
|
||||
pass
|
||||
|
||||
def send_notification(self, **kwargs):
|
||||
try:
|
||||
import dbus
|
||||
|
||||
bus = dbus.SessionBus()
|
||||
notify_obj = bus.get_object("org.freedesktop.Notifications", "/org/freedesktop/Notifications")
|
||||
method = notify_obj.get_dbus_method("Notify", "org.freedesktop.Notifications")
|
||||
method(
|
||||
kwargs.get("application_name"),
|
||||
0, # Don't replace previous notification.
|
||||
kwargs.get("notification_icon", ""),
|
||||
kwargs.get("notification_title"),
|
||||
kwargs.get("notification_subtitle"),
|
||||
[], # actions
|
||||
{"transient": True}, # hints
|
||||
-1, # timeout
|
||||
)
|
||||
except Exception as exception:
|
||||
print(f"[Warning] Could not generate notification: {exception}", file=sys.stderr)
|
||||
return True
|
||||
|
||||
if notify_command:
|
||||
if call([notify_command, title, message]) != 0:
|
||||
print(f"[Warning] Could not generate notification: Could not run '{notify_command}'.", file=sys.stderr)
|
||||
else:
|
||||
try:
|
||||
notifier = LinuxNotifier if sys.platform.startswith("linux") else None
|
||||
notification = notifypy.Notify(use_custom_notifier=notifier)
|
||||
notification.title = title
|
||||
notification.message = message
|
||||
notification.icon = path.join(self.get_top_dir(), "resources", "servo_64.png")
|
||||
notification.send(block=False)
|
||||
except notifypy.exceptions.UnsupportedPlatform as e:
|
||||
print(f"[Warning] Could not generate notification: {e}", file=sys.stderr)
|
||||
|
||||
|
||||
def copy_windows_dlls_to_build_directory(servo_binary: str, target: BuildTarget) -> bool:
|
||||
servo_exe_dir = os.path.dirname(servo_binary)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue