add send stats info

This commit is contained in:
Marcos Pinto 2008-06-22 21:15:05 +00:00
commit dd18152266
3 changed files with 44 additions and 3 deletions

View file

@ -59,6 +59,8 @@ from deluge.log import LOG as log
DEFAULT_PREFS = { DEFAULT_PREFS = {
"config_location": deluge.configmanager.get_config_dir(), "config_location": deluge.configmanager.get_config_dir(),
"send_info": False,
"info_sent": 0.0,
"daemon_port": 58846, "daemon_port": 58846,
"allow_remote": False, "allow_remote": False,
"compact_allocation": False, "compact_allocation": False,
@ -181,6 +183,40 @@ class Core(
return result return result
SetConsoleCtrlHandler(win_handler) 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): def get_request(self):
"""Get the request and client address from the socket. """Get the request and client address from the socket.
We override this so that we can get the ip address of the client. We override this so that we can get the ip address of the client.
@ -268,6 +304,10 @@ class Core(
# Load plugins # Load plugins
self.plugins = PluginManager(self) self.plugins = PluginManager(self)
# send stats info
if self.config["send_info"]:
self.send_info()
# Start the TorrentManager # Start the TorrentManager
self.torrents = TorrentManager(self.session, self.alerts) self.torrents = TorrentManager(self.session, self.alerts)

View file

@ -78,7 +78,6 @@ DEFAULT_PREFS = {
"lock_tray": False, "lock_tray": False,
"tray_password": "", "tray_password": "",
"check_new_releases": False, "check_new_releases": False,
"send_info": False,
"default_load_path": None, "default_load_path": None,
"window_maximized": False, "window_maximized": False,
"window_x_pos": 0, "window_x_pos": 0,

View file

@ -217,6 +217,7 @@ class Preferences(component.Component):
"chk_natpmp": ("active", self.core_config["natpmp"]), "chk_natpmp": ("active", self.core_config["natpmp"]),
"chk_utpex": ("active", self.core_config["utpex"]), "chk_utpex": ("active", self.core_config["utpex"]),
"chk_lsd": ("active", self.core_config["lsd"]), "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_encin": ("active", self.core_config["enc_in_policy"]),
"combo_encout": ("active", self.core_config["enc_out_policy"]), "combo_encout": ("active", self.core_config["enc_out_policy"]),
"combo_enclevel": ("active", self.core_config["enc_level"]), "combo_enclevel": ("active", self.core_config["enc_level"]),
@ -331,6 +332,7 @@ class Preferences(component.Component):
"chk_natpmp", "chk_natpmp",
"chk_utpex", "chk_utpex",
"chk_lsd", "chk_lsd",
"chk_send_info",
"combo_encin", "combo_encin",
"combo_encout", "combo_encout",
"combo_enclevel", "combo_enclevel",
@ -386,7 +388,7 @@ class Preferences(component.Component):
self.gtkui_config["check_new_releases"]) self.gtkui_config["check_new_releases"])
self.glade.get_widget("chk_send_info").set_active( self.glade.get_widget("chk_send_info").set_active(
self.gtkui_config["send_info"]) self.core_config["send_info"])
## Plugins tab ## ## Plugins tab ##
all_plugins = self.all_plugins all_plugins = self.all_plugins
@ -520,7 +522,7 @@ class Preferences(component.Component):
new_gtkui_config["check_new_releases"] = \ new_gtkui_config["check_new_releases"] = \
self.glade.get_widget("chk_new_releases").get_active() 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() self.glade.get_widget("chk_send_info").get_active()
## Daemon tab ## ## Daemon tab ##