Author: andar

Revision: 5350

Log:
        Fix some issues with creating torrent files, was putting the announce 
list in the wrong key
Add support for using a system installed GeoIP db file.  It will look for 
/usr/share/GeoIP/GeoIP.dat first and try to load that

Diff:
Modified: trunk/deluge/core/alertmanager.py
===================================================================
--- trunk/deluge/core/alertmanager.py   2009-06-04 16:20:28 UTC (rev 5349)
+++ trunk/deluge/core/alertmanager.py   2009-06-04 16:57:53 UTC (rev 5350)
@@ -65,7 +65,7 @@
             lt.alert.category_t.storage_notification |
             lt.alert.category_t.tracker_notification |
             lt.alert.category_t.status_notification |
-            lt.alert.category_t.ip_block_notification|
+            lt.alert.category_t.ip_block_notification |
             lt.alert.category_t.performance_warning)
 
         # handlers is a dictionary of lists {"alert_type": [handler1,h2,..]}

Modified: trunk/deluge/core/core.py
===================================================================
--- trunk/deluge/core/core.py   2009-06-04 16:20:28 UTC (rev 5349)
+++ trunk/deluge/core/core.py   2009-06-04 16:57:53 UTC (rev 5350)
@@ -95,16 +95,6 @@
         # Load the session state if available
         self.__load_session_state()
 
-        # Load the GeoIP DB for country look-ups if available
-        geoip_db = pkg_resources.resource_filename("deluge", 
os.path.join("data", "GeoIP.dat"))
-        if os.path.exists(geoip_db):
-            try:
-                self.session.load_country_db(geoip_db)
-            except Exception, e:
-                log.error("Unable to load geoip database!")
-                log.exception(e)
-
-
         # Set the user agent
         self.settings = lt.session_settings()
         self.settings.user_agent = "Deluge %s" % deluge.common.get_version()
@@ -141,6 +131,22 @@
         # Get the core config
         self.config = deluge.configmanager.ConfigManager("core.conf")
 
+        # Load the GeoIP DB for country look-ups if available
+        geoip_db = ""
+        if os.path.exists(self.config["geoip_db_location"]):
+            geoip_db = self.config["geoip_db_location"]
+        elif os.path.exists(pkg_resources.resource_filename("deluge", 
os.path.join("data", "GeoIP.dat"))):
+            geoip_db = pkg_resources.resource_filename("deluge", 
os.path.join("data", "GeoIP.dat"))
+        else:
+            log.warning("Unable to find GeoIP database file!")
+
+        if geoip_db:
+            try:
+                self.session.load_country_db(geoip_db)
+            except Exception, e:
+                log.error("Unable to load geoip database!")
+                log.exception(e)
+
         # If there was an interface value from the command line, use it, but
         # store the one in the config so we can restore it on shutdown
         self.__old_interface = None
@@ -626,7 +632,7 @@
 
     @export
     def create_torrent(self, path, tracker, piece_length, comment, target,
-                        url_list, private, created_by, httpseeds, 
add_to_session):
+                        url_list, private, created_by, httpseeds, trackers, 
add_to_session):
 
         log.debug("creating torrent..")
         threading.Thread(target=_create_torrent_thread,
@@ -640,10 +646,11 @@
                 private,
                 created_by,
                 httpseeds,
+                trackers,
                 add_to_session)).start()
 
     def _create_torrent_thread(self, path, tracker, piece_length, comment, 
target,
-                    url_list, private, created_by, httpseeds, add_to_session):
+                    url_list, private, created_by, httpseeds, trackers, 
add_to_session):
         import deluge.metafile
         deluge.metafile.make_meta_file(
             path,
@@ -654,7 +661,8 @@
             url_list=url_list,
             private=private,
             created_by=created_by,
-            httpseeds=httpseeds)
+            httpseeds=httpseeds,
+            trackers=trackers)
         log.debug("torrent created!")
         if add_to_session:
             self.add_torrent_file(os.path.split(target)[1], open(target, 
"rb").read(), None)

Modified: trunk/deluge/core/preferencesmanager.py
===================================================================
--- trunk/deluge/core/preferencesmanager.py     2009-06-04 16:20:28 UTC (rev 
5349)
+++ trunk/deluge/core/preferencesmanager.py     2009-06-04 16:57:53 UTC (rev 
5350)
@@ -142,7 +142,8 @@
     "outgoing_ports": [0, 0],
     "random_outgoing_ports": True,
     "peer_tos": "0x00",
-    "rate_limit_ip_overhead": True
+    "rate_limit_ip_overhead": True,
+    "geoip_db_location": "/usr/share/GeoIP/GeoIP.dat"
 }
 
 class PreferencesManager(component.Component):

Modified: trunk/deluge/metafile.py
===================================================================
--- trunk/deluge/metafile.py    2009-06-04 16:20:28 UTC (rev 5349)
+++ trunk/deluge/metafile.py    2009-06-04 16:57:53 UTC (rev 5350)
@@ -58,7 +58,7 @@
 def make_meta_file(path, url, piece_length, progress=dummy,
                    title=None, comment=None, safe=None, content_type=None,
                    target=None, url_list=None, name=None, private=False,
-                   created_by=None, httpseeds=None):
+                   created_by=None, httpseeds=None, trackers=None):
     data = {'creation date': int(gmtime())}
     if url:
         data['announce'] = url.strip()
@@ -88,6 +88,8 @@
         data['created by'] = created_by
     if httpseeds:
         data['httpseeds'] = httpseeds
+    if trackers:
+        data['announce-list'] = trackers
 
     h.write(bencode(data))
     h.close()

Modified: trunk/deluge/ui/gtkui/createtorrentdialog.py
===================================================================
--- trunk/deluge/ui/gtkui/createtorrentdialog.py        2009-06-04 16:20:28 UTC 
(rev 5349)
+++ trunk/deluge/ui/gtkui/createtorrentdialog.py        2009-06-04 16:57:53 UTC 
(rev 5350)
@@ -288,10 +288,11 @@
                 piece_length,
                 comment,
                 result,
-                trackers,
+                None,
                 private,
                 author,
                 webseeds,
+                trackers,
                 add_to_session)
 
         else:
@@ -312,13 +313,14 @@
                     private,
                     author,
                     webseeds,
+                    trackers,
                     add_to_session)).start()
 
         chooser.destroy()
         self.dialog.destroy()
 
     def create_torrent(self, path, tracker, piece_length, progress, comment, 
target,
-                        url_list, private, created_by, httpseeds, 
add_to_session):
+                        url_list, private, created_by, httpseeds, trackers, 
add_to_session):
         import deluge.metafile
         deluge.metafile.make_meta_file(
             path,
@@ -330,7 +332,8 @@
             url_list=url_list,
             private=private,
             created_by=created_by,
-            httpseeds=httpseeds)
+            httpseeds=httpseeds,
+            trackers=trackers)
         self.glade.get_widget("progress_dialog").hide_all()
         if add_to_session:
             client.core.add_torrent_file(



--~--~---------~--~----~------------~-------~--~----~
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