Changed from 2 spaces ident to 4

This commit is contained in:
Andrew Resch 2007-07-13 01:34:18 +00:00
parent a7c93458c8
commit 702967a2c6
10 changed files with 508 additions and 501 deletions

View File

@ -1,7 +1,7 @@
#
# common.py
#
# Copyright (C) Andrew Resch 2007 <andrewresch@gmail.com>
# Copyright (C) Andrew Resch 2007 <andrewresch@gmail.com>
#
# Deluge is free software.
#
@ -16,20 +16,20 @@
# See the GNU General Public License for more details.
#
# 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.,
# 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
# permission to link the code of portions of this program with the OpenSSL
# library.
# 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
# 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
# this exception statement from your version. If you delete this exception
# statement from all source files in the program, then also delete it here.
# In addition, as a special exception, the copyright holders give
# permission to link the code of portions of this program with the OpenSSL
# library.
# 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
# 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
# this exception statement from your version. If you delete this exception
# statement from all source files in the program, then also delete it here.
import logging
import pkg_resources
@ -40,18 +40,19 @@ import os
log = logging.getLogger("deluge")
def get_version():
"""Returns the program version from the egg metadata"""
return pkg_resources.require("Deluge")[0].version
"""Returns the program version from the egg metadata"""
return pkg_resources.require("Deluge")[0].version
def get_config_dir(filename=None):
""" Returns the config path if no filename is specified
Returns the config directory + filename as a path if filename is specified
"""
if filename != None:
return os.path.join(xdg.BaseDirectory.save_config_path("deluge"), filename)
else:
return xdg.BaseDirectory.save_config_path("deluge")
""" Returns the config path if no filename is specified
Returns the config directory + filename as a path if filename is specified
"""
if filename != None:
return os.path.join(xdg.BaseDirectory.save_config_path("deluge"),
filename)
else:
return xdg.BaseDirectory.save_config_path("deluge")
def get_default_download_dir():
"""Returns the default download directory"""
return os.environ.get("HOME")
"""Returns the default download directory"""
return os.environ.get("HOME")

View File

