home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2012 January / maximum-cd-2012-01.iso / DiscContents / digsby_setup.exe / lib / metrics.pyo (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2011-10-05  |  2.6 KB  |  89 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.6)
  3.  
  4. import time
  5. import hooks
  6. DISABLE_STATS = False
  7.  
  8. def get_tzoffset():
  9.     daylight = time.gmtime(time.time()).tm_isdst
  10.     if time.daylight and daylight:
  11.         return time.altzone
  12.     return time.timezone
  13.  
  14.  
  15. def dump():
  16.     import simplejson
  17.     return simplejson.dumps(dict(tzOffset = get_tzoffset(), events = stats.events(), eventNames = stats.eventNames(), samples = stats.samples(), sampleNames = stats.sampleNames()))
  18.  
  19.  
  20. class MockStatistics(object):
  21.     
  22.     def event(self, eventName):
  23.         pass
  24.  
  25.     
  26.     def start(self):
  27.         pass
  28.  
  29.     
  30.     def stop(self):
  31.         pass
  32.  
  33.     
  34.     def events(self):
  35.         return []
  36.  
  37.     
  38.     def samples(self):
  39.         return []
  40.  
  41.     
  42.     def eventNames(self):
  43.         return { }
  44.  
  45.     
  46.     def sampleNames(self):
  47.         return { }
  48.  
  49.  
  50.  
  51. def on_account_state_changed(acct, state):
  52.     if acct.protocol is not None and state:
  53.         event('.'.join([
  54.             'account',
  55.             acct.protocol,
  56.             state]))
  57.     
  58.  
  59. metrics_hooks = [
  60.     ('account.state', on_account_state_changed),
  61.     ('imwin.created', None)]
  62.  
  63. def register_hooks():
  64.     for hook, cb in metrics_hooks:
  65.         if cb is None:
  66.             
  67.             cb = lambda *a, **k: event(hook)
  68.         
  69.         hooks.register(hook, cb)
  70.     
  71.  
  72.  
  73. try:
  74.     stats
  75. except NameError:
  76.     if DISABLE_STATS:
  77.         stats = MockStatistics()
  78.     else:
  79.         
  80.         try:
  81.             import cgui
  82.             stats = cgui.Statistics(15000)
  83.         except:
  84.             stats = MockStatistics()
  85.  
  86.     stats.start()
  87.     event = stats.event
  88.  
  89.