Add a deluge._libtorrent module to handle importing libtorrent

Use the new module
This commit is contained in:
Andrew Resch 2009-07-26 03:26:18 +00:00
parent 100dd1e2a7
commit ba6f30dad1
8 changed files with 62 additions and 43 deletions

52
deluge/_libtorrent.py Normal file
View File

@ -0,0 +1,52 @@
#
# _libtorrent.py
#
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
#
# Deluge is free software.
#
# You may redistribute it and/or modify it under the terms of the
# GNU General Public License, as published by the Free Software
# Foundation; either version 3 of the License, or (at your option)
# any later version.
#
# deluge 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 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:
# The Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor
# 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.
#
#
"""
This module is used to handle the importing of libtorrent.
We use this module to control what versions of libtorrent this version of Deluge
supports.
** Usage **
>>> from deluge._libtorrent import lt
"""
try:
import deluge.libtorrent as lt
except ImportError:
import libtorrent as lt
if not (lt.version_major == 0 and lt.version_minor == 14):
raise ImportError("This version of Deluge requires libtorrent 0.14!")

View File

@ -44,12 +44,7 @@ This should typically only be used by the Core. Plugins should utilize the
from twisted.internet import reactor
import deluge.component as component
try:
import deluge.libtorrent as lt
except ImportError:
import libtorrent as lt
if not (lt.version_major == 0 and lt.version_minor == 14):
raise ImportError("This version of Deluge requires libtorrent 0.14!")
from deluge._libtorrent import lt
from deluge.log import LOG as log

View File

@ -36,12 +36,7 @@
import os
try:
import deluge.libtorrent as lt
except ImportError:
import libtorrent as lt
if not (lt.version_major == 0 and lt.version_minor == 14):
raise ImportError("This version of Deluge requires libtorrent 0.14!")
from deluge._libtorrent import lt
import deluge.component as component
from deluge.configmanager import ConfigManager

View File

@ -1,7 +1,7 @@
#
# core.py
#
# Copyright (C) 2007, 2008 Andrew Resch <andrewresch@gmail.com>
# Copyright (C) 2007-2009 Andrew Resch <andrewresch@gmail.com>
#
# Deluge is free software.
#
@ -33,6 +33,8 @@
#
#
from deluge._libtorrent import lt
import os
import glob
import base64
@ -49,12 +51,7 @@ import twisted.web.client
from deluge.httpdownloader import download_file
from deluge.log import LOG as log
try:
import deluge.libtorrent as lt
except ImportError:
import libtorrent as lt
if not (lt.version_major == 0 and lt.version_minor == 14):
raise ImportError("This version of Deluge requires libtorrent 0.14!")
import deluge.configmanager
import deluge.common

View File

@ -40,12 +40,7 @@ import pickle
import cPickle
import shutil
try:
import deluge.libtorrent as lt
except ImportError:
import libtorrent as lt
if not (lt.version_major == 0 and lt.version_minor == 14):
raise ImportError("This version of Deluge requires libtorrent 0.14!")
from deluge._libtorrent import lt
from deluge.configmanager import ConfigManager
import deluge.core.torrentmanager

View File

@ -40,12 +40,7 @@ import pkg_resources
from twisted.internet import reactor
from twisted.internet.task import LoopingCall
try:
import deluge.libtorrent as lt
except ImportError:
import libtorrent as lt
if not (lt.version_major == 0 and lt.version_minor == 14):
raise ImportError("This version of Deluge requires libtorrent 0.14!")
from deluge._libtorrent import lt
from deluge.event import *
import deluge.configmanager

View File

@ -38,12 +38,7 @@ import os
import time
from urlparse import urlparse
try:
import deluge.libtorrent as lt
except ImportError:
import libtorrent as lt
if not (lt.version_major == 0 and lt.version_minor == 14):
raise ImportError("This version of Deluge requires libtorrent 0.14!")
from deluge._libtorrent import lt
import deluge.common
import deluge.component as component

View File

@ -45,12 +45,7 @@ import operator
from twisted.internet import reactor
from twisted.internet.task import LoopingCall
try:
import deluge.libtorrent as lt
except ImportError:
import libtorrent as lt
if not (lt.version_major == 0 and lt.version_minor == 14):
raise ImportError("This version of Deluge requires libtorrent 0.14!")
from deluge._libtorrent import lt
from deluge.event import *