diff --git a/deluge/core/core.py b/deluge/core/core.py index 7c67ab057..f949fbce4 100644 --- a/deluge/core/core.py +++ b/deluge/core/core.py @@ -59,6 +59,8 @@ from deluge.log import LOG as log DEFAULT_PREFS = { "config_location": deluge.configmanager.get_config_dir(), + "send_info": False, + "info_sent": 0.0, "daemon_port": 58846, "allow_remote": False, "compact_allocation": False, @@ -181,6 +183,40 @@ class Core( return result SetConsoleCtrlHandler(win_handler) + def send_info(self): + """sends anonymous stats home""" + class Send_Info_Thread(threading.Thread): + def __init__(self, config): + self.config = config + threading.Thread.__init__(self) + def run(self): + import time + now = time.time() + # check if we've done this within the last week or never + if (now - self.config["info_sent"]) >= (60 * 60 * 24 * 7): + import deluge.common + import urllib + import platform + #this is so gtk isnt required in core + try: + import gtk + except ImportError: + pygtk = None + else: + pygtk = '%i.%i.%i' %(gtk.pygtk_version[0], gtk.pygtk_version[1], gtk.pygtk_version[2]) + + try: + url = "http://deluge-torrent.org/stats_get.php?processor=" + \ + platform.machine() + "&python=" + platform.python_version() \ + + "&os=" + platform.system() + "&plugins=" + urllib.quote_plus(self.config["enabled_plugins"]) \ + + "&deluge=" + deluge.common.get_version() + urllib.urlopen(url) + except IOError: + print "Network error while trying to send info" + else: + self.config["info_sent"] = now + Send_Info_Thread(self.config).start() + def get_request(self): """Get the request and client address from the socket. We override this so that we can get the ip address of the client. @@ -268,6 +304,10 @@ class Core( # Load plugins self.plugins = PluginManager(self) + # send stats info + if self.config["send_info"]: + self.send_info() + # Start the TorrentManager self.torrents = TorrentManager(self.session, self.alerts) diff --git a/deluge/ui/gtkui/gtkui.py b/deluge/ui/gtkui/gtkui.py index f95553619..e35aad31f 100644 --- a/deluge/ui/gtkui/gtkui.py +++ b/deluge/ui/gtkui/gtkui.py @@ -78,7 +78,6 @@ DEFAULT_PREFS = { "lock_tray": False, "tray_password": "", "check_new_releases": False, - "send_info": False, "default_load_path": None, "window_maximized": False, "window_x_pos": 0, diff --git a/deluge/ui/gtkui/preferences.py b/deluge/ui/gtkui/preferences.py index be2274db7..41e38e15c 100644 --- a/deluge/ui/gtkui/preferences.py +++ b/deluge/ui/gtkui/preferences.py @@ -217,6 +217,7 @@ class Preferences(component.Component): "chk_natpmp": ("active", self.core_config["natpmp"]), "chk_utpex": ("active", self.core_config["utpex"]), "chk_lsd": ("active", self.core_config["lsd"]), + "chk_send_info": ("active", self.core_config["send_info"]), "combo_encin": ("active", self.core_config["enc_in_policy"]), "combo_encout": ("active", self.core_config["enc_out_policy"]), "combo_enclevel": ("active", self.core_config["enc_level"]), @@ -331,6 +332,7 @@ class Preferences(component.Component): "chk_natpmp", "chk_utpex", "chk_lsd", + "chk_send_info", "combo_encin", "combo_encout", "combo_enclevel", @@ -386,7 +388,7 @@ class Preferences(component.Component): self.gtkui_config["check_new_releases"]) self.glade.get_widget("chk_send_info").set_active( - self.gtkui_config["send_info"]) + self.core_config["send_info"]) ## Plugins tab ## all_plugins = self.all_plugins @@ -520,7 +522,7 @@ class Preferences(component.Component): new_gtkui_config["check_new_releases"] = \ self.glade.get_widget("chk_new_releases").get_active() - new_gtkui_config["send_info"] = \ + new_core_config["send_info"] = \ self.glade.get_widget("chk_send_info").get_active() ## Daemon tab ##