mirror of
https://github.com/codex-storage/deluge.git
synced 2025-01-11 12:04:10 +00:00
Changed from 2 spaces ident to 4
This commit is contained in:
parent
a7c93458c8
commit
702967a2c6
@ -1,7 +1,7 @@
|
|||||||
#
|
#
|
||||||
# common.py
|
# common.py
|
||||||
#
|
#
|
||||||
# Copyright (C) Andrew Resch 2007 <andrewresch@gmail.com>
|
# Copyright (C) Andrew Resch 2007 <andrewresch@gmail.com>
|
||||||
#
|
#
|
||||||
# Deluge is free software.
|
# Deluge is free software.
|
||||||
#
|
#
|
||||||
@ -16,20 +16,20 @@
|
|||||||
# See the GNU General Public License for more details.
|
# See the GNU General Public License for more details.
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with deluge. If not, write to:
|
# along with deluge. If not, write to:
|
||||||
# The Free Software Foundation, Inc.,
|
# The Free Software Foundation, Inc.,
|
||||||
# 51 Franklin Street, Fifth Floor
|
# 51 Franklin Street, Fifth Floor
|
||||||
# Boston, MA 02110-1301, USA.
|
# Boston, MA 02110-1301, USA.
|
||||||
#
|
#
|
||||||
# In addition, as a special exception, the copyright holders give
|
# In addition, as a special exception, the copyright holders give
|
||||||
# permission to link the code of portions of this program with the OpenSSL
|
# permission to link the code of portions of this program with the OpenSSL
|
||||||
# library.
|
# library.
|
||||||
# You must obey the GNU General Public License in all respects for all of
|
# You must obey the GNU General Public License in all respects for all of
|
||||||
# the code used other than OpenSSL. If you modify file(s) with this
|
# the code used other than OpenSSL. If you modify file(s) with this
|
||||||
# exception, you may extend this exception to your version of the file(s),
|
# exception, you may extend this exception to your version of the file(s),
|
||||||
# but you are not obligated to do so. If you do not wish to do so, delete
|
# 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
|
# this exception statement from your version. If you delete this exception
|
||||||
# statement from all source files in the program, then also delete it here.
|
# statement from all source files in the program, then also delete it here.
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import pkg_resources
|
import pkg_resources
|
||||||
@ -40,18 +40,19 @@ import os
|
|||||||
log = logging.getLogger("deluge")
|
log = logging.getLogger("deluge")
|
||||||
|
|
||||||
def get_version():
|
def get_version():
|
||||||
"""Returns the program version from the egg metadata"""
|
"""Returns the program version from the egg metadata"""
|
||||||
return pkg_resources.require("Deluge")[0].version
|
return pkg_resources.require("Deluge")[0].version
|
||||||
|
|
||||||
def get_config_dir(filename=None):
|
def get_config_dir(filename=None):
|
||||||
""" Returns the config path if no filename is specified
|
""" Returns the config path if no filename is specified
|
||||||
Returns the config directory + filename as a path if filename is specified
|
Returns the config directory + filename as a path if filename is specified
|
||||||
"""
|
"""
|
||||||
if filename != None:
|
if filename != None:
|
||||||
return os.path.join(xdg.BaseDirectory.save_config_path("deluge"), filename)
|
return os.path.join(xdg.BaseDirectory.save_config_path("deluge"),
|
||||||
else:
|
filename)
|
||||||
return xdg.BaseDirectory.save_config_path("deluge")
|
else:
|
||||||
|
return xdg.BaseDirectory.save_config_path("deluge")
|
||||||
|
|
||||||
def get_default_download_dir():
|
def get_default_download_dir():
|
||||||
"""Returns the default download directory"""
|
"""Returns the default download directory"""
|
||||||
return os.environ.get("HOME")
|
return os.environ.get("HOME")
|
||||||
|
135
deluge/config.py
135
deluge/config.py
@ -1,7 +1,7 @@
|
|||||||
#
|
#
|
||||||
# config.py
|
# config.py
|
||||||
#
|
#
|
||||||
# Copyright (C) Andrew Resch 2007 <andrewresch@gmail.com>
|
# Copyright (C) Andrew Resch 2007 <andrewresch@gmail.com>
|
||||||
#
|
#
|
||||||
# Deluge is free software.
|
# Deluge is free software.
|
||||||
#
|
#
|
||||||
@ -16,20 +16,20 @@
|
|||||||
# See the GNU General Public License for more details.
|
# See the GNU General Public License for more details.
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with deluge. If not, write to:
|
# along with deluge. If not, write to:
|
||||||
# The Free Software Foundation, Inc.,
|
# The Free Software Foundation, Inc.,
|
||||||
# 51 Franklin Street, Fifth Floor
|
# 51 Franklin Street, Fifth Floor
|
||||||
# Boston, MA 02110-1301, USA.
|
# Boston, MA 02110-1301, USA.
|
||||||
#
|
#
|
||||||
# In addition, as a special exception, the copyright holders give
|
# In addition, as a special exception, the copyright holders give
|
||||||
# permission to link the code of portions of this program with the OpenSSL
|
# permission to link the code of portions of this program with the OpenSSL
|
||||||
# library.
|
# library.
|
||||||
# You must obey the GNU General Public License in all respects for all of
|
# You must obey the GNU General Public License in all respects for all of
|
||||||
# the code used other than OpenSSL. If you modify file(s) with this
|
# the code used other than OpenSSL. If you modify file(s) with this
|
||||||
# exception, you may extend this exception to your version of the file(s),
|
# exception, you may extend this exception to your version of the file(s),
|
||||||
# but you are not obligated to do so. If you do not wish to do so, delete
|
# 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
|
# this exception statement from your version. If you delete this exception
|
||||||
# statement from all source files in the program, then also delete it here.
|
# statement from all source files in the program, then also delete it here.
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import pickle
|
import pickle
|
||||||
@ -40,65 +40,66 @@ import deluge.common
|
|||||||
log = logging.getLogger("deluge")
|
log = logging.getLogger("deluge")
|
||||||
|
|
||||||
class Config:
|
class Config:
|
||||||
def __init__(self, filename, defaults=None):
|
def __init__(self, filename, defaults=None):
|
||||||
log.debug("Config created with filename: %s", filename)
|
log.debug("Config created with filename: %s", filename)
|
||||||
log.debug("Config defaults: %s", defaults)
|
log.debug("Config defaults: %s", defaults)
|
||||||
self.config = {}
|
self.config = {}
|
||||||
# If defaults is not None then we need to use "defaults".
|
# If defaults is not None then we need to use "defaults".
|
||||||
if defaults != None:
|
if defaults != None:
|
||||||
self.config = defaults
|
self.config = defaults
|
||||||
|
|
||||||
# Load the config from file in the config_dir
|
# Load the config from file in the config_dir
|
||||||
self.config_file = deluge.common.get_config_dir(filename)
|
self.config_file = deluge.common.get_config_dir(filename)
|
||||||
self.load(self.config_file)
|
self.load(self.config_file)
|
||||||
|
|
||||||
def load(self, filename=None):
|
def load(self, filename=None):
|
||||||
# Use self.config_file if filename is None
|
# Use self.config_file if filename is None
|
||||||
if filename is None:
|
if filename is None:
|
||||||
filename = self.config_file
|
filename = self.config_file
|
||||||
try:
|
try:
|
||||||
# Un-pickle the file and update the config dictionary
|
# Un-pickle the file and update the config dictionary
|
||||||
log.debug("Opening pickled file for load..")
|
log.debug("Opening pickled file for load..")
|
||||||
pkl_file = open(filename, "rb")
|
pkl_file = open(filename, "rb")
|
||||||
filedump = pickle.load(pkl_file)
|
filedump = pickle.load(pkl_file)
|
||||||
self.config.update(filedump)
|
self.config.update(filedump)
|
||||||
pkl_file.close()
|
pkl_file.close()
|
||||||
except IOError:
|
except IOError:
|
||||||
log.warning("IOError: Unable to load file '%s'", filename)
|
log.warning("IOError: Unable to load file '%s'", filename)
|
||||||
except EOFError:
|
except EOFError:
|
||||||
log.debug("Closing pickled file..")
|
log.debug("Closing pickled file..")
|
||||||
pkl_file.close()
|
pkl_file.close()
|
||||||
|
|
||||||
def save(self, filename=None):
|
def save(self, filename=None):
|
||||||
# Saves the config dictionary
|
# Saves the config dictionary
|
||||||
if filename is None:
|
if filename is None:
|
||||||
filename = self.config_file
|
filename = self.config_file
|
||||||
try:
|
try:
|
||||||
log.debug("Opening pickled file for save..")
|
log.debug("Opening pickled file for save..")
|
||||||
pkl_file = open(filename, "wb")
|
pkl_file = open(filename, "wb")
|
||||||
pickle.dump(self.config, pkl_file)
|
pickle.dump(self.config, pkl_file)
|
||||||
log.debug("Closing pickled file..")
|
log.debug("Closing pickled file..")
|
||||||
pkl_file.close()
|
pkl_file.close()
|
||||||
except IOError:
|
except IOError:
|
||||||
log.warning("IOError: Unable to save file '%s'", filename)
|
log.warning("IOError: Unable to save file '%s'", filename)
|
||||||
|
|
||||||
def set(self, key, value):
|
def set(self, key, value):
|
||||||
# Sets the "key" with "value" in the config dict
|
# Sets the "key" with "value" in the config dict
|
||||||
log.debug("Setting '%s' to %s", key, value)
|
log.debug("Setting '%s' to %s", key, value)
|
||||||
self.config[key] = value
|
self.config[key] = value
|
||||||
|
|
||||||
def get(self, key):
|
def get(self, key):
|
||||||
# Attempts to get the "key" value and returns None if the key is invalid
|
# Attempts to get the "key" value and returns None if the key is
|
||||||
try:
|
# invalid
|
||||||
value = self.config[key]
|
try:
|
||||||
log.debug("Getting '%s' as %s", key, value)
|
value = self.config[key]
|
||||||
return value
|
log.debug("Getting '%s' as %s", key, value)
|
||||||
except KeyError:
|
return value
|
||||||
log.warning("Key does not exist, returning None")
|
except KeyError:
|
||||||
return
|
log.warning("Key does not exist, returning None")
|
||||||
|
return
|
||||||
|
|
||||||
def __getitem__(self, key):
|
def __getitem__(self, key):
|
||||||
return self.config[key]
|
return self.config[key]
|
||||||
|
|
||||||
def __setitem__(self, key, value):
|
def __setitem__(self, key, value):
|
||||||
self.config[key] = value
|
self.config[key] = value
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#
|
#
|
||||||
# core.py
|
# core.py
|
||||||
#
|
#
|
||||||
# Copyright (C) Andrew Resch 2007 <andrewresch@gmail.com>
|
# Copyright (C) Andrew Resch 2007 <andrewresch@gmail.com>
|
||||||
#
|
#
|
||||||
# Deluge is free software.
|
# Deluge is free software.
|
||||||
#
|
#
|
||||||
@ -16,20 +16,20 @@
|
|||||||
# See the GNU General Public License for more details.
|
# See the GNU General Public License for more details.
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with deluge. If not, write to:
|
# along with deluge. If not, write to:
|
||||||
# The Free Software Foundation, Inc.,
|
# The Free Software Foundation, Inc.,
|
||||||
# 51 Franklin Street, Fifth Floor
|
# 51 Franklin Street, Fifth Floor
|
||||||
# Boston, MA 02110-1301, USA.
|
# Boston, MA 02110-1301, USA.
|
||||||
#
|
#
|
||||||
# In addition, as a special exception, the copyright holders give
|
# In addition, as a special exception, the copyright holders give
|
||||||
# permission to link the code of portions of this program with the OpenSSL
|
# permission to link the code of portions of this program with the OpenSSL
|
||||||
# library.
|
# library.
|
||||||
# You must obey the GNU General Public License in all respects for all of
|
# You must obey the GNU General Public License in all respects for all of
|
||||||
# the code used other than OpenSSL. If you modify file(s) with this
|
# the code used other than OpenSSL. If you modify file(s) with this
|
||||||
# exception, you may extend this exception to your version of the file(s),
|
# exception, you may extend this exception to your version of the file(s),
|
||||||
# but you are not obligated to do so. If you do not wish to do so, delete
|
# 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
|
# this exception statement from your version. If you delete this exception
|
||||||
# statement from all source files in the program, then also delete it here.
|
# statement from all source files in the program, then also delete it here.
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
@ -58,65 +58,65 @@ log = logging.getLogger("deluge")
|
|||||||
|
|
||||||
#_default_download_dir = deluge.common.get_default_download_dir()
|
#_default_download_dir = deluge.common.get_default_download_dir()
|
||||||
DEFAULT_PREFS = {
|
DEFAULT_PREFS = {
|
||||||
"listen_ports": [6881, 6891],
|
"listen_ports": [6881, 6891],
|
||||||
"download_location": deluge.common.get_default_download_dir(),
|
"download_location": deluge.common.get_default_download_dir(),
|
||||||
"compact_allocation": True
|
"compact_allocation": True
|
||||||
}
|
}
|
||||||
|
|
||||||
class Core(dbus.service.Object):
|
class Core(dbus.service.Object):
|
||||||
def __init__(self, path="/org/deluge_torrent/Core"):
|
def __init__(self, path="/org/deluge_torrent/Core"):
|
||||||
log.debug("Core init..")
|
log.debug("Core init..")
|
||||||
bus_name = dbus.service.BusName("org.deluge_torrent.Deluge",
|
bus_name = dbus.service.BusName("org.deluge_torrent.Deluge",
|
||||||
bus=dbus.SessionBus())
|
bus=dbus.SessionBus())
|
||||||
dbus.service.Object.__init__(self, bus_name, path)
|
dbus.service.Object.__init__(self, bus_name, path)
|
||||||
self.config = Config("core.conf", DEFAULT_PREFS)
|
self.config = Config("core.conf", DEFAULT_PREFS)
|
||||||
# Setup the libtorrent session and listen on the configured ports
|
# Setup the libtorrent session and listen on the configured ports
|
||||||
log.debug("Starting libtorrent session..")
|
log.debug("Starting libtorrent session..")
|
||||||
self.session = lt.session()
|
self.session = lt.session()
|
||||||
log.debug("Listening on %i-%i", self.config.get("listen_ports")[0],
|
log.debug("Listening on %i-%i", self.config.get("listen_ports")[0],
|
||||||
self.config.get("listen_ports")[1])
|
self.config.get("listen_ports")[1])
|
||||||
self.session.listen_on(self.config.get("listen_ports")[0],
|
self.session.listen_on(self.config.get("listen_ports")[0],
|
||||||
self.config.get("listen_ports")[1])
|
self.config.get("listen_ports")[1])
|
||||||
|
|
||||||
log.debug("Starting main loop..")
|
log.debug("Starting main loop..")
|
||||||
self.loop = gobject.MainLoop()
|
self.loop = gobject.MainLoop()
|
||||||
self.loop.run()
|
self.loop.run()
|
||||||
|
|
||||||
|
|
||||||
# Exported Methods
|
# Exported Methods
|
||||||
@dbus.service.method(dbus_interface="org.deluge_torrent.Deluge",
|
@dbus.service.method(dbus_interface="org.deluge_torrent.Deluge",
|
||||||
in_signature="s", out_signature="")
|
in_signature="s", out_signature="")
|
||||||
def add_torrent_file(self, _filename):
|
def add_torrent_file(self, _filename):
|
||||||
"""Adds a torrent file to the libtorrent session
|
"""Adds a torrent file to the libtorrent session
|
||||||
"""
|
"""
|
||||||
log.info("Adding torrent: %s", _filename)
|
log.info("Adding torrent: %s", _filename)
|
||||||
torrent = Torrent(filename=_filename)
|
torrent = Torrent(filename=_filename)
|
||||||
self.session.add_torrent(torrent.torrent_info,
|
self.session.add_torrent(torrent.torrent_info,
|
||||||
self.config["download_location"],
|
self.config["download_location"],
|
||||||
self.config["compact_allocation"])
|
self.config["compact_allocation"])
|
||||||
# Emit the torrent_added signal
|
# Emit the torrent_added signal
|
||||||
self.torrent_added()
|
self.torrent_added()
|
||||||
|
|
||||||
@dbus.service.method(dbus_interface="org.deluge_torrent.Deluge",
|
@dbus.service.method(dbus_interface="org.deluge_torrent.Deluge",
|
||||||
in_signature="s", out_signature="")
|
in_signature="s", out_signature="")
|
||||||
def add_torrent_url(self, _url):
|
def add_torrent_url(self, _url):
|
||||||
"""Adds a torrent from url to the libtorrent session
|
"""Adds a torrent from url to the libtorrent session
|
||||||
"""
|
"""
|
||||||
log.info("Adding torrent: %s", _url)
|
log.info("Adding torrent: %s", _url)
|
||||||
torrent = Torrent(url=_url)
|
torrent = Torrent(url=_url)
|
||||||
self.session.add_torrent(torrent.torrent_info,
|
self.session.add_torrent(torrent.torrent_info,
|
||||||
self.config["download_location"],
|
self.config["download_location"],
|
||||||
self.config["compact_allocation"])
|
self.config["compact_allocation"])
|
||||||
|
|
||||||
|
|
||||||
@dbus.service.method("org.deluge_torrent.Deluge")
|
@dbus.service.method("org.deluge_torrent.Deluge")
|
||||||
def shutdown(self):
|
def shutdown(self):
|
||||||
log.info("Shutting down core..")
|
log.info("Shutting down core..")
|
||||||
self.loop.quit()
|
self.loop.quit()
|
||||||
|
|
||||||
# Signals
|
# Signals
|
||||||
@dbus.service.signal(dbus_interface="org.deluge_torrent.Deluge",
|
@dbus.service.signal(dbus_interface="org.deluge_torrent.Deluge",
|
||||||
signature="")
|
signature="")
|
||||||
def torrent_added(self):
|
def torrent_added(self):
|
||||||
"""Emitted when a new torrent is added to the core"""
|
"""Emitted when a new torrent is added to the core"""
|
||||||
pass
|
pass
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#
|
#
|
||||||
# daemon.py
|
# daemon.py
|
||||||
#
|
#
|
||||||
# Copyright (C) Andrew Resch 2007 <andrewresch@gmail.com>
|
# Copyright (C) Andrew Resch 2007 <andrewresch@gmail.com>
|
||||||
#
|
#
|
||||||
# Deluge is free software.
|
# Deluge is free software.
|
||||||
#
|
#
|
||||||
@ -16,30 +16,30 @@
|
|||||||
# See the GNU General Public License for more details.
|
# See the GNU General Public License for more details.
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with deluge. If not, write to:
|
# along with deluge. If not, write to:
|
||||||
# The Free Software Foundation, Inc.,
|
# The Free Software Foundation, Inc.,
|
||||||
# 51 Franklin Street, Fifth Floor
|
# 51 Franklin Street, Fifth Floor
|
||||||
# Boston, MA 02110-1301, USA.
|
# Boston, MA 02110-1301, USA.
|
||||||
#
|
#
|
||||||
# In addition, as a special exception, the copyright holders give
|
# In addition, as a special exception, the copyright holders give
|
||||||
# permission to link the code of portions of this program with the OpenSSL
|
# permission to link the code of portions of this program with the OpenSSL
|
||||||
# library.
|
# library.
|
||||||
# You must obey the GNU General Public License in all respects for all of
|
# You must obey the GNU General Public License in all respects for all of
|
||||||
# the code used other than OpenSSL. If you modify file(s) with this
|
# the code used other than OpenSSL. If you modify file(s) with this
|
||||||
# exception, you may extend this exception to your version of the file(s),
|
# exception, you may extend this exception to your version of the file(s),
|
||||||
# but you are not obligated to do so. If you do not wish to do so, delete
|
# 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
|
# this exception statement from your version. If you delete this exception
|
||||||
# statement from all source files in the program, then also delete it here.
|
# statement from all source files in the program, then also delete it here.
|
||||||
try:
|
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):
|
||||||
import dbus.glib
|
import dbus.glib
|
||||||
elif dbus_version >= (0,80,0):
|
elif dbus_version >= (0,80,0):
|
||||||
from dbus.mainloop.glib import DBusGMainLoop
|
from dbus.mainloop.glib import DBusGMainLoop
|
||||||
DBusGMainLoop(set_as_default=True)
|
DBusGMainLoop(set_as_default=True)
|
||||||
else:
|
else:
|
||||||
pass
|
pass
|
||||||
except: dbus_imported = False
|
except: dbus_imported = False
|
||||||
else: dbus_imported = True
|
else: dbus_imported = True
|
||||||
|
|
||||||
@ -51,16 +51,16 @@ from deluge.core.core import Core
|
|||||||
log = logging.getLogger("deluge")
|
log = logging.getLogger("deluge")
|
||||||
|
|
||||||
class Daemon:
|
class Daemon:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
# Check to see if the daemon is already running and if not, start it
|
# Check to see if the daemon is already running and if not, start it
|
||||||
bus = dbus.SessionBus()
|
bus = dbus.SessionBus()
|
||||||
obj = bus.get_object("org.freedesktop.DBus", "/org/freedesktop/DBus")
|
obj = bus.get_object("org.freedesktop.DBus", "/org/freedesktop/DBus")
|
||||||
iface = dbus.Interface(obj, "org.freedesktop.DBus")
|
iface = dbus.Interface(obj, "org.freedesktop.DBus")
|
||||||
if iface.NameHasOwner("org.deluge_torrent.Deluge"):
|
if iface.NameHasOwner("org.deluge_torrent.Deluge"):
|
||||||
# Daemon is running so lets tell the user
|
# Daemon is running so lets tell the user
|
||||||
log.info("Daemon is already running..")
|
log.info("Daemon is already running..")
|
||||||
else:
|
else:
|
||||||
# Daemon is not running so lets start up the core
|
# Daemon is not running so lets start up the core
|
||||||
log.debug("Daemon is not running..")
|
log.debug("Daemon is not running..")
|
||||||
self.core = Core()
|
self.core = Core()
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#
|
#
|
||||||
# torrent.py
|
# torrent.py
|
||||||
#
|
#
|
||||||
# Copyright (C) Andrew Resch 2007 <andrewresch@gmail.com>
|
# Copyright (C) Andrew Resch 2007 <andrewresch@gmail.com>
|
||||||
#
|
#
|
||||||
# Deluge is free software.
|
# Deluge is free software.
|
||||||
#
|
#
|
||||||
@ -16,27 +16,27 @@
|
|||||||
# See the GNU General Public License for more details.
|
# See the GNU General Public License for more details.
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with deluge. If not, write to:
|
# along with deluge. If not, write to:
|
||||||
# The Free Software Foundation, Inc.,
|
# The Free Software Foundation, Inc.,
|
||||||
# 51 Franklin Street, Fifth Floor
|
# 51 Franklin Street, Fifth Floor
|
||||||
# Boston, MA 02110-1301, USA.
|
# Boston, MA 02110-1301, USA.
|
||||||
#
|
#
|
||||||
# In addition, as a special exception, the copyright holders give
|
# In addition, as a special exception, the copyright holders give
|
||||||
# permission to link the code of portions of this program with the OpenSSL
|
# permission to link the code of portions of this program with the OpenSSL
|
||||||
# library.
|
# library.
|
||||||
# You must obey the GNU General Public License in all respects for all of
|
# You must obey the GNU General Public License in all respects for all of
|
||||||
# the code used other than OpenSSL. If you modify file(s) with this
|
# the code used other than OpenSSL. If you modify file(s) with this
|
||||||
# exception, you may extend this exception to your version of the file(s),
|
# exception, you may extend this exception to your version of the file(s),
|
||||||
# but you are not obligated to do so. If you do not wish to do so, delete
|
# 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
|
# this exception statement from your version. If you delete this exception
|
||||||
# statement from all source files in the program, then also delete it here.
|
# statement from all source files in the program, then also delete it here.
|
||||||
|
|
||||||
import deluge.libtorrent as lt
|
import deluge.libtorrent as lt
|
||||||
|
|
||||||
class Torrent:
|
class Torrent:
|
||||||
def __init__(self, filename=None, url=None):
|
def __init__(self, filename=None, url=None):
|
||||||
# Load the torrent file
|
# Load the torrent file
|
||||||
if filename is not None:
|
if filename is not None:
|
||||||
torrent_file = lt.bdecode(open(filename, 'rb').read())
|
torrent_file = lt.bdecode(open(filename, 'rb').read())
|
||||||
self.torrent_info = lt.torrent_info(torrent_file)
|
self.torrent_info = lt.torrent_info(torrent_file)
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#
|
#
|
||||||
# main.py
|
# main.py
|
||||||
#
|
#
|
||||||
# Copyright (C) Andrew Resch 2007 <andrewresch@gmail.com>
|
# Copyright (C) Andrew Resch 2007 <andrewresch@gmail.com>
|
||||||
#
|
#
|
||||||
# Deluge is free software.
|
# Deluge is free software.
|
||||||
#
|
#
|
||||||
@ -16,22 +16,22 @@
|
|||||||
# See the GNU General Public License for more details.
|
# See the GNU General Public License for more details.
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with deluge. If not, write to:
|
# along with deluge. If not, write to:
|
||||||
# The Free Software Foundation, Inc.,
|
# The Free Software Foundation, Inc.,
|
||||||
# 51 Franklin Street, Fifth Floor
|
# 51 Franklin Street, Fifth Floor
|
||||||
# Boston, MA 02110-1301, USA.
|
# Boston, MA 02110-1301, USA.
|
||||||
#
|
#
|
||||||
# In addition, as a special exception, the copyright holders give
|
# In addition, as a special exception, the copyright holders give
|
||||||
# permission to link the code of portions of this program with the OpenSSL
|
# permission to link the code of portions of this program with the OpenSSL
|
||||||
# library.
|
# library.
|
||||||
# You must obey the GNU General Public License in all respects for all of
|
# You must obey the GNU General Public License in all respects for all of
|
||||||
# the code used other than OpenSSL. If you modify file(s) with this
|
# the code used other than OpenSSL. If you modify file(s) with this
|
||||||
# exception, you may extend this exception to your version of the file(s),
|
# exception, you may extend this exception to your version of the file(s),
|
||||||
# but you are not obligated to do so. If you do not wish to do so, delete
|
# 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
|
# this exception statement from your version. If you delete this exception
|
||||||
# statement from all source files in the program, then also delete it here.
|
# statement from all source files in the program, then also delete it here.
|
||||||
|
|
||||||
# The main starting point for the program. This function is called when the
|
# The main starting point for the program. This function is called when the
|
||||||
# user runs the command 'deluge'.
|
# user runs the command 'deluge'.
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
@ -45,47 +45,47 @@ import deluge.common
|
|||||||
|
|
||||||
# Setup the logger
|
# Setup the logger
|
||||||
logging.basicConfig(
|
logging.basicConfig(
|
||||||
level=logging.DEBUG,
|
level=logging.DEBUG,
|
||||||
format="[%(levelname)-8s] %(name)s:%(module)s:%(lineno)d %(message)s"
|
format="[%(levelname)-8s] %(name)s:%(module)s:%(lineno)d %(message)s"
|
||||||
)
|
)
|
||||||
# Get the logger for deluge
|
# Get the logger for deluge
|
||||||
log = logging.getLogger("deluge")
|
log = logging.getLogger("deluge")
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
# Setup the argument parser
|
# Setup the argument parser
|
||||||
# FIXME: need to use deluge.common to fill in version
|
# FIXME: need to use deluge.common to fill in version
|
||||||
parser = OptionParser(usage="%prog [options] [actions]",
|
parser = OptionParser(usage="%prog [options] [actions]",
|
||||||
version=deluge.common.get_version())
|
version=deluge.common.get_version())
|
||||||
parser.add_option("--daemon", dest="daemon", help="Start Deluge daemon",
|
parser.add_option("--daemon", dest="daemon", help="Start Deluge daemon",
|
||||||
metavar="DAEMON", action="store_true", default=False)
|
metavar="DAEMON", action="store_true", default=False)
|
||||||
parser.add_option("--ui", dest="ui", help="Start Deluge UI",
|
parser.add_option("--ui", dest="ui", help="Start Deluge UI",
|
||||||
metavar="UI", action="store_true", default=False)
|
metavar="UI", action="store_true", default=False)
|
||||||
|
|
||||||
# Get the options and args from the OptionParser
|
# Get the options and args from the OptionParser
|
||||||
(options, args) = parser.parse_args()
|
(options, args) = parser.parse_args()
|
||||||
|
|
||||||
log.info("Deluge %s", deluge.common.get_version())
|
log.info("Deluge %s", deluge.common.get_version())
|
||||||
|
|
||||||
log.debug("options: %s", options)
|
log.debug("options: %s", options)
|
||||||
log.debug("args: %s", args)
|
log.debug("args: %s", args)
|
||||||
|
|
||||||
daemon = None
|
daemon = None
|
||||||
pid = None
|
pid = None
|
||||||
uri = None
|
uri = None
|
||||||
|
|
||||||
# Start the daemon
|
# Start the daemon
|
||||||
if options.daemon:
|
if options.daemon:
|
||||||
log.info("Starting daemon..")
|
log.info("Starting daemon..")
|
||||||
# We need to fork() the process to run it in the background...
|
# We need to fork() the process to run it in the background...
|
||||||
# FIXME: We cannot use fork() on Windows
|
# FIXME: We cannot use fork() on Windows
|
||||||
pid = os.fork()
|
pid = os.fork()
|
||||||
if not pid:
|
if not pid:
|
||||||
# Since we are starting daemon this process will not start a UI
|
# Since we are starting daemon this process will not start a UI
|
||||||
options.ui = False
|
options.ui = False
|
||||||
# Create the daemon object
|
# Create the daemon object
|
||||||
daemon = Daemon()
|
daemon = Daemon()
|
||||||
|
|
||||||
# Start the UI
|
# Start the UI
|
||||||
if options.ui:
|
if options.ui:
|
||||||
log.info("Starting ui..")
|
log.info("Starting ui..")
|
||||||
ui = UI()
|
ui = UI()
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#
|
#
|
||||||
# gtkui.py
|
# gtkui.py
|
||||||
#
|
#
|
||||||
# Copyright (C) Andrew Resch 2007 <andrewresch@gmail.com>
|
# Copyright (C) Andrew Resch 2007 <andrewresch@gmail.com>
|
||||||
#
|
#
|
||||||
# Deluge is free software.
|
# Deluge is free software.
|
||||||
#
|
#
|
||||||
@ -16,20 +16,20 @@
|
|||||||
# See the GNU General Public License for more details.
|
# See the GNU General Public License for more details.
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with deluge. If not, write to:
|
# along with deluge. If not, write to:
|
||||||
# The Free Software Foundation, Inc.,
|
# The Free Software Foundation, Inc.,
|
||||||
# 51 Franklin Street, Fifth Floor
|
# 51 Franklin Street, Fifth Floor
|
||||||
# Boston, MA 02110-1301, USA.
|
# Boston, MA 02110-1301, USA.
|
||||||
#
|
#
|
||||||
# In addition, as a special exception, the copyright holders give
|
# In addition, as a special exception, the copyright holders give
|
||||||
# permission to link the code of portions of this program with the OpenSSL
|
# permission to link the code of portions of this program with the OpenSSL
|
||||||
# library.
|
# library.
|
||||||
# You must obey the GNU General Public License in all respects for all of
|
# You must obey the GNU General Public License in all respects for all of
|
||||||
# the code used other than OpenSSL. If you modify file(s) with this
|
# the code used other than OpenSSL. If you modify file(s) with this
|
||||||
# exception, you may extend this exception to your version of the file(s),
|
# exception, you may extend this exception to your version of the file(s),
|
||||||
# but you are not obligated to do so. If you do not wish to do so, delete
|
# 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
|
# this exception statement from your version. If you delete this exception
|
||||||
# statement from all source files in the program, then also delete it here.
|
# statement from all source files in the program, then also delete it here.
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
@ -43,15 +43,15 @@ from mainwindow import MainWindow
|
|||||||
log = logging.getLogger("deluge")
|
log = logging.getLogger("deluge")
|
||||||
|
|
||||||
class GtkUI:
|
class GtkUI:
|
||||||
def __init__(self, core):
|
def __init__(self, core):
|
||||||
# Get the core proxy object from the args
|
# Get the core proxy object from the args
|
||||||
self.core = core
|
self.core = core
|
||||||
|
|
||||||
# Initialize the main window
|
# Initialize the main window
|
||||||
self.main_window = MainWindow(self.core)
|
self.main_window = MainWindow(self.core)
|
||||||
|
|
||||||
# Show the main window
|
# Show the main window
|
||||||
self.main_window.show()
|
self.main_window.show()
|
||||||
|
|
||||||
# Start the gtk main loop
|
# Start the gtk main loop
|
||||||
gtk.main()
|
gtk.main()
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#
|
#
|
||||||
# gtkui_mainwindow.py
|
# gtkui_mainwindow.py
|
||||||
#
|
#
|
||||||
# Copyright (C) Andrew Resch 2007 <andrewresch@gmail.com>
|
# Copyright (C) Andrew Resch 2007 <andrewresch@gmail.com>
|
||||||
#
|
#
|
||||||
# Deluge is free software.
|
# Deluge is free software.
|
||||||
#
|
#
|
||||||
@ -16,20 +16,20 @@
|
|||||||
# See the GNU General Public License for more details.
|
# See the GNU General Public License for more details.
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with deluge. If not, write to:
|
# along with deluge. If not, write to:
|
||||||
# The Free Software Foundation, Inc.,
|
# The Free Software Foundation, Inc.,
|
||||||
# 51 Franklin Street, Fifth Floor
|
# 51 Franklin Street, Fifth Floor
|
||||||
# Boston, MA 02110-1301, USA.
|
# Boston, MA 02110-1301, USA.
|
||||||
#
|
#
|
||||||
# In addition, as a special exception, the copyright holders give
|
# In addition, as a special exception, the copyright holders give
|
||||||
# permission to link the code of portions of this program with the OpenSSL
|
# permission to link the code of portions of this program with the OpenSSL
|
||||||
# library.
|
# library.
|
||||||
# You must obey the GNU General Public License in all respects for all of
|
# You must obey the GNU General Public License in all respects for all of
|
||||||
# the code used other than OpenSSL. If you modify file(s) with this
|
# the code used other than OpenSSL. If you modify file(s) with this
|
||||||
# exception, you may extend this exception to your version of the file(s),
|
# exception, you may extend this exception to your version of the file(s),
|
||||||
# but you are not obligated to do so. If you do not wish to do so, delete
|
# 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
|
# this exception statement from your version. If you delete this exception
|
||||||
# statement from all source files in the program, then also delete it here.
|
# statement from all source files in the program, then also delete it here.
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
@ -42,126 +42,129 @@ import pkg_resources
|
|||||||
log = logging.getLogger("deluge")
|
log = logging.getLogger("deluge")
|
||||||
|
|
||||||
class MainWindow:
|
class MainWindow:
|
||||||
def __init__(self, core):
|
def __init__(self, core):
|
||||||
self.core = core
|
self.core = core
|
||||||
|
|
||||||
# Get the glade file for the main window
|
# Get the glade file for the main window
|
||||||
self.main_glade = gtk.glade.XML(
|
self.main_glade = gtk.glade.XML(
|
||||||
pkg_resources.resource_filename("deluge.ui.gtkui",
|
pkg_resources.resource_filename("deluge.ui.gtkui",
|
||||||
"glade/main_window.glade"))
|
"glade/main_window.glade"))
|
||||||
|
|
||||||
self.window = self.main_glade.get_widget("main_window")
|
self.window = self.main_glade.get_widget("main_window")
|
||||||
|
|
||||||
# Initialize various components of the gtkui
|
# Initialize various components of the gtkui
|
||||||
self.menubar = MainWindowMenuBar(self)
|
self.menubar = MainWindowMenuBar(self)
|
||||||
|
|
||||||
def show(self):
|
def show(self):
|
||||||
self.window.show_all()
|
self.window.show_all()
|
||||||
|
|
||||||
def hide(self):
|
def hide(self):
|
||||||
self.window.hide()
|
self.window.hide()
|
||||||
|
|
||||||
def quit(self):
|
def quit(self):
|
||||||
self.hide()
|
self.hide()
|
||||||
gtk.main_quit()
|
gtk.main_quit()
|
||||||
|
|
||||||
class MainWindowMenuBar:
|
class MainWindowMenuBar:
|
||||||
def __init__(self, mainwindow):
|
def __init__(self, mainwindow):
|
||||||
log.debug("MainWindowMenuBar init..")
|
log.debug("MainWindowMenuBar init..")
|
||||||
self.mainwindow = mainwindow
|
self.mainwindow = mainwindow
|
||||||
self.torrentmenu = gtk.glade.XML(
|
self.torrentmenu = gtk.glade.XML(
|
||||||
pkg_resources.resource_filename("deluge.ui.gtkui",
|
pkg_resources.resource_filename("deluge.ui.gtkui",
|
||||||
"glade/torrent_menu.glade"))
|
"glade/torrent_menu.glade"))
|
||||||
|
|
||||||
# Attach the torrent_menu to the Torrent file menu
|
# Attach the torrent_menu to the Torrent file menu
|
||||||
self.mainwindow.main_glade.get_widget("menu_torrent").set_submenu(
|
self.mainwindow.main_glade.get_widget("menu_torrent").set_submenu(
|
||||||
self.torrentmenu.get_widget("torrent_menu"))
|
self.torrentmenu.get_widget("torrent_menu"))
|
||||||
|
|
||||||
### Connect Signals ###
|
### Connect Signals ###
|
||||||
self.mainwindow.main_glade.signal_autoconnect({
|
self.mainwindow.main_glade.signal_autoconnect({
|
||||||
## File Menu
|
## File Menu
|
||||||
"on_menuitem_addtorrent_activate": self.on_menuitem_addtorrent_activate,
|
"on_menuitem_addtorrent_activate": \
|
||||||
"on_menuitem_addurl_activate": self.on_menuitem_addurl_activate,
|
self.on_menuitem_addtorrent_activate,
|
||||||
"on_menuitem_clear_activate": \
|
"on_menuitem_addurl_activate": self.on_menuitem_addurl_activate,
|
||||||
self.on_menuitem_clear_activate,
|
"on_menuitem_clear_activate": \
|
||||||
"on_menuitem_quit_activate": self.on_menuitem_quit_activate,
|
self.on_menuitem_clear_activate,
|
||||||
|
"on_menuitem_quit_activate": self.on_menuitem_quit_activate,
|
||||||
|
|
||||||
## Edit Menu
|
## Edit Menu
|
||||||
"on_menuitem_preferences_activate": \
|
"on_menuitem_preferences_activate": \
|
||||||
self.on_menuitem_preferences_activate,
|
self.on_menuitem_preferences_activate,
|
||||||
"on_menuitem_plugins_activate": self.on_menuitem_plugins_activate,
|
"on_menuitem_plugins_activate": self.on_menuitem_plugins_activate,
|
||||||
|
|
||||||
## View Menu
|
## View Menu
|
||||||
"on_menuitem_toolbar_toggled": self.on_menuitem_toolbar_toggled,
|
"on_menuitem_toolbar_toggled": self.on_menuitem_toolbar_toggled,
|
||||||
"on_menuitem_infopane_toggled": self.on_menuitem_infopane_toggled,
|
"on_menuitem_infopane_toggled": self.on_menuitem_infopane_toggled,
|
||||||
|
|
||||||
## Help Menu
|
## Help Menu
|
||||||
"on_menuitem_about_activate": self.on_menuitem_about_activate
|
"on_menuitem_about_activate": self.on_menuitem_about_activate
|
||||||
})
|
})
|
||||||
|
|
||||||
self.torrentmenu.signal_autoconnect({
|
self.torrentmenu.signal_autoconnect({
|
||||||
## Torrent Menu
|
## Torrent Menu
|
||||||
"on_menuitem_pause_activate": self.on_menuitem_pause_activate,
|
"on_menuitem_pause_activate": self.on_menuitem_pause_activate,
|
||||||
"on_menuitem_updatetracker_activate": \
|
"on_menuitem_updatetracker_activate": \
|
||||||
self.on_menuitem_updatetracker_activate,
|
self.on_menuitem_updatetracker_activate,
|
||||||
"on_menuitem_edittrackers_activate": \
|
"on_menuitem_edittrackers_activate": \
|
||||||
self.on_menuitem_edittrackers_activate,
|
self.on_menuitem_edittrackers_activate,
|
||||||
"on_menuitem_remove_activate": self.on_menuitem_remove_activate,
|
"on_menuitem_remove_activate": self.on_menuitem_remove_activate,
|
||||||
"on_menuitem_queuetop_activate": self.on_menuitem_queuetop_activate,
|
"on_menuitem_queuetop_activate": \
|
||||||
"on_menuitem_queueup_activate": self.on_menuitem_queueup_activate,
|
self.on_menuitem_queuetop_activate,
|
||||||
"on_menuitem_queuedown_activate": self.on_menuitem_queuedown_activate,
|
"on_menuitem_queueup_activate": self.on_menuitem_queueup_activate,
|
||||||
"on_menuitem_queuebottom_activate": \
|
"on_menuitem_queuedown_activate": \
|
||||||
|
self.on_menuitem_queuedown_activate,
|
||||||
|
"on_menuitem_queuebottom_activate": \
|
||||||
self.on_menuitem_queuebottom_activate
|
self.on_menuitem_queuebottom_activate
|
||||||
})
|
})
|
||||||
|
|
||||||
### Callbacks ###
|
### Callbacks ###
|
||||||
|
|
||||||
## File Menu ##
|
## File Menu ##
|
||||||
def on_menuitem_addtorrent_activate(self, data=None):
|
def on_menuitem_addtorrent_activate(self, data=None):
|
||||||
log.debug("on_menuitem_addtorrent_activate")
|
log.debug("on_menuitem_addtorrent_activate")
|
||||||
def on_menuitem_addurl_activate(self, data=None):
|
def on_menuitem_addurl_activate(self, data=None):
|
||||||
log.debug("on_menuitem_addurl_activate")
|
log.debug("on_menuitem_addurl_activate")
|
||||||
def on_menuitem_clear_activate(self, data=None):
|
def on_menuitem_clear_activate(self, data=None):
|
||||||
log.debug("on_menuitem_clear_activate")
|
log.debug("on_menuitem_clear_activate")
|
||||||
def on_menuitem_quit_activate(self, data=None):
|
def on_menuitem_quit_activate(self, data=None):
|
||||||
log.debug("on_menuitem_quit_activate")
|
log.debug("on_menuitem_quit_activate")
|
||||||
self.mainwindow.quit()
|
self.mainwindow.quit()
|
||||||
|
|
||||||
## Edit Menu ##
|
## Edit Menu ##
|
||||||
def on_menuitem_preferences_activate(self, data=None):
|
def on_menuitem_preferences_activate(self, data=None):
|
||||||
log.debug("on_menuitem_preferences_activate")
|
log.debug("on_menuitem_preferences_activate")
|
||||||
def on_menuitem_plugins_activate(self, data=None):
|
def on_menuitem_plugins_activate(self, data=None):
|
||||||
log.debug("on_menuitem_plugins_activate")
|
log.debug("on_menuitem_plugins_activate")
|
||||||
|
|
||||||
## Torrent Menu ##
|
## Torrent Menu ##
|
||||||
def on_menuitem_pause_activate(self, data=None):
|
def on_menuitem_pause_activate(self, data=None):
|
||||||
log.debug("on_menuitem_pause_activate")
|
log.debug("on_menuitem_pause_activate")
|
||||||
def on_menuitem_updatetracker_activate(self, data=None):
|
def on_menuitem_updatetracker_activate(self, data=None):
|
||||||
log.debug("on_menuitem_updatetracker_activate")
|
log.debug("on_menuitem_updatetracker_activate")
|
||||||
def on_menuitem_edittrackers_activate(self, data=None):
|
def on_menuitem_edittrackers_activate(self, data=None):
|
||||||
log.debug("on_menuitem_edittrackers_activate")
|
log.debug("on_menuitem_edittrackers_activate")
|
||||||
def on_menuitem_remove_activate(self, data=None):
|
def on_menuitem_remove_activate(self, data=None):
|
||||||
log.debug("on_menuitem_remove_activate")
|
log.debug("on_menuitem_remove_activate")
|
||||||
def on_menuitem_queuetop_activate(self, data=None):
|
def on_menuitem_queuetop_activate(self, data=None):
|
||||||
log.debug("on_menuitem_queuetop_activate")
|
log.debug("on_menuitem_queuetop_activate")
|
||||||
def on_menuitem_queueup_activate(self, data=None):
|
def on_menuitem_queueup_activate(self, data=None):
|
||||||
log.debug("on_menuitem_queueup_activate")
|
log.debug("on_menuitem_queueup_activate")
|
||||||
def on_menuitem_queuedown_activate(self, data=None):
|
def on_menuitem_queuedown_activate(self, data=None):
|
||||||
log.debug("on_menuitem_queuedown_activate")
|
log.debug("on_menuitem_queuedown_activate")
|
||||||
def on_menuitem_queuebottom_activate(self, data=None):
|
def on_menuitem_queuebottom_activate(self, data=None):
|
||||||
log.debug("on_menuitem_queuebottom_activate")
|
log.debug("on_menuitem_queuebottom_activate")
|
||||||
|
|
||||||
## View Menu ##
|
## View Menu ##
|
||||||
def on_menuitem_toolbar_toggled(self, data=None):
|
def on_menuitem_toolbar_toggled(self, data=None):
|
||||||
log.debug("on_menuitem_toolbar_toggled")
|
log.debug("on_menuitem_toolbar_toggled")
|
||||||
def on_menuitem_infopane_toggled(self, data=None):
|
def on_menuitem_infopane_toggled(self, data=None):
|
||||||
log.debug("on_menuitem_infopane_toggled")
|
log.debug("on_menuitem_infopane_toggled")
|
||||||
|
|
||||||
## Help Menu ##
|
## Help Menu ##
|
||||||
def on_menuitem_about_activate(self, data=None):
|
def on_menuitem_about_activate(self, data=None):
|
||||||
log.debug("on_menuitem_about_activate")
|
log.debug("on_menuitem_about_activate")
|
||||||
|
|
||||||
class MainWindowToolBar:
|
class MainWindowToolBar:
|
||||||
def __init__(self, mainwindow):
|
def __init__(self, mainwindow):
|
||||||
self.mainwindow = mainwindow
|
self.mainwindow = mainwindow
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#
|
#
|
||||||
# ui.py
|
# ui.py
|
||||||
#
|
#
|
||||||
# Copyright (C) Andrew Resch 2007 <andrewresch@gmail.com>
|
# Copyright (C) Andrew Resch 2007 <andrewresch@gmail.com>
|
||||||
#
|
#
|
||||||
# Deluge is free software.
|
# Deluge is free software.
|
||||||
#
|
#
|
||||||
@ -16,33 +16,33 @@
|
|||||||
# See the GNU General Public License for more details.
|
# See the GNU General Public License for more details.
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with deluge. If not, write to:
|
# along with deluge. If not, write to:
|
||||||
# The Free Software Foundation, Inc.,
|
# The Free Software Foundation, Inc.,
|
||||||
# 51 Franklin Street, Fifth Floor
|
# 51 Franklin Street, Fifth Floor
|
||||||
# Boston, MA 02110-1301, USA.
|
# Boston, MA 02110-1301, USA.
|
||||||
#
|
#
|
||||||
# In addition, as a special exception, the copyright holders give
|
# In addition, as a special exception, the copyright holders give
|
||||||
# permission to link the code of portions of this program with the OpenSSL
|
# permission to link the code of portions of this program with the OpenSSL
|
||||||
# library.
|
# library.
|
||||||
# You must obey the GNU General Public License in all respects for all of
|
# You must obey the GNU General Public License in all respects for all of
|
||||||
# the code used other than OpenSSL. If you modify file(s) with this
|
# the code used other than OpenSSL. If you modify file(s) with this
|
||||||
# exception, you may extend this exception to your version of the file(s),
|
# exception, you may extend this exception to your version of the file(s),
|
||||||
# but you are not obligated to do so. If you do not wish to do so, delete
|
# 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
|
# this exception statement from your version. If you delete this exception
|
||||||
# statement from all source files in the program, then also delete it here.
|
# statement from all source files in the program, then also delete it here.
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
try:
|
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):
|
||||||
import dbus.glib
|
import dbus.glib
|
||||||
elif dbus_version >= (0,80,0):
|
elif dbus_version >= (0,80,0):
|
||||||
from dbus.mainloop.glib import DBusGMainLoop
|
from dbus.mainloop.glib import DBusGMainLoop
|
||||||
DBusGMainLoop(set_as_default=True)
|
DBusGMainLoop(set_as_default=True)
|
||||||
else:
|
else:
|
||||||
pass
|
pass
|
||||||
except: dbus_imported = False
|
except: dbus_imported = False
|
||||||
else: dbus_imported = True
|
else: dbus_imported = True
|
||||||
|
|
||||||
@ -54,23 +54,23 @@ from deluge.config import Config
|
|||||||
log = logging.getLogger("deluge")
|
log = logging.getLogger("deluge")
|
||||||
|
|
||||||
DEFAULT_PREFS = {
|
DEFAULT_PREFS = {
|
||||||
"selected_ui": "gtk"
|
"selected_ui": "gtk"
|
||||||
}
|
}
|
||||||
|
|
||||||
class UI:
|
class UI:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
log.debug("UI init..")
|
log.debug("UI init..")
|
||||||
self.config = Config("ui.conf", DEFAULT_PREFS)
|
self.config = Config("ui.conf", DEFAULT_PREFS)
|
||||||
log.debug("Getting core proxy object from DBUS..")
|
log.debug("Getting core proxy object from DBUS..")
|
||||||
# Get the proxy object from DBUS
|
# Get the proxy object from DBUS
|
||||||
bus = dbus.SessionBus()
|
bus = dbus.SessionBus()
|
||||||
proxy = bus.get_object("org.deluge_torrent.Deluge",
|
proxy = bus.get_object("org.deluge_torrent.Deluge",
|
||||||
"/org/deluge_torrent/Core")
|
"/org/deluge_torrent/Core")
|
||||||
self.core = dbus.Interface(proxy, "org.deluge_torrent.Deluge")
|
self.core = dbus.Interface(proxy, "org.deluge_torrent.Deluge")
|
||||||
log.debug("Got core proxy object..")
|
log.debug("Got core proxy object..")
|
||||||
|
|
||||||
if self.config["selected_ui"] == "gtk":
|
if self.config["selected_ui"] == "gtk":
|
||||||
log.info("Starting GtkUI..")
|
log.info("Starting GtkUI..")
|
||||||
from deluge.ui.gtkui.gtkui import GtkUI
|
from deluge.ui.gtkui.gtkui import GtkUI
|
||||||
ui = GtkUI(self.core)
|
ui = GtkUI(self.core)
|
||||||
|
|
||||||
|
118
setup.py
118
setup.py
@ -9,24 +9,24 @@
|
|||||||
#
|
#
|
||||||
# This program is distributed in the hope that it will be useful,
|
# This program is distributed in the hope that it will be useful,
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# GNU General Public License for more details.
|
# GNU General Public License for more details.
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program. If not, write to:
|
# along with this program. If not, write to:
|
||||||
# The Free Software Foundation, Inc.,
|
# The Free Software Foundation, Inc.,
|
||||||
# 51 Franklin Street, Fifth Floor
|
# 51 Franklin Street, Fifth Floor
|
||||||
# Boston, MA 02110-1301, USA.
|
# Boston, MA 02110-1301, USA.
|
||||||
#
|
#
|
||||||
# In addition, as a special exception, the copyright holders give
|
# In addition, as a special exception, the copyright holders give
|
||||||
# permission to link the code of portions of this program with the OpenSSL
|
# permission to link the code of portions of this program with the OpenSSL
|
||||||
# library.
|
# library.
|
||||||
# You must obey the GNU General Public License in all respects for all of
|
# You must obey the GNU General Public License in all respects for all of
|
||||||
# the code used other than OpenSSL. If you modify file(s) with this
|
# the code used other than OpenSSL. If you modify file(s) with this
|
||||||
# exception, you may extend this exception to your version of the file(s),
|
# exception, you may extend this exception to your version of the file(s),
|
||||||
# but you are not obligated to do so. If you do not wish to do so, delete
|
# 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
|
# this exception statement from your version. If you delete this exception
|
||||||
# statement from all source files in the program, then also delete it here.
|
# statement from all source files in the program, then also delete it here.
|
||||||
|
|
||||||
import ez_setup
|
import ez_setup
|
||||||
ez_setup.use_setuptools()
|
ez_setup.use_setuptools()
|
||||||
@ -39,48 +39,48 @@ python_version = platform.python_version()[0:3]
|
|||||||
|
|
||||||
# The libtorrent extension
|
# The libtorrent extension
|
||||||
_extra_compile_args = [
|
_extra_compile_args = [
|
||||||
"-Wno-missing-braces",
|
"-Wno-missing-braces",
|
||||||
"-DHAVE_INCLUDE_LIBTORRENT_ASIO____ASIO_HPP=1",
|
"-DHAVE_INCLUDE_LIBTORRENT_ASIO____ASIO_HPP=1",
|
||||||
"-DHAVE_INCLUDE_LIBTORRENT_ASIO_SSL_STREAM_HPP=1",
|
"-DHAVE_INCLUDE_LIBTORRENT_ASIO_SSL_STREAM_HPP=1",
|
||||||
"-DHAVE_INCLUDE_LIBTORRENT_ASIO_IP_TCP_HPP=1",
|
"-DHAVE_INCLUDE_LIBTORRENT_ASIO_IP_TCP_HPP=1",
|
||||||
"-DHAVE_PTHREAD=1",
|
"-DHAVE_PTHREAD=1",
|
||||||
"-DTORRENT_USE_OPENSSL=1",
|
"-DTORRENT_USE_OPENSSL=1",
|
||||||
"-DHAVE_SSL=1"
|
"-DHAVE_SSL=1"
|
||||||
]
|
]
|
||||||
|
|
||||||
_include_dirs = [
|
_include_dirs = [
|
||||||
'./libtorrent',
|
'./libtorrent',
|
||||||
'./libtorrent/include',
|
'./libtorrent/include',
|
||||||
'./libtorrent/include/libtorrent',
|
'./libtorrent/include/libtorrent',
|
||||||
'/usr/include/python' + python_version
|
'/usr/include/python' + python_version
|
||||||
]
|
]
|
||||||
|
|
||||||
_libraries = [
|
_libraries = [
|
||||||
'boost_filesystem',
|
'boost_filesystem',
|
||||||
'boost_date_time',
|
'boost_date_time',
|
||||||
'boost_thread',
|
'boost_thread',
|
||||||
'boost_python',
|
'boost_python',
|
||||||
'z',
|
'z',
|
||||||
'pthread',
|
'pthread',
|
||||||
'ssl'
|
'ssl'
|
||||||
]
|
]
|
||||||
|
|
||||||
_sources = glob.glob("./libtorrent/src/*.cpp") + \
|
_sources = glob.glob("./libtorrent/src/*.cpp") + \
|
||||||
glob.glob("./libtorrent/src/kademlia/*.cpp") + \
|
glob.glob("./libtorrent/src/kademlia/*.cpp") + \
|
||||||
glob.glob("./libtorrent/bindings/python/src/*.cpp")
|
glob.glob("./libtorrent/bindings/python/src/*.cpp")
|
||||||
|
|
||||||
# Remove file_win.cpp as it is only for Windows builds
|
# 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:
|
if "file_win.cpp" in source:
|
||||||
_sources.remove(source)
|
_sources.remove(source)
|
||||||
break
|
break
|
||||||
|
|
||||||
libtorrent = Extension(
|
libtorrent = Extension(
|
||||||
'libtorrent',
|
'libtorrent',
|
||||||
include_dirs = _include_dirs,
|
include_dirs = _include_dirs,
|
||||||
libraries = _libraries,
|
libraries = _libraries,
|
||||||
extra_compile_args = _extra_compile_args,
|
extra_compile_args = _extra_compile_args,
|
||||||
sources = _sources
|
sources = _sources
|
||||||
)
|
)
|
||||||
|
|
||||||
# Main setup
|
# Main setup
|
||||||
@ -89,23 +89,25 @@ _datafiles = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
name = "deluge",
|
name = "deluge",
|
||||||
fullname = "Deluge Bittorent Client",
|
fullname = "Deluge Bittorent Client",
|
||||||
version = "0.6",
|
version = "0.6",
|
||||||
author = "Zach Tibbitts, Alon Zakai, Marcos Pinto, Andrew Resch",
|
author = "Zach Tibbitts, Alon Zakai, Marcos Pinto, Andrew Resch",
|
||||||
author_email = "zach@collegegeek.org, kripkensteiner@gmail.com, \
|
author_email = "zach@collegegeek.org, kripkensteiner@gmail.com, \
|
||||||
marcospinto@dipconsultants.com, andrewresch@gmail.com",
|
marcospinto@dipconsultants.com, \
|
||||||
description = "GTK+ bittorrent client",
|
andrewresch@gmail.com",
|
||||||
url = "http://deluge-torrent.org",
|
description = "GTK+ bittorrent client",
|
||||||
license = "GPLv2",
|
url = "http://deluge-torrent.org",
|
||||||
|
license = "GPLv2",
|
||||||
|
|
||||||
include_package_data = True,
|
include_package_data = True,
|
||||||
package_data = {"deluge": ["ui/gtkui/glade/*.glade", "data/pixmaps/*.png"]},
|
package_data = {"deluge": ["ui/gtkui/glade/*.glade",
|
||||||
ext_package = "deluge",
|
"data/pixmaps/*.png"]},
|
||||||
ext_modules = [libtorrent],
|
ext_package = "deluge",
|
||||||
packages = find_packages(),
|
ext_modules = [libtorrent],
|
||||||
entry_points = """
|
packages = find_packages(),
|
||||||
[console_scripts]
|
entry_points = """
|
||||||
deluge = deluge.main:main
|
[console_scripts]
|
||||||
"""
|
deluge = deluge.main:main
|
||||||
|
"""
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user