[Dextrose] [PATCH sugar] Notify on not sent feedbacks; fix issue with not auto resend
Anish Mangal
anish at activitycentral.org
Mon Feb 14 22:08:52 EST 2011
On Thu, Feb 10, 2011 at 12:28, Anish Mangal <anish at activitycentral.org> wrote:
> On Sun, Feb 6, 2011 at 07:52, Aleksey Lim <alsroot at activitycentral.org> wrote:
>> ---
>> src/jarabe/model/feedback_collector.py | 32 ++++++++++++++++++++------------
>> 1 files changed, 20 insertions(+), 12 deletions(-)
>>
>> diff --git a/src/jarabe/model/feedback_collector.py b/src/jarabe/model/feedback_collector.py
>> index 4671437..43540a0 100644
>> --- a/src/jarabe/model/feedback_collector.py
>> +++ b/src/jarabe/model/feedback_collector.py
>> @@ -25,12 +25,14 @@ from email.mime.multipart import MIMEMultipart
>> from email.mime.application import MIMEApplication
>> from email.generator import Generator
>> from email.encoders import encode_noop
>> +from gettext import gettext as _
>>
>> import gconf
>> import gobject
>> import simplejson
>>
>> from sugar import logger, feedback, util
>> +from jarabe import frame
>>
>>
>> _reports = {}
>> @@ -47,7 +49,7 @@ def start(host, port, auto_submit_delay):
>> _port = port
>>
>> if auto_submit_delay > 0:
>> - gobject.timeout_add_seconds(auto_submit_delay, anonymous_submit)
>> + gobject.timeout_add_seconds(auto_submit_delay, anonymous_submit, True)
>>
>>
>> def update(bundle_id, report, log_file):
>> @@ -86,24 +88,26 @@ def submit(message):
>> 'nick': nick,
>> 'jabber_server': jabber,
>> }
>> - _submit(data)
>> + _submit(data, False)
>>
>>
>> -def anonymous_submit():
>> +def anonymous_submit(implicit=False):
>> 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)
>> + _submit(data, implicit)
>> +
>> + return True
>>
>>
>> -def _submit(data=None):
>> +def _submit(data, implicit):
>> if data:
>> _reports.update(data)
>> if is_empty():
>> - return True
>> + return
>>
>> logging.debug('Sending feedback report: %r', _reports)
>>
>> @@ -126,16 +130,15 @@ def _submit(data=None):
>>
>> tar.close()
>>
>> - _SubmitThread(tar_file).run()
>> -
>> - return True
>> + _SubmitThread(tar_file, implicit).run()
>>
>>
>> class _SubmitThread(threading.Thread):
>>
>> - def __init__(self, tar_file):
>> + def __init__(self, tar_file, implicit):
>> threading.Thread.__init__(self)
>> self._tar_file = tar_file
>> + self._implicit = implicit
>>
>> def run(self):
>> try:
>> @@ -151,11 +154,16 @@ class _SubmitThread(threading.Thread):
>> response = conn.getresponse()
>>
>> if response.status != 200:
>> - logging.error('Incorrect feedback submit: %s, %s',
>> + raise Exception('Incorrect feedback submit: %s, %s',
>> response.status, response.read())
>>
>> except Exception:
>> - logging.exception('Cannot submit feedback')
>> + title = _('Cannot submit feedback')
>> + msg = _('Feedback was not sent to %s:%s.') % (_host, _port)
>> + if not self._implicit:
>> + gobject.idle_add(lambda:
>> + frame.get_view().add_message(summary=title, body=msg))
>> + logging.exception('%s: %s', title, msg)
>> finally:
>> os.unlink(self._tar_file)
>> self._tar_file = None
>
> Maybe catch specific exception and give a message like:
>
> 'Was not able to submit feedback! Check your internet connection or
> try again later'
>
>> --
>> 1.7.3.4
>>
>>
>
Committed to dextrose/mainline:
http://git.sugarlabs.org/dextrose/mainline/commit/6e031895ecef7c8f2296678d23a176ab079e4149
Note: I'll open a bug report for this and other text strings I've come
across which might be better suited.
Reviewed-by: Anish Mangal <anish at activitycentral.org>
Acked-by: Anish Mangal <anish at activitycentral.org>
More information about the Dextrose
mailing list