Kaydet (Commit) 00e20fbf authored tarafından Bahadır Kandemir's avatar Bahadır Kandemir

waitBus after starting D-Bus

üst d1281372
......@@ -14,6 +14,7 @@ import os
import locale
import time
import dbus
import socket
import subprocess
# i18n
......@@ -36,6 +37,20 @@ def loadConfig(path):
dict[key] = value
return dict
def waitBus(unix_name, timeout=10, wait=0.1, stream=True):
if stream:
sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
else:
sock = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM)
while timeout > 0:
try:
sock.connect(unix_name)
return True
except:
timeout -= wait
time.sleep(wait)
return False
# Operations
class Service:
......@@ -218,6 +233,9 @@ def manage_dbus(op, use_color, quiet):
run("/sbin/start-stop-daemon", "-b", "--start", "--quiet",
"--pidfile", "/var/run/dbus/pid", "--exec", "/usr/bin/dbus-daemon",
"--", "--system")
if not waitBus("/var/run/dbus/system_bus_socket"):
print _("Unable to start D-Bus")
return
elif op == "stop":
if not quiet:
print _("Stopping DBus...")
......
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