[web2py] Re: Error tickets by number of occurrence

2010-10-25 Thread mdipierro
Good idea!

On Oct 25, 6:37 am, selecta gr...@delarue-berlin.de wrote:
 Quite a while ago I wrote some code for my issue tracker to show error
 tickets by their number of occurrence.
 The Idea behind this is that you will see the error that appears most
 frequently and that needs fixing immediately. Since I am too busy to
 finish the issue tracker I will just share the relevant code

 screenshothttp://jaguar.biologie.hu-berlin.de/~fkrause/screenshot_error_frequec...

 the controller

 error_files_base =
 os.path.join(request.env.web2py_path,'applications',request.application,'errors')
 def errors():
    import operator
    import os.path
    import hashlib
    import os
    import pickle
     #--
     if request.vars.has_key('del'):
         for fn in os.listdir(error_files_base):
             try:
                 error =
 pickle.load(open(os.path.join(error_files_base,fn),'r'))
             except IOError:
                 continue
             hash = hashlib.md5(error['traceback']).hexdigest()
             if request.vars['del'] == hash:
                 os.remove( os.path.join(error_files_base,fn) )
     #--

     hash2error = dict()
     for fn in os.listdir(error_files_base):
         try:
             error =
 pickle.load(open(os.path.join(error_files_base,fn),'r'))
         except IOError:
             continue
         hash = hashlib.md5(error['traceback']).hexdigest()
         try:
             hash2error[hash]['count'] += 1
         except KeyError:
             error_lines = error['traceback'].split(\n)
             last_line = error_lines[-2]
             error_causer = os.path.split(error['layer'])[1]
             hash2error[hash] = dict(count = 1, pickel = error, causer
 = error_causer, last_line = last_line, hash = hash)

     decorated = [(x['count'],x) for x in hash2error.values()]
     decorated.sort(key=operator.itemgetter(0), reverse=True)
     return dict(errors = [x[1] for x in decorated])

 the view

 table id='trck_errors'
 {{=THEAD(TR(TH('Delete'), TH('Count'), TH('File'), TH('Error')))}}
 tbody
 {{for e in errors:}}
 {{=TR(TD(BUTTON_DELETE(e['hash'])),
 TH(e['count']),TD(e['causer']),TD(e['last_line']),
 _onclick=collapse('%s');%e['hash'])}}{{=TR(TD(DIV(CODE(e['pickel']
 ['traceback']), _id=e['hash']),_colspan=4 ))}}
 {{pass}}
 /tbody
 /table
 script $(document).ready(function(){
     $('{{for e in errors:}}#{{=e['hash']}}, {{pass}}').hide();
     }); /script

 feel free to use and improve


[web2py] Re: Error tickets by number of occurrence

2010-10-25 Thread selecta
so will you integrate it into the current issue tracker?
like a tab or button with sort by number of occurrence

