It basically uses DBus and HAL (to support older distributions) and ConsoleKit/DeviceKit-power (to support newer distributions), I think the code is pretty much self explanatory.
Thanks
It will work on probably 99% of the systems running a graphical environment. This code is targeted at desktop system because it would be kind of pointless to shutdown, hibernate or suspend a server via SABnzbd. If the platform doesn't support these things the code will handle it.shypike wrote: Thanks, quite interesting.
My Linux knowledge is quite superficial, hence the question:
This is portable over the different distributions and will not cause problems when not supported by the platform?
I think we can include it in release 0.5.0.
Code: Select all
try:
import dbus
except ImportError:
pass
else:
try:
name = 'org.freedesktop.PowerManagement'
path = '/org/freedesktop/PowerManagement'
interface = 'org.freedesktop.PowerManagement'
bus = dbus.SessionBus()
proxy = bus.get_object(name, path)
except dbus.exceptions.DBusException:
try:
name = 'org.freedesktop.ConsoleKit'
path = '/org/freedesktop/ConsoleKit/Manager'
interface = 'org.freedesktop.ConsoleKit.Manager'
bus = dbus.SystemBus()
proxy = bus.get_object(name, path)
except dbus.exceptions.DBusException:
pass
else:
if proxy.CanStop(dbus_interface=interface):
proxy.Stop(dbus_interface=interface)
else:
if proxy.CanShutdown():
proxy.Shutdown(dbus_interface=interface)
finally:
os._exit(0)
It will be included, but current the development pace of SABnzbd is quite low.carresmd wrote: Hi shypike, any news regarding my patch?![]()
Great to hear that! Not so much about the development pace though, but that's just how stuff goes.shypike wrote: It will be included, but current the development pace of SABnzbd is quite low.