@ -1,7 +1,7 @@
#
# config.py
#
# Copyright (C) Andrew Resch 2007 <andrewresch@gmail.com>
# Copyright (C) Andrew Resch 2007 <andrewresch@gmail.com>
#
# Deluge is free software.
#
@ -16,20 +16,20 @@
# See the GNU General Public License for more details.
#
# 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.,
# 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
# permission to link the code of portions of this program with the OpenSSL
# library.
# 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
# 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
# this exception statement from your version. If you delete this exception
# statement from all source files in the program, then also delete it here.
# In addition, as a special exception, the copyright holders give
# permission to link the code of portions of this program with the OpenSSL
# library.
# 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
# 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
# this exception statement from your version. If you delete this exception
# statement from all source files in the program, then also delete it here.
import logging
import pickle
@ -40,65 +40,66 @@ import deluge.common
log = logging.getLogger("deluge")
class Config:
def __init__(self, filename, defaults=None):
log.debug("Config created with filename: %s", filename)
log.debug("Config defaults: %s", defaults)
self.config = {}
# If defaults is not None then we need to use "defaults".
if defaults != None:
self.config = defaults
def __init__(self, filename, defaults=None):
log.debug("Config created with filename: %s", filename)
log.debug("Config defaults: %s", defaults)
self.config = {}
# If defaults is not None then we need to use "defaults".
if defaults != None:
self.config = defaults
# Load the config from file in the config_dir
self.config_file = deluge.common.get_config_dir(filename)
self.load(self.config_file)
def load(self, filename=None):
# Use self.config_file if filename is None
if filename is None:
filename = self.config_file
try:
# Un-pickle the file and update the config dictionary
log.debug("Opening pickled file for load..")
pkl_file = open(filename, "rb")
filedump = pickle.load(pkl_file)
self.config.update(filedump)
pkl_file.close()
except IOError:
log.warning("IOError: Unable to load file '%s'", filename)
except EOFError:
log.debug("Closing pickled file..")
pkl_file.close()
def save(self, filename=None):
# Saves the config dictionary
if filename is None:
filename = self.config_file
try:
log.debug("Opening pickled file for save..")
pkl_file = open(filename, "wb")
pickle.dump(self.config, pkl_file)
log.debug("Closing pickled file..")
pkl_file.close()
except IOError:
log.warning("IOError: Unable to save file '%s'", filename)
def set(self, key, value):
# Sets the "key" with "value" in the config dict
log.debug("Setting '%s' to %s", key, value)
self.config[key] = value
# Load the config from file in the config_dir
self.config_file = deluge.common.get_config_dir(filename)
self.load(self.config_file)
def load(self, filename=None):
# Use self.config_file if filename is None
if filename is None:
filename = self.config_file
try:
# Un-pickle the file and update the config dictionary
log.debug("Opening pickled file for load..")
pkl_file = open(filename, "rb")
filedump = pickle.load(pkl_file)
self.config.update(filedump)
pkl_file.close()
except IOError:
log.warning("IOError: Unable to load file '%s'", filename)
except EOFError:
log.debug("Closing pickled file..")
pkl_file.close()
def save(self, filename=None):
# Saves the config dictionary
if filename is None:
filename = self.config_file
try:
log.debug("Opening pickled file for save..")
pkl_file = open(filename, "wb")
pickle.dump(self.config, pkl_file)
log.debug("Closing pickled file..")
pkl_file.close()
except IOError:
log.warning("IOError: Unable to save file '%s'", filename)
def set(self, key, value):
# Sets the "key" with "value" in the config dict
log.debug("Setting '%s' to %s", key, value)
self.config[key] = value
def get(self, key):
# Attempts to get the "key" value and returns None if the key is invalid
try:
value = self.config[key]
log.debug("Getting '%s' as %s", key, value)
return value
except KeyError:
log.warning("Key does not exist, returning None")
return
def get(self, key):
# Attempts to get the "key" value and returns None if the key is
# invalid
try:
value = self.config[key]
log.debug("Getting '%s' as %s", key, value)
return value
except KeyError:
log.warning("Key does not exist, returning None")
return
def __getitem__(self, key):
return self.config[key]
def __getitem__(self, key):
return self.config[key]
def __setitem__(self, key, value):
self.config[key] = value
def __setitem__(self, key, value):
self.config[key] = value

View File