On Oct 25, 1:59 pm, mdipierro mdipie...@cs.depaul.edu wrote:
 Good idea!

 On Oct 25, 6:37 am, selecta gr...@delarue-berlin.de wrote:



  Quite a while ago I wrote some code for my issue tracker to show error
  tickets by their number of occurrence.
  The Idea behind this is that you will see the error that appears most
  frequently and that needs fixing immediately. Since I am too busy to
  finish the issue tracker I will just share the relevant code

  screenshothttp://jaguar.biologie.hu-berlin.de/~fkrause/screenshot_error_frequec...

  the controller

  error_files_base =
  os.path.join(request.env.web2py_path,'applications',request.application,'er­rors')
  def errors():
     import operator
     import os.path
     import hashlib
     import os
     import pickle
      #--
      if request.vars.has_key('del'):
          for fn in os.listdir(error_files_base):
              try:
                  error =
  pickle.load(open(os.path.join(error_files_base,fn),'r'))
              except IOError:
                  continue
              hash = hashlib.md5(error['traceback']).hexdigest()
              if request.vars['del'] == hash:
                  os.remove( os.path.join(error_files_base,fn) )
      #--

      hash2error = dict()
      for fn in os.listdir(error_files_base):
          try:
              error =
  pickle.load(open(os.path.join(error_files_base,fn),'r'))
          except IOError:
              continue
          hash = hashlib.md5(error['traceback']).hexdigest()
          try:
              hash2error[hash]['count'] += 1
          except KeyError:
              error_lines = error['traceback'].split(\n)
              last_line = error_lines[-2]
              error_causer = os.path.split(error['layer'])[1]
              hash2error[hash] = dict(count = 1, pickel = error, causer
  = error_causer, last_line = last_line, hash = hash)

      decorated = [(x['count'],x) for x in hash2error.values()]
      decorated.sort(key=operator.itemgetter(0), reverse=True)
      return dict(errors = [x[1] for x in decorated])

  the view

  table id='trck_errors'
  {{=THEAD(TR(TH('Delete'), TH('Count'), TH('File'), TH('Error')))}}
  tbody
  {{for e in errors:}}
  {{=TR(TD(BUTTON_DELETE(e['hash'])),
  TH(e['count']),TD(e['causer']),TD(e['last_line']),
  _onclick=collapse('%s');%e['hash'])}}{{=TR(TD(DIV(CODE(e['pickel']
  ['traceback']), _id=e['hash']),_colspan=4 ))}}
  {{pass}}
  /tbody
  /table
  script $(document).ready(function(){
      $('{{for e in errors:}}#{{=e['hash']}}, {{pass}}').hide();
      }); /script

  feel free to use and improve


[web2py] Re: Error tickets by number of occurrence

2010-10-25 Thread mdipierro
If I have time, I would like to.

On Oct 25, 7:03 am, selecta gr...@delarue-berlin.de wrote:
 so will you integrate it into the current issue tracker?
 like a tab or button with sort by number of occurrence

 On Oct 25, 1:59 pm, mdipierro mdipie...@cs.depaul.edu wrote:

  Good idea!

  On Oct 25, 6:37 am, selecta gr...@delarue-berlin.de wrote:

   Quite a while ago I wrote some code for my issue tracker to show error
   tickets by their number of occurrence.
   The Idea behind this is that you will see the error that appears most
   frequently and that needs fixing immediately. Since I am too busy to
   finish the issue tracker I will just share the relevant code

   screenshothttp://jaguar.biologie.hu-berlin.de/~fkrause/screenshot_error_frequec...

   the controller

   error_files_base =
   os.path.join(request.env.web2py_path,'applications',request.application,'er­rors')
   def errors():
      import operator
      import os.path
      import hashlib
      import os
      import pickle
       #--
       if request.vars.has_key('del'):
           for fn in os.listdir(error_files_base):
               try:
                   error =
   pickle.load(open(os.path.join(error_files_base,fn),'r'))
               except IOError:
                   continue
               hash = hashlib.md5(error['traceback']).hexdigest()
               if request.vars['del'] == hash:
                   os.remove( os.path.join(error_files_base,fn) )
       #--

       hash2error = dict()
       for fn in os.listdir(error_files_base):
           try:
               error =
   pickle.load(open(os.path.join(error_files_base,fn),'r'))
           except IOError:
               continue
           hash = hashlib.md5(error['traceback']).hexdigest()
           try:
               hash2error[hash]['count'] += 1
           except KeyError:
               error_lines = error['traceback'].split(\n)
               last_line = error_lines[-2]
               error_causer = os.path.split(error['layer'])[1]
               hash2error[hash] = dict(count = 1, pickel = error, causer
   = error_causer, last_line = last_line, hash = hash)

       decorated = [(x['count'],x) for x in hash2error.values()]
       decorated.sort(key=operator.itemgetter(0), reverse=True)
       return dict(errors = [x[1] for x in decorated])

   the view

   table id='trck_errors'
   {{=THEAD(TR(TH('Delete'), TH('Count'), TH('File'), TH('Error')))}}
   tbody
   {{for e in errors:}}
   {{=TR(TD(BUTTON_DELETE(e['hash'])),
   TH(e['count']),TD(e['causer']),TD(e['last_line']),
   _onclick=collapse('%s');%e['hash'])}}{{=TR(TD(DIV(CODE(e['pickel']
   ['traceback']), _id=e['hash']),_colspan=4 ))}}
   {{pass}}
   /tbody
   /table
   script $(document).ready(function(){
       $('{{for e in errors:}}#{{=e['hash']}}, {{pass}}').hide();
       }); /script

   feel free to use and improve




