Changed from Pyro to DBUS.. Still doesn't do anything.
This commit is contained in:
parent
29c4b6aee1
commit
59656397d0
|
@ -33,6 +33,21 @@
|
|||
|
||||
import logging
|
||||
|
||||
try:
|
||||
import dbus, dbus.service
|
||||
dbus_version = getattr(dbus, "version", (0,0,0))
|
||||
if dbus_version >= (0,41,0) and dbus_version < (0,80,0):
|
||||
import dbus.glib
|
||||
elif dbus_version >= (0,80,0):
|
||||
from dbus.mainloop.glib import DBusGMainLoop
|
||||
DBusGMainLoop(set_as_default=True)
|
||||
else:
|
||||
pass
|
||||
except: dbus_imported = False
|
||||
else: dbus_imported = True
|
||||
|
||||
import gobject
|
||||
|
||||
from deluge.config import Config
|
||||
import deluge.common
|
||||
|
||||
|
@ -42,11 +57,18 @@ log = logging.getLogger("deluge")
|
|||
DEFAULT_PREFS = {
|
||||
}
|
||||
|
||||
class Core:
|
||||
def __init__(self):
|
||||
class Core(dbus.service.Object):
|
||||
def __init__(self, path="/org/deluge_torrent/Core"):
|
||||
log.debug("Core init..")
|
||||
|
||||
bus_name = dbus.service.BusName("org.deluge_torrent.Deluge",
|
||||
bus=dbus.SessionBus())
|
||||
dbus.service.Object.__init__(self, bus_name, path)
|
||||
self.config = Config("core.conf", DEFAULT_PREFS)
|
||||
log.debug("Starting main loop..")
|
||||
loop = gobject.MainLoop()
|
||||
loop.run()
|
||||
|
||||
@dbus.service.method("org.deluge_torrent.Deluge")
|
||||
def test(self):
|
||||
print "test"
|
||||
|
||||
|
|
|
@ -30,11 +30,21 @@
|
|||
# but you are not obligated to do so. If you do not wish to do so, delete
|
||||
# this exception statement from your version. If you delete this exception
|
||||
# statement from all source files in the program, then also delete it here.
|
||||
try:
|
||||
import dbus, dbus.service
|
||||
dbus_version = getattr(dbus, "version", (0,0,0))
|
||||
if dbus_version >= (0,41,0) and dbus_version < (0,80,0):
|
||||
import dbus.glib
|
||||
elif dbus_version >= (0,80,0):
|
||||
from dbus.mainloop.glib import DBusGMainLoop
|
||||
DBusGMainLoop(set_as_default=True)
|
||||
else:
|
||||
pass
|
||||
except: dbus_imported = False
|
||||
else: dbus_imported = True
|
||||
|
||||
import logging
|
||||
|
||||
import Pyro.core
|
||||
|
||||
from deluge.core import Core
|
||||
|
||||
# Get the logger
|
||||
|
@ -42,22 +52,15 @@ log = logging.getLogger("deluge")
|
|||
|
||||
class Daemon:
|
||||
def __init__(self):
|
||||
# Instantiate the Manager class
|
||||
# Check to see if the daemon is already running and if not, start it
|
||||
bus = dbus.SessionBus()
|
||||
obj = bus.get_object("org.freedesktop.DBus", "/org/freedesktop/DBus")
|
||||
iface = dbus.Interface(obj, "org.freedesktop.DBus")
|
||||
if iface.NameHasOwner("org.deluge_torrent.Deluge"):
|
||||
# Daemon is running so lets tell the user
|
||||
log.info("Daemon is already running..")
|
||||
else:
|
||||
# Daemon is not running so lets start up the core
|
||||
log.debug("Daemon is not running..")
|
||||
self.core = Core()
|
||||
# Initialize the Pyro core and daemon
|
||||
Pyro.core.initServer(banner=0)
|
||||
log.debug("Pyro server initiliazed..")
|
||||
self.daemon = Pyro.core.Daemon()
|
||||
# Connect the Manager to the Pyro server
|
||||
obj = Pyro.core.ObjBase()
|
||||
obj.delegateTo(self.core)
|
||||
self.uri = self.daemon.connect(obj, "core")
|
||||
log.debug("uri: %s", self.uri)
|
||||
|
||||
def start(self):
|
||||
# Start the main loop for the pyro daemon
|
||||
self.daemon.requestLoop()
|
||||
|
||||
def get_uri(self):
|
||||
# Return the URI for the Pyro server
|
||||
return self.uri
|
||||
|
|
|
@ -76,18 +76,19 @@ def main():
|
|||
# Start the daemon
|
||||
if options.daemon:
|
||||
log.info("Starting daemon..")
|
||||
daemon = Daemon()
|
||||
uri = daemon.get_uri()
|
||||
# We need to fork() the process to run it in the background...
|
||||
# FIXME: We cannot use fork() on Windows
|
||||
pid = os.fork()
|
||||
if not pid:
|
||||
daemon.start()
|
||||
# Since we are starting daemon this process will not start a UI
|
||||
options.ui = False
|
||||
# Create the daemon object
|
||||
daemon = Daemon()
|
||||
|
||||
# Start the UI
|
||||
if options.ui:
|
||||
log.info("Starting ui..")
|
||||
ui = Ui(uri)
|
||||
ui = Ui()
|
||||
|
||||
# Stop Deluge
|
||||
log.info ("Stopping Deluge..")
|
||||
|
|
|
@ -33,18 +33,31 @@
|
|||
|
||||
import logging
|
||||
|
||||
import Pyro.core
|
||||
try:
|
||||
import dbus, dbus.service
|
||||
dbus_version = getattr(dbus, "version", (0,0,0))
|
||||
if dbus_version >= (0,41,0) and dbus_version < (0,80,0):
|
||||
import dbus.glib
|
||||
elif dbus_version >= (0,80,0):
|
||||
from dbus.mainloop.glib import DBusGMainLoop
|
||||
DBusGMainLoop(set_as_default=True)
|
||||
else:
|
||||
pass
|
||||
except: dbus_imported = False
|
||||
else: dbus_imported = True
|
||||
|
||||
# Get the logger
|
||||
log = logging.getLogger("deluge")
|
||||
|
||||
class Ui:
|
||||
def __init__(self, core_uri):
|
||||
def __init__(self):
|
||||
log.debug("Ui init..")
|
||||
log.debug("core_uri: %s", core_uri)
|
||||
# Get the core manager from the Pyro server
|
||||
if core_uri != None:
|
||||
self.core = Pyro.core.getProxyForURI(core_uri)
|
||||
# Test
|
||||
log.debug("Getting core proxy object from DBUS..")
|
||||
# Get the proxy object from DBUS
|
||||
bus = dbus.SessionBus()
|
||||
proxy = bus.get_object("org.deluge_torrent.Deluge",
|
||||
"/org/deluge_torrent/Core")
|
||||
self.core = dbus.Interface(proxy, "org.deluge_torrent.Deluge")
|
||||
log.debug("Got core proxy object..")
|
||||
# Test the interface.. this calls test() in Core
|
||||
self.core.test()
|
||||
|
||||
|
|
27
setup.py
27
setup.py
|
@ -38,7 +38,7 @@ import glob
|
|||
python_version = platform.python_version()[0:3]
|
||||
|
||||
# The libtorrent extension
|
||||
__extra_compile_args = [
|
||||
_extra_compile_args = [
|
||||
"-Wno-missing-braces",
|
||||
"-DHAVE_INCLUDE_LIBTORRENT_ASIO____ASIO_HPP=1",
|
||||
"-DHAVE_INCLUDE_LIBTORRENT_ASIO_SSL_STREAM_HPP=1",
|
||||
|
@ -48,14 +48,14 @@ __extra_compile_args = [
|
|||
"-DHAVE_SSL=1"
|
||||
]
|
||||
|
||||
__include_dirs = [
|
||||
_include_dirs = [
|
||||
'./libtorrent',
|
||||
'./libtorrent/include',
|
||||
'./libtorrent/include/libtorrent',
|
||||
'/usr/include/python' + python_version
|
||||
]
|
||||
|
||||
__libraries = [
|
||||
_libraries = [
|
||||
'boost_filesystem',
|
||||
'boost_date_time',
|
||||
'boost_thread',
|
||||
|
@ -64,26 +64,25 @@ __libraries = [
|
|||
'ssl'
|
||||
]
|
||||
|
||||
__sources = glob.glob("./libtorrent/src/*.cpp") + glob.glob("./libtorrent/src/kademelia/*.cpp") + glob.glob("./libtorrent/bindings/python/src/*.cpp")
|
||||
_sources = glob.glob("./libtorrent/src/*.cpp") + glob.glob("./libtorrent/src/kademelia/*.cpp") + glob.glob("./libtorrent/bindings/python/src/*.cpp")
|
||||
|
||||
# Remove file_win.cpp as it is only for Windows builds
|
||||
for source in __sources:
|
||||
for source in _sources:
|
||||
if "file_win.cpp" in source:
|
||||
__sources.remove(source)
|
||||
_sources.remove(source)
|
||||
break
|
||||
|
||||
libtorrent = Extension(
|
||||
'libtorrent',
|
||||
include_dirs = __include_dirs,
|
||||
libraries = __libraries,
|
||||
extra_compile_args = __extra_compile_args,
|
||||
sources = __sources
|
||||
include_dirs = _include_dirs,
|
||||
libraries = _libraries,
|
||||
extra_compile_args = _extra_compile_args,
|
||||
sources = _sources
|
||||
)
|
||||
|
||||
print find_packages("deluge")
|
||||
# Main setup
|
||||
|
||||
__data_files = [
|
||||
_data_files = [
|
||||
# ('share/deluge/glade', glob.glob("share/deluge/glade/*.glade")),
|
||||
# ('share/deluge/pixmaps', glob.glob('share/deluge/pixmaps/*.png')),
|
||||
('share/applications' , ["deluge/share/applications/deluge.desktop"]),
|
||||
|
@ -100,10 +99,8 @@ setup(
|
|||
url = "http://deluge-torrent.org",
|
||||
license = "GPLv2",
|
||||
|
||||
# packages = find_packages("deluge"),
|
||||
include_package_data = True,
|
||||
#scripts = ["scripts/deluge"],
|
||||
data_files = __data_files,
|
||||
data_files = _data_files,
|
||||
ext_package = "deluge",
|
||||
ext_modules = [libtorrent],
|
||||
packages=['deluge'],
|
||||
|
|
Loading…
Reference in New Issue