Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

[265406]: plugin.audio.dr.dk.netradio / buggalo.py Maximize Restore History

Download this file

buggalo.py    103 lines (88 with data), 3.3 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
#
# Copyright (C) 2011 Tommy Winther
# http://tommy.winther.nu
#
# This Program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This Program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with XBMC; see the file COPYING. If not, write to
# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
# http://www.gnu.org/copyleft/gpl.html
#
#
# Buggalo 1.0
# http://theinfosphere.org/Where_the_Buggalo_Roam
#
import os
import sys
import traceback as tb
import datetime
import urllib2
import simplejson
import random
import xbmcgui
import xbmcaddon
def onExceptionRaised():
"""
Invoke this method in an except clause to allow the user to submit
a bug report with stacktrace, system information, etc.
This also avoids the 'Script error' popup in XBMC, unless of course
an exception is thrown in this code :-)
"""
# start by logging the usual info to stderr
(type, value, traceback) = sys.exc_info()
tb.print_exception(type, value, traceback)
addon = xbmcaddon.Addon()
heading = addon.getLocalizedString(random.randint(99980, 99985))
line1 = addon.getLocalizedString(99990)
line2 = addon.getLocalizedString(99991)
line3 = addon.getLocalizedString(99992)
yes = addon.getLocalizedString(99993)
no = addon.getLocalizedString(99994)
thanks = addon.getLocalizedString(99995)
if xbmcgui.Dialog().yesno(heading, line1, line2, line3, no, yes):
data = _gatherData(addon, type, value, traceback)
_submitData(data)
xbmcgui.Dialog().ok(heading, thanks)
def _gatherData(addon, type, value, traceback):
(sysname, nodename, release, version, machine) = os.uname()
data = dict()
data['timestamp'] = datetime.datetime.now().isoformat()
system = dict()
system['nodename'] = nodename
system['sysname'] = sysname
system['release'] = release
system['version'] = version
system['machine'] = machine
data['system'] = system
addonInfo = dict()
addonInfo['id'] = addon.getAddonInfo('id')
addonInfo['name'] = addon.getAddonInfo('name')
addonInfo['version'] = addon.getAddonInfo('version')
addonInfo['path'] = addon.getAddonInfo('path')
addonInfo['profile'] = addon.getAddonInfo('profile')
data['addon'] = addonInfo
execution = dict()
execution['python'] = sys.version
execution['sys.argv'] = sys.argv
data['execution'] = execution
exception = dict()
exception['type'] = str(type)
exception['value'] = str(value)
exception['stacktrace'] = tb.format_tb(traceback)
data['exception'] = exception
return simplejson.dumps(data)
def _submitData(data):
req = urllib2.Request('http://tommy.winther.nu/exception/submit.php', data)
req.add_header('Content-Type', 'text/json')
u = urllib2.urlopen(req)
u.read()
u.close()