Re: [web2py] Re: Error tickets by number of occurrence

2010-10-25 Thread Thadeus Burgess
I think this should be default for the ticket view.

--
Thadeus




On Mon, Oct 25, 2010 at 8:54 AM, mdipierro mdipie...@cs.depaul.edu wrote:

 If I have time, I would like to.

 On Oct 25, 7:03 am, selecta gr...@delarue-berlin.de wrote:
  so will you integrate it into the current issue tracker?
  like a tab or button with sort by number of occurrence
 
  On Oct 25, 1:59 pm, mdipierro mdipie...@cs.depaul.edu wrote:
 
   Good idea!
 
   On Oct 25, 6:37 am, selecta gr...@delarue-berlin.de wrote:
 
Quite a while ago I wrote some code for my issue tracker to show
 error
tickets by their number of occurrence.
The Idea behind this is that you will see the error that appears most
frequently and that needs fixing immediately. Since I am too busy to
finish the issue tracker I will just share the relevant code
 
screenshothttp://
 jaguar.biologie.hu-berlin.de/~fkrause/screenshot_error_frequec.http://jaguar.biologie.hu-berlin.de/%7Efkrause/screenshot_error_frequec.
 ..
 
the controller
 
error_files_base =
   
 os.path.join(request.env.web2py_path,'applications',request.application,'er­rors')
def errors():
   import operator
   import os.path
   import hashlib
   import os
   import pickle
#--
if request.vars.has_key('del'):
for fn in os.listdir(error_files_base):
try:
error =
pickle.load(open(os.path.join(error_files_base,fn),'r'))
except IOError:
continue
hash = hashlib.md5(error['traceback']).hexdigest()
if request.vars['del'] == hash:
os.remove( os.path.join(error_files_base,fn) )
#--
 
hash2error = dict()
for fn in os.listdir(error_files_base):
try:
error =
pickle.load(open(os.path.join(error_files_base,fn),'r'))
except IOError:
continue
hash = hashlib.md5(error['traceback']).hexdigest()
try:
hash2error[hash]['count'] += 1
except KeyError:
error_lines = error['traceback'].split(\n)
last_line = error_lines[-2]
error_causer = os.path.split(error['layer'])[1]
hash2error[hash] = dict(count = 1, pickel = error, causer
= error_causer, last_line = last_line, hash = hash)
 
decorated = [(x['count'],x) for x in hash2error.values()]
decorated.sort(key=operator.itemgetter(0), reverse=True)
return dict(errors = [x[1] for x in decorated])
 
the view
 
table id='trck_errors'
{{=THEAD(TR(TH('Delete'), TH('Count'), TH('File'), TH('Error')))}}
tbody
{{for e in errors:}}
{{=TR(TD(BUTTON_DELETE(e['hash'])),
TH(e['count']),TD(e['causer']),TD(e['last_line']),
_onclick=collapse('%s');%e['hash'])}}{{=TR(TD(DIV(CODE(e['pickel']
['traceback']), _id=e['hash']),_colspan=4 ))}}
{{pass}}
/tbody
/table
script $(document).ready(function(){
$('{{for e in errors:}}#{{=e['hash']}}, {{pass}}').hide();
}); /script
 
feel free to use and improve