Author: andar

Revision: 5554

Log:
        Add a deluge._libtorrent module to handle importing libtorrent
Use the new module

Diff:
Added: trunk/deluge/_libtorrent.py
===================================================================
--- trunk/deluge/_libtorrent.py                         (rev 0)
+++ trunk/deluge/_libtorrent.py 2009-07-26 03:26:18 UTC (rev 5554)
@@ -0,0 +1,52 @@
+#
+# _libtorrent.py
+#
+# Copyright (C) 2009 Andrew Resch <[email protected]>
+#
+# 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!")

Modified: trunk/deluge/core/alertmanager.py
===================================================================
--- trunk/deluge/core/alertmanager.py   2009-07-25 04:05:00 UTC (rev 5553)
+++ trunk/deluge/core/alertmanager.py   2009-07-26 03:26:18 UTC (rev 5554)
@@ -44,12 +44,7 @@
 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
 

Modified: trunk/deluge/core/autoadd.py
===================================================================
--- trunk/deluge/core/autoadd.py        2009-07-25 04:05:00 UTC (rev 5553)
+++ trunk/deluge/core/autoadd.py        2009-07-26 03:26:18 UTC (rev 5554)
@@ -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

Modified: trunk/deluge/core/core.py
===================================================================
--- trunk/deluge/core/core.py   2009-07-25 04:05:00 UTC (rev 5553)
+++ trunk/deluge/core/core.py   2009-07-26 03:26:18 UTC (rev 5554)
@@ -1,7 +1,7 @@
 #
 # core.py
 #
-# Copyright (C) 2007, 2008 Andrew Resch <[email protected]>
+# Copyright (C) 2007-2009 Andrew Resch <[email protected]>
 #
 # Deluge is free software.
 #
@@ -33,6 +33,8 @@
 #
 #
 
+from deluge._libtorrent import lt
+
 import os
 import glob
 import base64
@@ -49,13 +51,8 @@
 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
 import deluge.component as component

Modified: trunk/deluge/core/oldstateupgrader.py
===================================================================
--- trunk/deluge/core/oldstateupgrader.py       2009-07-25 04:05:00 UTC (rev 
5553)
+++ trunk/deluge/core/oldstateupgrader.py       2009-07-26 03:26:18 UTC (rev 
5554)
@@ -40,12 +40,7 @@
 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

Modified: trunk/deluge/core/preferencesmanager.py
===================================================================
--- trunk/deluge/core/preferencesmanager.py     2009-07-25 04:05:00 UTC (rev 
5553)
+++ trunk/deluge/core/preferencesmanager.py     2009-07-26 03:26:18 UTC (rev 
5554)
@@ -40,12 +40,7 @@
 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

Modified: trunk/deluge/core/torrent.py
===================================================================
--- trunk/deluge/core/torrent.py        2009-07-25 04:05:00 UTC (rev 5553)
+++ trunk/deluge/core/torrent.py        2009-07-26 03:26:18 UTC (rev 5554)
@@ -38,12 +38,7 @@
 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

Modified: trunk/deluge/core/torrentmanager.py
===================================================================
--- trunk/deluge/core/torrentmanager.py 2009-07-25 04:05:00 UTC (rev 5553)
+++ trunk/deluge/core/torrentmanager.py 2009-07-26 03:26:18 UTC (rev 5554)
@@ -45,12 +45,7 @@
 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 *



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"deluge-commit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/deluge-commit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to