@ -1,7 +1,7 @@
#
# core.py
#
# Copyright (C) Andrew Resch 2007 <andrewresch@gmail.com>
# Copyright (C) Andrew Resch 2007 <andrewresch@gmail.com>
#
# Deluge is free software.
#
@ -16,20 +16,20 @@
# See the GNU General Public License for more details.
#
# 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.,
# 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
# permission to link the code of portions of this program with the OpenSSL
# library.
# 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
# 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
# this exception statement from your version. If you delete this exception
# statement from all source files in the program, then also delete it here.
# In addition, as a special exception, the copyright holders give
# permission to link the code of portions of this program with the OpenSSL
# library.
# 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
# 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
# this exception statement from your version. If you delete this exception
# statement from all source files in the program, then also delete it here.
import logging
@ -58,65 +58,65 @@ log = logging.getLogger("deluge")
#_default_download_dir = deluge.common.get_default_download_dir()
DEFAULT_PREFS = {
"listen_ports": [6881, 6891],
"download_location": deluge.common.get_default_download_dir(),
"compact_allocation": True
"listen_ports": [6881, 6891],
"download_location": deluge.common.get_default_download_dir(),
"compact_allocation": True
}
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)
# Setup the libtorrent session and listen on the configured ports
log.debug("Starting libtorrent session..")
self.session = lt.session()
log.debug("Listening on %i-%i", self.config.get("listen_ports")[0],
self.config.get("listen_ports")[1])
self.session.listen_on(self.config.get("listen_ports")[0],
self.config.get("listen_ports")[1])
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)
# Setup the libtorrent session and listen on the configured ports
log.debug("Starting libtorrent session..")
self.session = lt.session()
log.debug("Listening on %i-%i", self.config.get("listen_ports")[0],
self.config.get("listen_ports")[1])
self.session.listen_on(self.config.get("listen_ports")[0],
self.config.get("listen_ports")[1])
log.debug("Starting main loop..")
self.loop = gobject.MainLoop()
self.loop.run()
log.debug("Starting main loop..")
self.loop = gobject.MainLoop()
self.loop.run()
# Exported Methods
@dbus.service.method(dbus_interface="org.deluge_torrent.Deluge",
in_signature="s", out_signature="")
def add_torrent_file(self, _filename):
"""Adds a torrent file to the libtorrent session
"""
log.info("Adding torrent: %s", _filename)
torrent = Torrent(filename=_filename)
self.session.add_torrent(torrent.torrent_info,
self.config["download_location"],
self.config["compact_allocation"])
# Emit the torrent_added signal
self.torrent_added()
# Exported Methods
@dbus.service.method(dbus_interface="org.deluge_torrent.Deluge",
in_signature="s", out_signature="")
def add_torrent_file(self, _filename):
"""Adds a torrent file to the libtorrent session
"""
log.info("Adding torrent: %s", _filename)
torrent = Torrent(filename=_filename)
self.session.add_torrent(torrent.torrent_info,
self.config["download_location"],
self.config["compact_allocation"])
# Emit the torrent_added signal
self.torrent_added()
@dbus.service.method(dbus_interface="org.deluge_torrent.Deluge",
in_signature="s", out_signature="")
def add_torrent_url(self, _url):
"""Adds a torrent from url to the libtorrent session
"""
log.info("Adding torrent: %s", _url)
torrent = Torrent(url=_url)
self.session.add_torrent(torrent.torrent_info,
self.config["download_location"],
self.config["compact_allocation"])
@dbus.service.method(dbus_interface="org.deluge_torrent.Deluge",
in_signature="s", out_signature="")
def add_torrent_url(self, _url):
"""Adds a torrent from url to the libtorrent session
"""
log.info("Adding torrent: %s", _url)
torrent = Torrent(url=_url)
self.session.add_torrent(torrent.torrent_info,
self.config["download_location"],
self.config["compact_allocation"])
@dbus.service.method("org.deluge_torrent.Deluge")
def shutdown(self):
log.info("Shutting down core..")
self.loop.quit()
# Signals
@dbus.service.signal(dbus_interface="org.deluge_torrent.Deluge",
signature="")
def torrent_added(self):
"""Emitted when a new torrent is added to the core"""
pass
@dbus.service.method("org.deluge_torrent.Deluge")
def shutdown(self):
log.info("Shutting down core..")
self.loop.quit()
# Signals
@dbus.service.signal(dbus_interface="org.deluge_torrent.Deluge",
signature="")
def torrent_added(self):
"""Emitted when a new torrent is added to the core"""
pass

View File

@ -1,7 +1,7 @@
#
# daemon.py
#
# Copyright (C) Andrew Resch 2007 <andrewresch@gmail.com>
# Copyright (C) Andrew Resch 2007 <andrewresch@gmail.com>
#
# Deluge is free software.
#
@ -16,30 +16,30 @@
# See the GNU General Public License for more details.
#
# 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.,
# 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
# permission to link the code of portions of this program with the OpenSSL
# library.
# 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
# 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
# this exception statement from your version. If you delete this exception
# statement from all source files in the program, then also delete it here.
# In addition, as a special exception, the copyright holders give
# permission to link the code of portions of this program with the OpenSSL
# library.
# 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
# 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
# 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
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
@ -51,16 +51,16 @@ from deluge.core.core import Core
log = logging.getLogger("deluge")
class Daemon:
def __init__(self):
# 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()
def __init__(self):
# 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()

View File

@ -1,7 +1,7 @@
#
# torrent.py
#
# Copyright (C) Andrew Resch 2007 <andrewresch@gmail.com>
# Copyright (C) Andrew Resch 2007 <andrewresch@gmail.com>
#
# Deluge is free software.
#
@ -16,27 +16,27 @@
# See the GNU General Public License for more details.
#
# 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.,
# 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
# permission to link the code of portions of this program with the OpenSSL
# library.
# 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
# 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
# this exception statement from your version. If you delete this exception
# statement from all source files in the program, then also delete it here.
# In addition, as a special exception, the copyright holders give
# permission to link the code of portions of this program with the OpenSSL
# library.
# 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
# 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
# this exception statement from your version. If you delete this exception
# statement from all source files in the program, then also delete it here.
import deluge.libtorrent as lt
class Torrent:
def __init__(self, filename=None, url=None):
# Load the torrent file
if filename is not None:
torrent_file = lt.bdecode(open(filename, 'rb').read())
self.torrent_info = lt.torrent_info(torrent_file)
def __init__(self, filename=None, url=None):
# Load the torrent file
if filename is not None:
torrent_file = lt.bdecode(open(filename, 'rb').read())
self.torrent_info = lt.torrent_info(torrent_file)

