[Dextrose] [PATCH sugar] Do not send empty feedback reports if anonymous_with_sn is enabled

Aleksey Lim alsroot at activitycentral.org
Fri Feb 11 21:17:17 EST 2011


---
 src/jarabe/model/feedback_collector.py |   24 +++++++++++++-----------
 1 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/src/jarabe/model/feedback_collector.py b/src/jarabe/model/feedback_collector.py
index 43540a0..3f3b9a8 100644
--- a/src/jarabe/model/feedback_collector.py
+++ b/src/jarabe/model/feedback_collector.py
@@ -49,7 +49,8 @@ def start(host, port, auto_submit_delay):
     _port = port
 
     if auto_submit_delay > 0:
-        gobject.timeout_add_seconds(auto_submit_delay, anonymous_submit, True)
+        logging.debug('Feedback auto submit with %ss delay', auto_submit_delay)
+        gobject.timeout_add_seconds(auto_submit_delay, _auto_submit_cb)
 
 
 def update(bundle_id, report, log_file):
@@ -88,27 +89,28 @@ def submit(message):
             'nick': nick,
             'jabber_server': jabber,
             }
-    _submit(data, False)
+    _reports.update(data)
+    _submit(False)
 
 
 def anonymous_submit(implicit=False):
+    if is_empty():
+        return
+
     from jarabe.journal import misc
 
-    data = {}
     client = gconf.client_get_default()
     if client.get_bool('/desktop/sugar/feedback/anonymous_with_sn'):
-        data['serial_number'] = misc.get_xo_serial()
-    _submit(data, implicit)
+        _reports['serial_number'] = misc.get_xo_serial()
+    _submit(implicit)
 
-    return True
 
+def _auto_submit_cb():
+    anonymous_submit()
+    return True
 
-def _submit(data, implicit):
-    if data:
-        _reports.update(data)
-    if is_empty():
-        return
 
+def _submit(implicit):
     logging.debug('Sending feedback report: %r', _reports)
 
     report = simplejson.dumps(_reports)
-- 
1.7.3.4



More information about the Dextrose mailing list