mirror of
https://github.com/codex-storage/deluge.git
synced 2025-02-02 06:36:15 +00:00
dbus fallback
This commit is contained in:
parent
f2f1739760
commit
0eb837ba18
@ -18,6 +18,12 @@
|
|||||||
# 51 Franklin Street, Fifth Floor
|
# 51 Franklin Street, Fifth Floor
|
||||||
# Boston, MA 02110-1301, USA.
|
# Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
|
|
||||||
|
# Code for dbus_importing borrowed from Listen (http://listen-project.org)
|
||||||
|
# I couldn't figure out how to use dbus without breaking on versions past
|
||||||
|
# 0.80.0. I finally found a solution by reading the source code from the
|
||||||
|
# Listen project.
|
||||||
|
try:
|
||||||
import dbus, dbus.service
|
import dbus, dbus.service
|
||||||
dbus_version = getattr(dbus, 'version', (0,0,0))
|
dbus_version = getattr(dbus, 'version', (0,0,0))
|
||||||
if dbus_version >= (0,41,0) and dbus_version < (0,80,0):
|
if dbus_version >= (0,41,0) and dbus_version < (0,80,0):
|
||||||
@ -29,7 +35,10 @@ elif dbus_version >= (0,80,0):
|
|||||||
dbus.SessionBus()
|
dbus.SessionBus()
|
||||||
else:
|
else:
|
||||||
pass
|
pass
|
||||||
|
except: dbus_imported = False
|
||||||
|
else: dbus_imported = True
|
||||||
|
|
||||||
|
if dbus_imported:
|
||||||
class Manager(dbus.service.Object):
|
class Manager(dbus.service.Object):
|
||||||
def __init__(self, interface, object_path='/org/deluge_torrent/DelugeObject'):
|
def __init__(self, interface, object_path='/org/deluge_torrent/DelugeObject'):
|
||||||
self.interface = interface
|
self.interface = interface
|
||||||
@ -41,5 +50,11 @@ class Manager(dbus.service.Object):
|
|||||||
@dbus.service.method('org.deluge_torrent.Deluge')
|
@dbus.service.method('org.deluge_torrent.Deluge')
|
||||||
def external_add_torrent(self, torrent_file):
|
def external_add_torrent(self, torrent_file):
|
||||||
self.interface.external_add_torrent(torrent_file)
|
self.interface.external_add_torrent(torrent_file)
|
||||||
|
else:
|
||||||
|
# This is a fallback class in case dbus is not available
|
||||||
|
class Manager:
|
||||||
|
def __init__(self, interface, object_path=None):
|
||||||
|
self.interface = interface
|
||||||
|
|
||||||
|
def external_add_torrent(self, torrent_file):
|
||||||
|
print "I can't do anything with this."
|
||||||
|
Loading…
x
Reference in New Issue
Block a user