View File

@ -1,7 +1,7 @@
#
# main.py
#
# Copyright (C) Andrew Resch 2007 <andrewresch@gmail.com>
# Copyright (C) Andrew Resch 2007 <andrewresch@gmail.com>
#
# Deluge is free software.
#
@ -16,22 +16,22 @@
# See the GNU General Public License for more details.
#
# 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.,
# 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
# permission to link the code of portions of this program with the OpenSSL
# library.
# 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
# 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
# this exception statement from your version. If you delete this exception
# statement from all source files in the program, then also delete it here.
# In addition, as a special exception, the copyright holders give
# permission to link the code of portions of this program with the OpenSSL
# library.
# 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
# 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
# this exception statement from your version. If you delete this exception
# 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'.
import logging
@ -45,47 +45,47 @@ import deluge.common
# Setup the logger
logging.basicConfig(
level=logging.DEBUG,
format="[%(levelname)-8s] %(name)s:%(module)s:%(lineno)d %(message)s"
level=logging.DEBUG,
format="[%(levelname)-8s] %(name)s:%(module)s:%(lineno)d %(message)s"
)
# Get the logger for deluge
log = logging.getLogger("deluge")
def main():
# Setup the argument parser
# FIXME: need to use deluge.common to fill in version
parser = OptionParser(usage="%prog [options] [actions]",
version=deluge.common.get_version())
parser.add_option("--daemon", dest="daemon", help="Start Deluge daemon",
metavar="DAEMON", action="store_true", default=False)
parser.add_option("--ui", dest="ui", help="Start Deluge UI",
metavar="UI", action="store_true", default=False)
# Setup the argument parser
# FIXME: need to use deluge.common to fill in version
parser = OptionParser(usage="%prog [options] [actions]",
version=deluge.common.get_version())
parser.add_option("--daemon", dest="daemon", help="Start Deluge daemon",
metavar="DAEMON", action="store_true", default=False)
parser.add_option("--ui", dest="ui", help="Start Deluge UI",
metavar="UI", action="store_true", default=False)
# Get the options and args from the OptionParser
(options, args) = parser.parse_args()
# Get the options and args from the OptionParser
(options, args) = parser.parse_args()
log.info("Deluge %s", deluge.common.get_version())
log.debug("options: %s", options)
log.debug("args: %s", args)
log.info("Deluge %s", deluge.common.get_version())
daemon = None
pid = None
uri = None
# Start the daemon
if options.daemon:
log.info("Starting daemon..")
# 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:
# Since we are starting daemon this process will not start a UI
options.ui = False
# Create the daemon object
daemon = Daemon()
log.debug("options: %s", options)
log.debug("args: %s", args)
daemon = None
pid = None
uri = None
# Start the daemon
if options.daemon:
log.info("Starting daemon..")
# 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:
# 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()
# Start the UI
if options.ui:
log.info("Starting ui..")
ui = UI()

View File

@ -1,7 +1,7 @@
#
# gtkui.py
#
# Copyright (C) Andrew Resch 2007 <andrewresch@gmail.com>
# Copyright (C) Andrew Resch 2007 <andrewresch@gmail.com>
#
# Deluge is free software.
#
@ -16,20 +16,20 @@
# See the GNU General Public License for more details.
#
# 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.,
# 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
# permission to link the code of portions of this program with the OpenSSL
# library.
# 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
# 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
# this exception statement from your version. If you delete this exception
# statement from all source files in the program, then also delete it here.
# In addition, as a special exception, the copyright holders give
# permission to link the code of portions of this program with the OpenSSL
# library.
# 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
# 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
# this exception statement from your version. If you delete this exception
# statement from all source files in the program, then also delete it here.
import logging
@ -43,15 +43,15 @@ from mainwindow import MainWindow
log = logging.getLogger("deluge")
class GtkUI:
def __init__(self, core):
# Get the core proxy object from the args
self.core = core
# Initialize the main window
self.main_window = MainWindow(self.core)
# Show the main window
self.main_window.show()
# Start the gtk main loop
gtk.main()
def __init__(self, core):
# Get the core proxy object from the args
self.core = core
# Initialize the main window
self.main_window = MainWindow(self.core)
# Show the main window
self.main_window.show()
# Start the gtk main loop
gtk.main()

