[RELEASE] buggalo - automatic exception collector

  Thread Rating:
  • 3 Votes - 4.67 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
twinther Offline
Fan
Posts: 308
Joined: Sep 2004
Reputation: 10
Location: Denmark
Post: #1
Hi guys,
I have been working on this little script for a while and testing it on a couple of my addons.
It has helped me a lot with spotting those hard to reproduce or temporary errors. Spiff suggested I made it into a module so here it is Laugh
This module is still in the testing phase though, but input and comments are welcome!

The readme has a description of what it is and how it works, so no reason to repeat myself here..
The code is at github for now, but I will submit script.module.buggalo to the official xbmc repo once I'm done testing it.
https://github.com/twinther/script.module.buggalo

The collected data is submitted to a URL, which is part of buggalo-web which is also on github: https://github.com/twinther/buggalo-web
This code is pretty rough, but I'm using it and working on it from time to time.

The idea is that each addon author has their own buggalo-web somewhere, but I may be able to make a central site if people are interested?


The README.txt:
Code:
INTRODUCTION
---------------------------------------------------------------------
The buggalo script can collect various information about an
exception in a Python script as well as information about the
users system, such as XBMC and Python versions.

The collected information is then posted to the internet at a
predefined URL where the addon author can investigate the exception.

The script is somewhat similar to posting the xbmc.log to pastebin,
but is more specialised and doesn't contain superfluous information.
It is also better integrated into the user experience, the user only
has to decide if they want to submit the bug report or not.


HOW TO USE
---------------------------------------------------------------------
To use this script you must do two things besides importing it.

1. Set buggalo.SUBMIT_URL to a full URL where the collected data
    is submitted.

2. Surround the code you want to be covered by this script in a
    try..except block, such as:

    try
        # addon logic
    except Exception:
        buggalo.onExceptionRaised()


    For plugin type addons, it is a good idea to include pretty much
    everything inside the try..except block.
    See this link for an example:
    * https://github.com/xbmc-danish-addons/plugin.video.news.tv2.dk/blob/master/addon.py#L124

    For script type addons, besides the rule above, each event in
    your UI should include the try..except block as well.
    See this link for an example:
    * https://github.com/twinther/script.tvguide/blob/master/gui.py#L140


WHAT IS COLLECTED
---------------------------------------------------------------------
Five groups of information is collected beyond basic information
such as date and time.

* System information
   OS name and version, kernel version, etc.

* Addon information
   Addon id, name, version, path, etc.

* XBMC Information
   Build version and date, the current skin and language

* Execution information
   Python version and sys.argv

* Exception information
   Type of exception, message and full stack trace

For further details take a look at the code in buggalo.py


---------------------------------------------------------------------

The latest code is always available at github:
* https://github.com/twinther/script.module.buggalo

The module is named after a creature in my favorite animated show:
* http://theinfosphere.org/Where_the_Buggalo_Roam

---------------------------------------------------------------------
                                               2012.02.04 - twinther

Mandatory screenshots:
[Image: script_error.png]

Error reports in buggalo web:
http://tommy.winther.nu/files/2012/02/ex...er-337.png
http://tommy.winther.nu/files/2012/02/ex...er-350.png
find quote
Bstrdsmkr Offline
Posting Freak
Posts: 803
Joined: Oct 2010
Reputation: 17
Post: #2
Hey man, this looks pretty awesome!

Can you pass in custom variables to be logged too? For example, sometimes I get weird strings back from a website that cause trouble. Having the failure submit those problem strings would be top notch. If it's not, would you consider it a feature request?
find quote
twinther Offline
Fan
Posts: 308
Joined: Sep 2004
Reputation: 10
Location: Denmark
Post: #3
Hey, I have just sent in the pull request for version 1.0.0 of the module and slightly updated the README:
https://github.com/twinther/script.module.buggalo

I have now received about 450 error reports and I must say this is helping me a lot. So I hope other devs will take a look and provide feedback and suggestions Big Grin

Bstrdsmkr Wrote:Hey man, this looks pretty awesome!

Can you pass in custom variables to be logged too? For example, sometimes I get weird strings back from a website that cause trouble. Having the failure submit those problem strings would be top notch. If it's not, would you consider it a feature request?

It's not possible at the moment. I does submit the sys.argv values though, but I guess that is not enough.