View File

@ -1,7 +1,7 @@
#
# gtkui_mainwindow.py
#
# Copyright (C) Andrew Resch 2007 <andrewresch@gmail.com>
# Copyright (C) Andrew Resch 2007 <andrewresch@gmail.com>
#
# Deluge is free software.
#
@ -16,20 +16,20 @@
# See the GNU General Public License for more details.
#
# 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.,
# 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
# permission to link the code of portions of this program with the OpenSSL
# library.
# 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
# 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
# this exception statement from your version. If you delete this exception
# statement from all source files in the program, then also delete it here.
# In addition, as a special exception, the copyright holders give
# permission to link the code of portions of this program with the OpenSSL
# library.
# 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
# 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
# this exception statement from your version. If you delete this exception
# statement from all source files in the program, then also delete it here.
import logging
@ -42,126 +42,129 @@ import pkg_resources
log = logging.getLogger("deluge")
class MainWindow:
def __init__(self, core):
self.core = core
# Get the glade file for the main window
self.main_glade = gtk.glade.XML(
pkg_resources.resource_filename("deluge.ui.gtkui",
"glade/main_window.glade"))
def __init__(self, core):
self.core = core
# Get the glade file for the main window
self.main_glade = gtk.glade.XML(
pkg_resources.resource_filename("deluge.ui.gtkui",
"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
self.menubar = MainWindowMenuBar(self)
# Initialize various components of the gtkui
self.menubar = MainWindowMenuBar(self)
def show(self):
self.window.show_all()
def hide(self):
self.window.hide()
def quit(self):
self.hide()
gtk.main_quit()
def show(self):
self.window.show_all()
def hide(self):
self.window.hide()
def quit(self):
self.hide()
gtk.main_quit()
class MainWindowMenuBar:
def __init__(self, mainwindow):
log.debug("MainWindowMenuBar init..")
self.mainwindow = mainwindow
self.torrentmenu = gtk.glade.XML(
pkg_resources.resource_filename("deluge.ui.gtkui",
"glade/torrent_menu.glade"))
def __init__(self, mainwindow):
log.debug("MainWindowMenuBar init..")
self.mainwindow = mainwindow
self.torrentmenu = gtk.glade.XML(
pkg_resources.resource_filename("deluge.ui.gtkui",
"glade/torrent_menu.glade"))
# Attach the torrent_menu to the Torrent file menu
self.mainwindow.main_glade.get_widget("menu_torrent").set_submenu(
self.torrentmenu.get_widget("torrent_menu"))
# Attach the torrent_menu to the Torrent file menu
self.mainwindow.main_glade.get_widget("menu_torrent").set_submenu(
self.torrentmenu.get_widget("torrent_menu"))
### Connect Signals ###
self.mainwindow.main_glade.signal_autoconnect({
## File Menu
"on_menuitem_addtorrent_activate": self.on_menuitem_addtorrent_activate,
"on_menuitem_addurl_activate": self.on_menuitem_addurl_activate,
"on_menuitem_clear_activate": \
self.on_menuitem_clear_activate,
"on_menuitem_quit_activate": self.on_menuitem_quit_activate,
### Connect Signals ###
self.mainwindow.main_glade.signal_autoconnect({
## File Menu
"on_menuitem_addtorrent_activate": \
self.on_menuitem_addtorrent_activate,
"on_menuitem_addurl_activate": self.on_menuitem_addurl_activate,
"on_menuitem_clear_activate": \
self.on_menuitem_clear_activate,
"on_menuitem_quit_activate": self.on_menuitem_quit_activate,
## Edit Menu
"on_menuitem_preferences_activate": \
## Edit Menu
"on_menuitem_preferences_activate": \
self.on_menuitem_preferences_activate,
"on_menuitem_plugins_activate": self.on_menuitem_plugins_activate,
## View Menu
"on_menuitem_toolbar_toggled": self.on_menuitem_toolbar_toggled,
"on_menuitem_infopane_toggled": self.on_menuitem_infopane_toggled,
## Help Menu
"on_menuitem_about_activate": self.on_menuitem_about_activate
})
self.torrentmenu.signal_autoconnect({
## Torrent Menu
"on_menuitem_pause_activate": self.on_menuitem_pause_activate,
"on_menuitem_updatetracker_activate": \
self.on_menuitem_updatetracker_activate,
"on_menuitem_edittrackers_activate": \
self.on_menuitem_edittrackers_activate,
"on_menuitem_remove_activate": self.on_menuitem_remove_activate,
"on_menuitem_queuetop_activate": self.on_menuitem_queuetop_activate,
"on_menuitem_queueup_activate": self.on_menuitem_queueup_activate,
"on_menuitem_queuedown_activate": self.on_menuitem_queuedown_activate,
"on_menuitem_queuebottom_activate": \
"on_menuitem_plugins_activate": self.on_menuitem_plugins_activate,
## View Menu
"on_menuitem_toolbar_toggled": self.on_menuitem_toolbar_toggled,
"on_menuitem_infopane_toggled": self.on_menuitem_infopane_toggled,
## Help Menu
"on_menuitem_about_activate": self.on_menuitem_about_activate
})
self.torrentmenu.signal_autoconnect({
## Torrent Menu
"on_menuitem_pause_activate": self.on_menuitem_pause_activate,
"on_menuitem_updatetracker_activate": \
self.on_menuitem_updatetracker_activate,
"on_menuitem_edittrackers_activate": \
self.on_menuitem_edittrackers_activate,
"on_menuitem_remove_activate": self.on_menuitem_remove_activate,
"on_menuitem_queuetop_activate": \
self.on_menuitem_queuetop_activate,
"on_menuitem_queueup_activate": self.on_menuitem_queueup_activate,
"on_menuitem_queuedown_activate": \
self.on_menuitem_queuedown_activate,
"on_menuitem_queuebottom_activate": \
self.on_menuitem_queuebottom_activate
})
})
### Callbacks ###
### Callbacks ###
## File Menu ##
def on_menuitem_addtorrent_activate(self, data=None):
log.debug("on_menuitem_addtorrent_activate")
def on_menuitem_addurl_activate(self, data=None):
log.debug("on_menuitem_addurl_activate")
def on_menuitem_clear_activate(self, data=None):
log.debug("on_menuitem_clear_activate")
def on_menuitem_quit_activate(self, data=None):
log.debug("on_menuitem_quit_activate")
self.mainwindow.quit()
## Edit Menu ##
def on_menuitem_preferences_activate(self, data=None):
log.debug("on_menuitem_preferences_activate")
def on_menuitem_plugins_activate(self, data=None):
log.debug("on_menuitem_plugins_activate")
## File Menu ##
def on_menuitem_addtorrent_activate(self, data=None):
log.debug("on_menuitem_addtorrent_activate")
def on_menuitem_addurl_activate(self, data=None):
log.debug("on_menuitem_addurl_activate")
def on_menuitem_clear_activate(self, data=None):
log.debug("on_menuitem_clear_activate")
def on_menuitem_quit_activate(self, data=None):
log.debug("on_menuitem_quit_activate")
self.mainwindow.quit()
## Edit Menu ##
def on_menuitem_preferences_activate(self, data=None):
log.debug("on_menuitem_preferences_activate")
def on_menuitem_plugins_activate(self, data=None):
log.debug("on_menuitem_plugins_activate")
## Torrent Menu ##
def on_menuitem_pause_activate(self, data=None):
log.debug("on_menuitem_pause_activate")
def on_menuitem_updatetracker_activate(self, data=None):
log.debug("on_menuitem_updatetracker_activate")
def on_menuitem_edittrackers_activate(self, data=None):
log.debug("on_menuitem_edittrackers_activate")
def on_menuitem_remove_activate(self, data=None):
log.debug("on_menuitem_remove_activate")
def on_menuitem_queuetop_activate(self, data=None):
log.debug("on_menuitem_queuetop_activate")
def on_menuitem_queueup_activate(self, data=None):
log.debug("on_menuitem_queueup_activate")
def on_menuitem_queuedown_activate(self, data=None):
log.debug("on_menuitem_queuedown_activate")
def on_menuitem_queuebottom_activate(self, data=None):
log.debug("on_menuitem_queuebottom_activate")
## Torrent Menu ##
def on_menuitem_pause_activate(self, data=None):
log.debug("on_menuitem_pause_activate")
def on_menuitem_updatetracker_activate(self, data=None):
log.debug("on_menuitem_updatetracker_activate")
def on_menuitem_edittrackers_activate(self, data=None):
log.debug("on_menuitem_edittrackers_activate")
def on_menuitem_remove_activate(self, data=None):
log.debug("on_menuitem_remove_activate")
def on_menuitem_queuetop_activate(self, data=None):
log.debug("on_menuitem_queuetop_activate")
def on_menuitem_queueup_activate(self, data=None):
log.debug("on_menuitem_queueup_activate")
def on_menuitem_queuedown_activate(self, data=None):
log.debug("on_menuitem_queuedown_activate")
def on_menuitem_queuebottom_activate(self, data=None):
log.debug("on_menuitem_queuebottom_activate")
## View Menu ##
def on_menuitem_toolbar_toggled(self, data=None):
log.debug("on_menuitem_toolbar_toggled")
def on_menuitem_infopane_toggled(self, data=None):
log.debug("on_menuitem_infopane_toggled")
## View Menu ##
def on_menuitem_toolbar_toggled(self, data=None):
log.debug("on_menuitem_toolbar_toggled")
def on_menuitem_infopane_toggled(self, data=None):
log.debug("on_menuitem_infopane_toggled")
## Help Menu ##
def on_menuitem_about_activate(self, data=None):
log.debug("on_menuitem_about_activate")
## Help Menu ##
def on_menuitem_about_activate(self, data=None):
log.debug("on_menuitem_about_activate")
class MainWindowToolBar:
def __init__(self, mainwindow):
self.mainwindow = mainwindow
def __init__(self, mainwindow):
self.mainwindow = mainwindow

View File

@ -1,7 +1,7 @@
#
# ui.py
#
# Copyright (C) Andrew Resch 2007 <andrewresch@gmail.com>
# Copyright (C) Andrew Resch 2007 <andrewresch@gmail.com>
#
# Deluge is free software.
#
@ -16,33 +16,33 @@
# See the GNU General Public License for more details.
#
# 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.,
# 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
# permission to link the code of portions of this program with the OpenSSL
# library.
# 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
# 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
# this exception statement from your version. If you delete this exception
# statement from all source files in the program, then also delete it here.
# In addition, as a special exception, the copyright holders give
# permission to link the code of portions of this program with the OpenSSL
# library.
# 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
# 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
# this exception statement from your version. If you delete this exception
# statement from all source files in the program, then also delete it here.
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
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
@ -54,23 +54,23 @@ from deluge.config import Config
log = logging.getLogger("deluge")
DEFAULT_PREFS = {
"selected_ui": "gtk"
"selected_ui": "gtk"
}
class UI:
def __init__(self):
log.debug("UI init..")
self.config = Config("ui.conf", DEFAULT_PREFS)
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..")
if self.config["selected_ui"] == "gtk":
log.info("Starting GtkUI..")
from deluge.ui.gtkui.gtkui import GtkUI
ui = GtkUI(self.core)
def __init__(self):
log.debug("UI init..")
self.config = Config("ui.conf", DEFAULT_PREFS)
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..")
if self.config["selected_ui"] == "gtk":
log.info("Starting GtkUI..")
from deluge.ui.gtkui.gtkui import GtkUI
ui = GtkUI(self.core)

124
setup.py
View File

@ -9,24 +9,24 @@
#
# This program is distributed in the hope that it will be useful,
# 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.
#
# 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.,
# 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
# permission to link the code of portions of this program with the OpenSSL
# library.
# 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
# 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
# this exception statement from your version. If you delete this exception
# statement from all source files in the program, then also delete it here.
# In addition, as a special exception, the copyright holders give
# permission to link the code of portions of this program with the OpenSSL
# library.
# 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
# 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
# this exception statement from your version. If you delete this exception
# statement from all source files in the program, then also delete it here.
import ez_setup
ez_setup.use_setuptools()
@ -39,73 +39,75 @@ python_version = platform.python_version()[0:3]
# The libtorrent extension
_extra_compile_args = [
"-Wno-missing-braces",
"-DHAVE_INCLUDE_LIBTORRENT_ASIO____ASIO_HPP=1",
"-DHAVE_INCLUDE_LIBTORRENT_ASIO_SSL_STREAM_HPP=1",
"-DHAVE_INCLUDE_LIBTORRENT_ASIO_IP_TCP_HPP=1",
"-DHAVE_PTHREAD=1",
"-DTORRENT_USE_OPENSSL=1",
"-DHAVE_SSL=1"
"-Wno-missing-braces",
"-DHAVE_INCLUDE_LIBTORRENT_ASIO____ASIO_HPP=1",
"-DHAVE_INCLUDE_LIBTORRENT_ASIO_SSL_STREAM_HPP=1",
"-DHAVE_INCLUDE_LIBTORRENT_ASIO_IP_TCP_HPP=1",
"-DHAVE_PTHREAD=1",
"-DTORRENT_USE_OPENSSL=1",
"-DHAVE_SSL=1"
]
_include_dirs = [
'./libtorrent',
'./libtorrent/include',
'./libtorrent/include/libtorrent',
'/usr/include/python' + python_version
'./libtorrent',
'./libtorrent/include',
'./libtorrent/include/libtorrent',
'/usr/include/python' + python_version
]
_libraries = [
'boost_filesystem',
'boost_date_time',
'boost_thread',
'boost_python',
'z',
'pthread',
'ssl'
'boost_filesystem',
'boost_date_time',
'boost_thread',
'boost_python',
'z',
'pthread',
'ssl'
]
_sources = glob.glob("./libtorrent/src/*.cpp") + \
glob.glob("./libtorrent/src/kademlia/*.cpp") + \
glob.glob("./libtorrent/bindings/python/src/*.cpp")
glob.glob("./libtorrent/src/kademlia/*.cpp") + \
glob.glob("./libtorrent/bindings/python/src/*.cpp")
# Remove file_win.cpp as it is only for Windows builds
for source in _sources:
if "file_win.cpp" in source:
_sources.remove(source)
break
if "file_win.cpp" in source:
_sources.remove(source)
break
libtorrent = Extension(
'libtorrent',
include_dirs = _include_dirs,
libraries = _libraries,
extra_compile_args = _extra_compile_args,
sources = _sources
'libtorrent',
include_dirs = _include_dirs,
libraries = _libraries,
extra_compile_args = _extra_compile_args,
sources = _sources
)
# Main setup
_datafiles = [
]
setup(
name = "deluge",
fullname = "Deluge Bittorent Client",
version = "0.6",
author = "Zach Tibbitts, Alon Zakai, Marcos Pinto, Andrew Resch",
author_email = "zach@collegegeek.org, kripkensteiner@gmail.com, \
marcospinto@dipconsultants.com, andrewresch@gmail.com",
description = "GTK+ bittorrent client",
url = "http://deluge-torrent.org",
license = "GPLv2",
include_package_data = True,
package_data = {"deluge": ["ui/gtkui/glade/*.glade", "data/pixmaps/*.png"]},
ext_package = "deluge",
ext_modules = [libtorrent],
packages = find_packages(),
entry_points = """
[console_scripts]
deluge = deluge.main:main
"""
name = "deluge",
fullname = "Deluge Bittorent Client",
version = "0.6",
author = "Zach Tibbitts, Alon Zakai, Marcos Pinto, Andrew Resch",
author_email = "zach@collegegeek.org, kripkensteiner@gmail.com, \
marcospinto@dipconsultants.com, \
andrewresch@gmail.com",
description = "GTK+ bittorrent client",
url = "http://deluge-torrent.org",
license = "GPLv2",
include_package_data = True,
package_data = {"deluge": ["ui/gtkui/glade/*.glade",
"data/pixmaps/*.png"]},
ext_package = "deluge",
ext_modules = [libtorrent],
packages = find_packages(),
entry_points = """
[console_scripts]
deluge = deluge.main:main
"""
)