Do you have a suggestion on how best to add this feature?
I'm thinking perhaps add a method to add extra data to buggalo.
If an exception is then raised, the extra data is included, otherwise it is simply discarded.
Something like:

PHP Code:
buggalo.SUBMIT_URL 'blababla'
buggalo.addExtraData(keyvalue)
buggalo.addExtraData(key2value2)

try:
    
# do stuff
    
buggalo.addExtraData(key3value3)
    
# do other stuff
except Exception:
    
buggalo.onExceptionRaised() 
find quote
Martijn Offline
Team Kodi
Posts: 11,442
Joined: Jul 2011
Reputation: 165
Location: Dawn of time
Post: #4
Might it be an idea to just put it in:
PHP Code:
buggalo.onExceptionRaised(add your data here

This way you don't have to specify the data first.
Not sure it will fetch all data you need then. Just some thoughts.

When it's added to repo i'll do the initial wiki page adding the contents of the readme so you will only have to update it.

Always read the XBMC online-manual, FAQ and search the forums before posting.
Do NOT e-mail Team-XBMC members asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting, make sure you read this first

For your mediacenter artwork go to
[Image: fanarttv.png]
(This post was last modified: 2012-02-18 13:23 by Martijn.)
find quote
Bstrdsmkr Offline
Posting Freak
Posts: 803
Joined: Oct 2010
Reputation: 17
Post: #5
That's what I had in mind when asking. Just accept a single parameter that's intended to be a dict of information to also be passed to the url. So if I think there's a possibility that a website might return values that cause trouble, I could put in my except statement:

Code:
data = {}
data['url'] = urlvariable
data['codeblock'] = 'During fetch webpage'
data['db_dir_exists'] = os.isdir(directory)

buggalo.onExceptionRaised(data)

And then I can the web interface prints any included values in an Additional Information section or similar.
find quote
Martijn Offline
Team Kodi
Posts: 11,442
Joined: Jul 2011
Reputation: 165
Location: Dawn of time
Post: #6
Added the wiki page using info in readme:
http://wiki.xbmc.org/index.php?title=Add..._Collector

Always read the XBMC online-manual, FAQ and search the forums before posting.
Do NOT e-mail Team-XBMC members asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting, make sure you read this first

For your mediacenter artwork go to
[Image: fanarttv.png]
find quote
bossanova808 Offline
Donor
Posts: 2,236
Joined: Sep 2009
Reputation: 34
Location: Melbourne, Australia
Post: #7
I'm keen but don't have a public webserver handy to use - is there a foundation one owned somewhere we could use??


Also, agree on the data, being able to pass it in right there would be handy. Should accept any type, though, not just a dict, and basically str(data) when printing it...

My XBMC stuff:
find quote
twinther Offline
Fan
Posts: 308
Joined: Sep 2004
Reputation: 10
Location: Denmark
Post: #8
I've been thinking a bit about the extra data and I think I'll add both options, ie. the addExtraData() method and the option to pass it into onExceptionRaised()
I can think of scenarios where both would be useful depending on the addon type.

I prefer the addExtraData(), because onExceptionRaised() is only supposed to be invoked when an exception is raised in Python, so your code/state is likely messed up somehow and it might be difficult to find the data you need without raising a new exception.

Thanks for updating the wiki, btw Smile

Br.
Tommy
find quote
twinther Offline
Fan
Posts: 308
Joined: Sep 2004
Reputation: 10
Location: Denmark
Post: #9
I have just pushed the change to github. let me know what you think..
https://github.com/twinther/script.modul...buggalo.py

Br.
Tommy
find quote
twinther Offline
Fan
Posts: 308
Joined: Sep 2004
Reputation: 10
Location: Denmark
Post: #10
bossanova808 Wrote:I'm keen but don't have a public webserver handy to use - is there a foundation one owned somewhere we could use??

To get things started I have setup buggalo-web on this url: http://buggalo.xbmc.info/

I don't know if this is going to be permanent yet, but it's going to stay there for the foreseeable future. buggalo-web was not really designed to be multi-user so let's see how it goes - and please fork my repo and submit patches Smile
https://github.com/twinther/buggalo-web

Remember to setup the SUBMIT_URL
PHP Code:
buggalo.SUBMIT_URL 'http://buggalo.xbmc.info/submit.php' 

Br.
Tommy
find quote
twinther Offline
Fan
Posts: 308
Joined: Sep 2004
Reputation: 10
Location: Denmark
Post: #11
Hi all,
I sent a pull request for getting v1.0.1 included in the repo today.
Two new features were added - one is the option to add extra data as we talked about in this thread.
The other is a function decorator to make it easier to wrap a function in the try..except block required by buggalo.
I use it in my tv guide addon - https://github.com/twinther/script.tvgui...ui.py#L174
Code:
@buggalo.buggalo_try_except({'method' : 'TVGuide.onInit'})
def onInit(self):
    self._hideControl(self.C_MAIN_MOUSE_CONTROLS)
    self._showControl(self.C_MAIN_OSD, self.C_MAIN_LOADING)
    self.getControl(self.C_MAIN_LOADING_TIME_LEFT).setLabel(strings(BACKGROUND_​UPDATE_IN_PROGRESS))
    self.setFocus(self.getControl(self.C_MAIN_LOADING_CANCEL))

Please let me know if you have other ideas for improvements Smile
find quote
tria Offline
Senior Member
Posts: 109
Joined: Jan 2012
Reputation: 0
Post: #12
hello twinther,

First thank you for this great module. Thank you also for the great idea. I didn't try it yet, but I liked the concept.
.
Here are some suggestions for improvements

1. Allow a way to specify the error dialog title/message. It will be also great to allow multiple title/message by passing a list of them to a method, and then randomly pick one pair and display it when an error occur.
e.g.
buggalo.setErrorMessage('title here', 'error message here') #one message only
or
buggalo.setErrorMessage([['title1', 'message1'], ['title2', 'message2']]) #pick one randomly each time

2. It would be great if you can keep track of the execution flow. For example the user choose one entry, then from there choose another one, then from there choose an entry that cause an exception. It would be helpful to send the flow up to a given number (3 steps, or make it a definable variable). This can be done by using else (try, except, else) you can there register the path of the script in a log file, and when an exception happens, you just pull the last N paths from the log and send it with the exception dump (I assume it can be done with function decorator). It will help the developer reproduce the error by following the same steps.

3. Don't know if this is possible or not, maybe you can have a third button to show what you are going to send (More Info button). This will comfort the end-user as he will see what is going to be send, and it will allow the developer to see the log when he face the exception himself without sending it to himself.

These what I thought of once I saw this module, I'll make sure to add anything else if it comes to mind.
find quote
twinther Offline
Fan
Posts: 308
Joined: Sep 2004
Reputation: 10
Location: Denmark
Post: #13
Hi tria,

Thanks for the suggestions, they are great! I'll try to implement them and probably post something here for feedback.

If you feel like contribution some code as well, you can fork my repository on github:
https://github.com/twinther/script.module.buggalo

Br.
Tommy
find quote
twinther Offline
Fan
Posts: 308
Joined: Sep 2004
Reputation: 10
Location: Denmark
Post: #14
Hi tria,

I've been working on your suggestions.
I changed the dialog to a custom one which includes a details view. I also added support for track the user flow.
The initial version of the code is available at my github.

Let me know what you think..

Br.
Tommy

[Image: script.module.buggalo-1.1.0a.png]

[Image: script.module.buggalo-1.1.0b.png]

[Image: script.module.buggalo-1.1.0c.png]
find quote
tria Offline
Senior Member
Posts: 109
Joined: Jan 2012
Reputation: 0
Post: #15
Wow, that is great man! I just saw your post!
I love the custom dialog idea, and I especially was impressed to see the userflow functionality happen.

But seeing the nodename and some of the path showing personal info (like user machine-name, and username) made me wonder if they are useful for debugging an xbmc addon, and some user might opt not to due to this. I mean no need for these info (unlike, OS, XBMC info, versions, timestamps). Maybe if there is a way to disable them from the API? I know I can remove them by myself, but this will require me to do that for each update and have my modified buggalo shipped with every addon. So having and API to enable/disable some of the info would be great.

I know I am pushing it a little bit, but how hard is it to allow the option to send an email instead of posting to a URL. Some developers might not have a website (or able to create a server-side logging on the web), but they do have an email. Allowing them to specify the title (so they can name it [XBMC-ADDON-BUG]) and they make a filter in their inbox to have a folder for them, can make it easy to track errors. It will also allow them to get the errors instantly on their smartphones, or when checking email daily.

But so far I think it is fantastic, and that any addon should use it. I even think it should be built in by xbmc, and I do mean it.
find quote
Post Reply