Update of /cvsroot/freevo/freevo/src/plugins/idlebar
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3230/src/plugins/idlebar

Modified Files:
        MultiMail.py __init__.py system.py 
Log Message:
patch from Viggo Fredriksen to reactivate the plugins

Index: MultiMail.py
===================================================================
RCS file: /cvsroot/freevo/freevo/src/plugins/idlebar/MultiMail.py,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** MultiMail.py        1 Aug 2004 10:48:47 -0000       1.6
--- MultiMail.py        8 Sep 2004 08:33:13 -0000       1.7
***************
*** 9,12 ****
--- 9,15 ----
  # -----------------------------------------------------------------------
  # $Log$
+ # Revision 1.7  2004/09/08 08:33:13  dischi
+ # patch from Viggo Fredriksen to reactivate the plugins
+ #
  # Revision 1.6  2004/08/01 10:48:47  dischi
  # deactivate plugin because of interface change
***************
*** 20,24 ****
  # -----------------------------------------------------------------------
  # Freevo - A Home Theater PC framework
! # Copyright (C) 2002 Krister Lagerstrom, et al. 
  # Please see the file freevo/Docs/CREDITS for a complete list of authors.
  #
--- 23,27 ----
  # -----------------------------------------------------------------------
  # Freevo - A Home Theater PC framework
! # Copyright (C) 2002 Krister Lagerstrom, et al.
  # Please see the file freevo/Docs/CREDITS for a complete list of authors.
  #
***************
*** 46,49 ****
--- 49,53 ----
  import threading
  import time
+ import gui
  
  from plugins.idlebar import IdleBarPlugin
***************
*** 53,95 ****
      """
      Displays an icon in the idlebar representing the number of emails for a 
specified account. In the case of IMAP, it only lists unread messages
!     
      Activate with:
      plugin.activate('idlebar.MultiMail.Imap',    level=10, args=('username', 
'password', 'host', 'port', 'folder')) (port and folder are optional)
      plugin.activate('idlebar.MultiMail.Pop3',    level=10, args=('username', 
'password', 'host', 'port')) (port is optional)
!     plugin.activate('idlebar.MultiMail.Mbox',    level=10, args=('path to mailbox 
file')    
!     
      """
      def __init__(self):
-         self.reason = 'draw() function needs update to work with new interface'
-         return
  
          IdleBarPlugin.__init__(self)
!         self.NO_MAILIMAGE = os.path.join(config.ICON_DIR, 
'status/newmail_dimmed.png')
!         self.MAILIMAGE = os.path.join(config.ICON_DIR, 
'status/newmail_active_small.png')
          self.FREQUENCY = 20 # seconds between checks
          self.unread = 0
          self.bg_thread = threading.Thread(target=self._bg_function, name='MultiMail 
Thread')
          self.bg_thread.setDaemon(1)
          self.bg_thread.start() # Run self._bg_function() in a separate thread
!         
      def _bg_function(self):
          while 1:
              self.unread = self.checkmail()
              time.sleep(self.FREQUENCY)
!         
      def checkmail(self):
          return 0
  
!     def draw(self, (type, object), x, osd):
          if self.unread > 0:
!             image_width = osd.drawimage(self.MAILIMAGE, (x, osd.y + 2, -1, -1))[0]
!             font  = osd.get_font('weather')
!             unread_str = '%3s' % self.unread
!             text_width = font.stringsize(unread_str)
!             osd.drawstring(unread_str, font, None, x, osd.y + 55 - font.h, 
text_width, font.h, 'left', 'top')
!             display_width = max(image_width, text_width)
!         else:
!             display_width = osd.drawimage(self.NO_MAILIMAGE, (x, osd.y + 10, -1, 
-1))[0] 
!         return display_width
  
  class Imap(MultiMail):
--- 57,108 ----
      """
      Displays an icon in the idlebar representing the number of emails for a 
specified account. In the case of IMAP, it only lists unread messages
! 
      Activate with:
      plugin.activate('idlebar.MultiMail.Imap',    level=10, args=('username', 
'password', 'host', 'port', 'folder')) (port and folder are optional)
      plugin.activate('idlebar.MultiMail.Pop3',    level=10, args=('username', 
'password', 'host', 'port')) (port is optional)
!     plugin.activate('idlebar.MultiMail.Mbox',    level=10, args=('path to mailbox 
file')
! 
      """
      def __init__(self):
  
          IdleBarPlugin.__init__(self)
!         self.NO_MAILIMAGE = os.path.join(config.ICON_DIR, 'status', 
'newmail_dimmed.png')
!         self.MAILIMAGE = os.path.join(config.ICON_DIR, 'status', 
'newmail_active_small.png')
          self.FREQUENCY = 20 # seconds between checks
          self.unread = 0
+         self.last_unread = -1
          self.bg_thread = threading.Thread(target=self._bg_function, name='MultiMail 
Thread')
          self.bg_thread.setDaemon(1)
          self.bg_thread.start() # Run self._bg_function() in a separate thread
! 
      def _bg_function(self):
          while 1:
              self.unread = self.checkmail()
              time.sleep(self.FREQUENCY)
! 
      def checkmail(self):
          return 0
  
!     def draw(self, width, height):
!         if self.last_unread == self.unread:
!             return self.NO_CHANGE
! 
!         self.clear()
!         self.last_unread = self.unread
! 
          if self.unread > 0:
!             i = gui.imagelib.load(self.MAILIMAGE, (None, None))
!             self.objects.append(gui.Image(i, (0, 2)))
!             font  = gui.get_font('weather')
!             str_unread = '%3s' % self.unread
!             text_width = font.stringsize(str_unread)
!             t = gui.Text(str_unread, (0, 55-font.height), (text_width, font.height),
!                          font, 'left', 'top')
!             self.objects.append(t)
!             return max(i.width, t.width)
! 
!         i = gui.imagelib.load(self.NO_MAILIMAGE, (None, None))
!         self.objects.append(gui.Image(i, (0, 10)))
!         return i.width
  
  class Imap(MultiMail):
***************
*** 101,105 ****
          self.FOLDER = folder
          MultiMail.__init__(self)
!         
      def checkmail(self):
          try:
--- 114,118 ----
          self.FOLDER = folder
          MultiMail.__init__(self)
! 
      def checkmail(self):
          try:
***************
*** 108,118 ****
              imap.select(self.FOLDER)
              unread = len(imap.search(None,"(UNSEEN)")[1][0].split())
!             imap.logout
!             return unread            
          except:
              _debug_('IMAP exception')
              return 0
!         
! class Pop3(MultiMail):        
      def __init__(self, username, password, host, port=110):
          self.USERNAME = username
--- 121,131 ----
              imap.select(self.FOLDER)
              unread = len(imap.search(None,"(UNSEEN)")[1][0].split())
!             imap.logout()
!             return unread
          except:
              _debug_('IMAP exception')
              return 0
! 
! class Pop3(MultiMail):
      def __init__(self, username, password, host, port=110):
          self.USERNAME = username
***************
*** 120,124 ****
          self.HOST = host
          self.PORT = port
!         MultiMail.__init__(self)    
  
      def checkmail(self):
--- 133,137 ----
          self.HOST = host
          self.PORT = port
!         MultiMail.__init__(self)
  
      def checkmail(self):
***************
*** 128,140 ****
              pop.pass_(self.PASSWORD)
              unread = len(pop.list()[1])
!             pop.quit
              return unread
          except:
              return 0
!       
  class Mbox(MultiMail):
      def __init__(self, mailbox):
          self.MAILBOX = mailbox
!         MultiMail.__init__(self)    
  
      def checkmail(self):
--- 141,153 ----
              pop.pass_(self.PASSWORD)
              unread = len(pop.list()[1])
!             pop.quit()
              return unread
          except:
              return 0
! 
  class Mbox(MultiMail):
      def __init__(self, mailbox):
          self.MAILBOX = mailbox
!         MultiMail.__init__(self)
  
      def checkmail(self):
***************
*** 149,151 ****
          else:
              return 0
!         
--- 162,164 ----
          else:
              return 0
! 

Index: __init__.py
===================================================================
RCS file: /cvsroot/freevo/freevo/src/plugins/idlebar/__init__.py,v
retrieving revision 1.28
retrieving revision 1.29
diff -C2 -d -r1.28 -r1.29
*** __init__.py 27 Aug 2004 14:27:54 -0000      1.28
--- __init__.py 8 Sep 2004 08:33:13 -0000       1.29
***************
*** 18,21 ****
--- 18,24 ----
  # -----------------------------------------------------------------------
  # $Log$
+ # Revision 1.29  2004/09/08 08:33:13  dischi
+ # patch from Viggo Fredriksen to reactivate the plugins
+ #
  # Revision 1.28  2004/08/27 14:27:54  dischi
  # change to new animation class name
***************
*** 129,133 ****
          self.container.set_zindex(10)
          gui.display.add_child(self.container)
!         
          # Getting current LOCALE
          try:
--- 132,136 ----
          self.container.set_zindex(10)
          gui.display.add_child(self.container)
! 
          # Getting current LOCALE
          try:
***************
*** 146,149 ****
--- 149,153 ----
          w = screen.width
          h = config.OSD_OVERSCAN_Y + 60
+ 
          f = gui.get_image('idlebar')
  
***************
*** 188,192 ****
  
          return changed
!             
  
      def show(self, update=True, fade=0):
--- 192,196 ----
  
          return changed
! 
  
      def show(self, update=True, fade=0):
***************
*** 207,211 ****
          if update:
              gui.get_display().update()
!         
  
      def add_background(self):
--- 211,215 ----
          if update:
              gui.get_display().update()
! 
  
      def add_background(self):
***************
*** 226,231 ****
          else:
              self.background.show()
!             
!                                                   
      def remove_background(self):
          """
--- 230,235 ----
          else:
              self.background.show()
! 
! 
      def remove_background(self):
          """
***************
*** 235,239 ****
              self.background.hide()
  
!             
      def eventhandler(self, event, menuw=None):
          """
--- 239,243 ----
              self.background.hide()
  
! 
      def eventhandler(self, event, menuw=None):
          """
***************
*** 265,269 ****
                  self.update()
              return
!         
          if not self.visible:
              return False
--- 269,273 ----
                  self.update()
              return
! 
          if not self.visible:
              return False
***************
*** 296,300 ****
          self.align     = 'left'
  
!         
      def draw(self, width, height):
          return self.NO_CHANGE
--- 300,304 ----
          self.align     = 'left'
  
! 
      def draw(self, width, height):
          return self.NO_CHANGE
***************
*** 305,310 ****
              o.unparent()
          self.objects = []
!         
!             
  
  
--- 309,314 ----
              o.unparent()
          self.objects = []
! 
! 
  
  
***************
*** 358,363 ****
      """
      def __init__(self):
-         self.reason = 'draw() function needs update to work with new interface'
-         return
  
          IdleBarPlugin.__init__(self)
--- 362,365 ----
***************
*** 373,379 ****
          self.cdimages ['mixed']       = os.path.join(icondir, 'cd_mixed.png')
  
!     def draw(self, (type, object), x, osd):
          image = self.cdimages['empty_cdrom']
!         width = 0
          for media in config.REMOVABLE_MEDIA:
              image = self.cdimages['empty_cdrom']
--- 375,384 ----
          self.cdimages ['mixed']       = os.path.join(icondir, 'cd_mixed.png')
  
!     def draw(self, width, height):
          image = self.cdimages['empty_cdrom']
! 
!         self.clear()
! 
!         w = 0
          for media in config.REMOVABLE_MEDIA:
              image = self.cdimages['empty_cdrom']
***************
*** 384,392 ****
              else:
                  image = self.cdimages['mixed']
  
!             width += osd.drawimage(image, (x+width, osd.y + 10, -1, -1))[0] + 10
!         if width:
!             width -= 10
!         return width
  
  
--- 389,402 ----
              else:
                  image = self.cdimages['mixed']
+             i = gui.imagelib.load(image, (None, None))
  
!             w += i.width + 10
! 
!             self.objects.append(gui.Image(i, (w, (height-i.height)/2)))
! 
! 
!         if w:
!             w -= 10
!         return w
  
  
***************
*** 400,407 ****
      """
      def __init__(self, mailbox):
-         self.reason = 'draw() function needs update to work with new interface'
-         return
- 
          IdleBarPlugin.__init__(self)
          self.NO_MAILIMAGE = os.path.join(config.ICON_DIR, 
'status/newmail_dimmed.png')
          self.MAILIMAGE = os.path.join(config.ICON_DIR, 'status/newmail_active.png')
--- 410,415 ----
      """
      def __init__(self, mailbox):
          IdleBarPlugin.__init__(self)
+         self.mails = -1
          self.NO_MAILIMAGE = os.path.join(config.ICON_DIR, 
'status/newmail_dimmed.png')
          self.MAILIMAGE = os.path.join(config.ICON_DIR, 'status/newmail_active.png')
***************
*** 422,430 ****
              return 0
  
!     def draw(self, (type, object), x, osd):
!         if self.checkmail() > 0:
!             return osd.drawimage(self.MAILIMAGE, (x, osd.y + 10, -1, -1))[0]
          else:
!             return osd.drawimage(self.NO_MAILIMAGE, (x, osd.y + 10, -1, -1))[0]
  
  
--- 430,450 ----
              return 0
  
!     def draw(self, width, height):
!         mails = self.checkmail()
! 
!         if self.mails == mails:
!             return self.NO_CHANGE
! 
!         self.mails = mails
!         self.clear()
! 
!         if mails > 0:
!             m = gui.imagelib.load(self.MAILIMAGE, (None, None))
          else:
!             m = gui.imagelib.load(self.NO_MAILIMAGE, (None, None))
! 
!         self.objects.append(gui.Image(m, (0, (height-m.height)/2)))
! 
!         return m.width
  
  
***************
*** 444,449 ****
      """
      def __init__(self, listings_threshold=-1):
-         self.reason = 'draw() function needs update to work with new interface'
-         return
          IdleBarPlugin.__init__(self)
  
--- 464,467 ----
***************
*** 453,457 ****
          self.tvlockfile         = config.FREEVO_CACHEDIR + '/record'
          self.status             = None
!         
          self.TVLOCKED     = 'television_active.png'
          self.TVFREE       = 'television_inactive.png'
--- 471,475 ----
          self.tvlockfile         = config.FREEVO_CACHEDIR + '/record'
          self.status             = None
! 
          self.TVLOCKED     = 'television_active.png'
          self.TVFREE       = 'television_inactive.png'
***************
*** 464,468 ****
          self.status = None
  
!         
      def checktv(self):
          if os.path.exists(self.tvlockfile):
--- 482,486 ----
          self.status = None
  
! 
      def checktv(self):
          if os.path.exists(self.tvlockfile):
***************
*** 495,504 ****
          self.clear()
          self.status = status
!         i = gui.get_icon('status/television_%s' % status)
!         i = gui.get_display().renderer.load(i, (None, height))
!         
!         w,h  = i.get_size()
!         self.objects.append(gui.Image(0, 0, w, h, i))
!         return w
  
  
--- 513,522 ----
          self.clear()
          self.status = status
!         icon = gui.get_icon('status/television_%s' % status)
!         i = gui.imagelib.load(icon, (None, None))
! 
! 
!         self.objects.append(gui.Image(i, (0, (height-i.height)/2)))
!         return i.width
  
  
***************
*** 515,520 ****
      """
      def __init__(self, zone='CYYZ', units='C'):
!         self.reason = 'draw() function needs update to work with new interface'
!         return
  
          IdleBarPlugin.__init__(self)
--- 533,537 ----
      """
      def __init__(self, zone='CYYZ', units='C'):
!         self.current = None, None
  
          IdleBarPlugin.__init__(self)
***************
*** 587,599 ****
          return temperature, icon
  
!     def draw(self, (type, object), x, osd):
          temp,icon = self.checkweather()
!         font  = osd.get_font('small0')
!         osd.drawimage(os.path.join(config.ICON_DIR, 'weather/' + icon),
!                         (x, osd.y + 15, -1, -1))
          temp = u'%s\xb0' % temp
          width = font.stringsize(temp)
!         osd.drawstring(temp, font, None, x + 15, osd.y + 55 - font.height, width, 
font.height,
!                        'left', 'top')
          return width + 15
  
--- 604,628 ----
          return temperature, icon
  
!     def draw(self, width, height):
!         t, ic = self.current
          temp,icon = self.checkweather()
! 
!         if temp == t and ic == icon:
!             return self.NO_CHANGE
! 
!         self.clear()
!         self.current = temp, icon
! 
!         icon = os.path.join(config.ICON_DIR, 'weather', icon)
!         font  = gui.get_font('small0')
!         i = gui.imagelib.load(icon, (None, None))
!         self.objects.append(gui.Image(i, (0, 15)))
! 
          temp = u'%s\xb0' % temp
          width = font.stringsize(temp)
! 
!         self.objects.append(gui.Text(temp, (15, 55-font.height), (width, 
font.height),
!                                      font, 'left', 'top'))
! 
          return width + 15
  
***************
*** 622,628 ****
      """
      def __init__(self):
-         self.reason = 'draw() function needs update to work with new interface'
-         return
          IdleBarPlugin.__init__(self)
  
      def config(self):
--- 651,656 ----
      """
      def __init__(self):
          IdleBarPlugin.__init__(self)
+         self.icon = ''
  
      def config(self):
***************
*** 647,654 ****
                  return os.path.join(config.ICON_DIR, 'holidays', icon)
  
!     def draw(self, (type, object), x, osd):
          icon = self.get_holiday_icon()
          if icon:
!             return osd.drawimage(icon, (x, osd.y + 10, -1, -1))[0]
  
  
--- 675,694 ----
                  return os.path.join(config.ICON_DIR, 'holidays', icon)
  
! 
!     def draw(self, width, height):
          icon = self.get_holiday_icon()
+ 
+         if icon == self.icon:
+             return self.NO_CHANGE
+ 
          if icon:
!             self.icon = icon
!             self.clear()
!             i = gui.imagelib.load(icon, (None, None))
!             self.objects.append(gui.Image(i, (0, (height-i.height)/2)))
! 
!             return i.width
! 
!         return 0
  
  
***************
*** 676,680 ****
          self.file = image
          self.clear()
!             
          i = gui.imagelib.load(image, (None, height + 10))
          if not i:
--- 716,720 ----
          self.file = image
          self.clear()
! 
          i = gui.imagelib.load(image, (None, height + 10))
          if not i:
***************
*** 682,685 ****
  
          self.objects.append(gui.Image(i, (0, 0)))
!         print 'add', self.objects
          return i.width
--- 722,725 ----
  
          self.objects.append(gui.Image(i, (0, 0)))
! 
          return i.width

Index: system.py
===================================================================
RCS file: /cvsroot/freevo/freevo/src/plugins/idlebar/system.py,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** system.py   1 Aug 2004 10:48:47 -0000       1.13
--- system.py   8 Sep 2004 08:33:13 -0000       1.14
***************
*** 13,16 ****
--- 13,19 ----
  # -----------------------------------------------------------------------
  # $Log$
+ # Revision 1.14  2004/09/08 08:33:13  dischi
+ # patch from Viggo Fredriksen to reactivate the plugins
+ #
  # Revision 1.13  2004/08/01 10:48:47  dischi
  # deactivate plugin because of interface change
***************
*** 30,34 ****
  # -----------------------------------------------------------------------
  # Freevo - A Home Theater PC framework
! # Copyright (C) 2002 Krister Lagerstrom, et al. 
  # Please see the file freevo/Docs/CREDITS for a complete list of authors.
  #
--- 33,37 ----
  # -----------------------------------------------------------------------
  # Freevo - A Home Theater PC framework
! # Copyright (C) 2002 Krister Lagerstrom, et al.
  # Please see the file freevo/Docs/CREDITS for a complete list of authors.
  #
***************
*** 55,58 ****
--- 58,62 ----
  import types
  import re
+ import gui
  
  import config
***************
*** 66,70 ****
      in megabytes (calculated approx. as MemFree+Cached?)
  
!     Activate with 
         plugin.activate('idlebar.system.procstats',level=20) for defaults or
         plugin.activate('idlebar.system.procstats',level=20,args=(Mem,Cpu,Prec))
--- 70,74 ----
      in megabytes (calculated approx. as MemFree+Cached?)
  
!     Activate with
         plugin.activate('idlebar.system.procstats',level=20) for defaults or
         plugin.activate('idlebar.system.procstats',level=20,args=(Mem,Cpu,Prec))
***************
*** 75,81 ****
      """
      def __init__(self,Mem=1,Cpu=1,Prec=1):
-         self.reason = 'draw() function needs update to work with new interface'
-         return
- 
          IdleBarPlugin.__init__(self)
          self.drawCpu = Cpu
--- 79,82 ----
***************
*** 128,132 ****
          """
          This could/should maybe be an even more
!         advanced algorithm, but it will suffice 
          for normal use.
  
--- 129,133 ----
          """
          This could/should maybe be an even more
!         advanced algorithm, but it will suffice
          for normal use.
  
***************
*** 149,154 ****
          self.lastused = used
          self.currentCpu = _('%s%%') % round(usage,self.precision)
!  
!     def draw(self, (type, object), x, osd):
          try:
              self.getStats()
--- 150,155 ----
          self.lastused = used
          self.currentCpu = _('%s%%') % round(usage,self.precision)
! 
!     def draw(self, width, height):
          try:
              self.getStats()
***************
*** 156,179 ****
              _debug_('[procstats]: Not working, this plugin is only tested with 2.4 
and 2.6 kernels')
  
!         font = osd.get_font('small0')
!         widthmem = 0
!         widthcpu = 0
  
          if self.drawCpu == 1:
!             widthcpu = font.stringsize(self.currentCpu)
!             osd.drawimage(os.path.join(config.ICON_DIR, 'misc/cpu.png'),
!                           (x, osd.y + 7, -1, -1))    
!             osd.drawstring(self.currentCpu, font, None, x + 15, osd.y + 55 - font.h,
!                            widthcpu, font.h, 'left', 'top')
  
          if self.drawMem == 1:
!             widthmem = font.stringsize(self.currentMem)
  
!             osd.drawimage(os.path.join(config.ICON_DIR, 'misc/memory.png'),
!                           (x + 15 + widthcpu, osd.y + 7, -1, -1))
!             osd.drawstring(self.currentMem, font, None, x + 40 + widthcpu, 
!                            osd.y + 55 - font.h, widthmem, font.h, 'left', 'top')
  
!         return widthmem + widthcpu + 15
  
  
--- 157,191 ----
              _debug_('[procstats]: Not working, this plugin is only tested with 2.4 
and 2.6 kernels')
  
! 
!         font = gui.get_font('small0')
! 
!         width = 0
! 
!         self.clear()
  
          if self.drawCpu == 1:
!             tw = font.stringsize(self.currentCpu)
!             icon = os.path.join(config.ICON_DIR, 'misc','cpu.png')
!             i = gui.imagelib.load(icon, (None, None))
!             self.objects.append(gui.Image(i, (0, 7)))
!             t = gui.Text(self.currentCpu, (0, 55-font.height), (tw, font.height),
!                          font, 'left', 'top')
!             self.objects.append(t)
! 
!             width = max(t.width,i.width)
  
          if self.drawMem == 1:
!             text_width = font.stringsize(self.currentMem)
!             icon = os.path.join(config.ICON_DIR, 'misc','memory.png')
!             i = gui.imagelib.load(icon, (None, None))
!             self.objects.append(gui.Image(i, (width+15, 7)))
  
!             t = gui.Text(self.currentMem, (width+15, 55-font.height), (text_width, 
font.height),
!                          font, 'left', 'top')
!             self.objects.append(t)
  
!             width += max(i.width, t.width)
! 
!         return width
  
  
***************
*** 188,194 ****
                args=('cpusensor', 'casesensor', 'meminfo'))
         plugin.activate('idlebar.system.sensors', level=40,
!               args=(('cpusensor','compute expression'), 
                      ('casesensor','compute_expression'), 'meminfo'))
!                     
      cpu and case sensor are the corresponding lm_sensors : this should be
      temp1, temp2 or temp3. defaults to temp3 for cpu and temp2 for case
--- 200,206 ----
                args=('cpusensor', 'casesensor', 'meminfo'))
         plugin.activate('idlebar.system.sensors', level=40,
!               args=(('cpusensor','compute expression'),
                      ('casesensor','compute_expression'), 'meminfo'))
! 
      cpu and case sensor are the corresponding lm_sensors : this should be
      temp1, temp2 or temp3. defaults to temp3 for cpu and temp2 for case
***************
*** 198,206 ****
      This requires a properly configure lm_sensors! If the standard sensors frontend
      delivered with lm_sensors works your OK.
!     Some sensors return raw-values, which have to be computed in order 
      to get correct values. This is normally stored in your /etc/sensors.conf.
!     Search in the corresponding section for your chipset, and search the 
      compute statement, e.g. "compute temp3 @*2, @/2". Only the third
!     argument is of interest. Insert this into the plugin activation line, e.g.: 
      "[...] args=(('temp3','@*2'),[...]". The @ stands for the raw value.
      The compute expression  works for the cpu- and casesensor.
--- 210,218 ----
      This requires a properly configure lm_sensors! If the standard sensors frontend
      delivered with lm_sensors works your OK.
!     Some sensors return raw-values, which have to be computed in order
      to get correct values. This is normally stored in your /etc/sensors.conf.
!     Search in the corresponding section for your chipset, and search the
      compute statement, e.g. "compute temp3 @*2, @/2". Only the third
!     argument is of interest. Insert this into the plugin activation line, e.g.:
      "[...] args=(('temp3','@*2'),[...]". The @ stands for the raw value.
      The compute expression  works for the cpu- and casesensor.
***************
*** 219,223 ****
              self.hotstack = hotstack
              self.washot = False
!             
          def temp(self):
              def temp_compute (rawvalue):
--- 231,235 ----
              self.hotstack = hotstack
              self.washot = False
! 
          def temp(self):
              def temp_compute (rawvalue):
***************
*** 230,235 ****
  
              if self.senspath == -1 or not self.senspath:
!                 return "?"        
!             
              if self.k6 :
                  file = os.path.join( self.senspath, 'temp_input' + self.sensor[-1] )
--- 242,247 ----
  
              if self.senspath == -1 or not self.senspath:
!                 return "?"
! 
              if self.k6 :
                  file = os.path.join( self.senspath, 'temp_input' + self.sensor[-1] )
***************
*** 241,260 ****
                  hotdata = f.read()
                  f.close()
!             
              else:
                  file = os.path.join( self.senspath, self.sensor )
!             
              f = open(file)
              data = f.read()
              f.close()
!             
              if self.k6:
                  temp = int(temp_compute(float(data[0:2])))
                  hot = int(temp_compute(float(hotdata[0:2])))
!                 
              else:
                  temp = int(temp_compute (float(string.split(data)[2])))
                  hot = int(temp_compute (float(string.split(data)[0])))
!             
              if temp > hot:
                  if self.washot == False:
--- 253,272 ----
                  hotdata = f.read()
                  f.close()
! 
              else:
                  file = os.path.join( self.senspath, self.sensor )
! 
              f = open(file)
              data = f.read()
              f.close()
! 
              if self.k6:
                  temp = int(temp_compute(float(data[0:2])))
                  hot = int(temp_compute(float(hotdata[0:2])))
! 
              else:
                  temp = int(temp_compute (float(string.split(data)[2])))
                  hot = int(temp_compute (float(string.split(data)[0])))
! 
              if temp > hot:
                  if self.washot == False:
***************
*** 265,271 ****
                      self.hotstack = self.hotstack - 1
                      self.washot = False
!                 
              return "%s�" % temp
!             
          def getSensorPath(self):
              #let's try if we find a sys filesystem (and kernel2.6 style sensors)
--- 277,283 ----
                      self.hotstack = self.hotstack - 1
                      self.washot = False
! 
              return "%s�" % temp
! 
          def getSensorPath(self):
              #let's try if we find a sys filesystem (and kernel2.6 style sensors)
***************
*** 280,284 ****
                          if pos_sensors == "temp1_input":
                              return testpath
!                             
              if not os.path.exists(self.initpath):
                  if self.k6:
--- 292,296 ----
                          if pos_sensors == "temp1_input":
                              return testpath
! 
              if not os.path.exists(self.initpath):
                  if self.k6:
***************
*** 291,317 ****
                      print "temperatures will be bogus"
                  return -1 #failure
!                 
              for senspath in os.listdir(self.initpath):
                  testpath = os.path.join(self.initpath , senspath)
!                 if os.path.isdir(testpath): 
                      return testpath
-                     
-     
-     
-     def __init__(self, cpu='temp3', case='temp2' , ram='MemTotal'):
-         self.reason = 'draw() function needs update to work with new interface'
-         return
  
          IdleBarPlugin.__init__(self)
!         
          self.hotstack = 0
          self.case = None
!     
          if isinstance (cpu,types.StringType):
              self.cpu = self.sensor(cpu, '@', self.hotstack)
          else:
              self.cpu = self.sensor(cpu[0], cpu[1], self.hotstack)
!     
!         if case: 
              if isinstance (case,types.StringType):
                  self.case = self.sensor(case, '@', self.hotstack)
--- 303,326 ----
                      print "temperatures will be bogus"
                  return -1 #failure
! 
              for senspath in os.listdir(self.initpath):
                  testpath = os.path.join(self.initpath , senspath)
!                 if os.path.isdir(testpath):
                      return testpath
  
+ 
+ 
+     def __init__(self, cpu='temp3', case='temp2' , ram='MemTotal'):
          IdleBarPlugin.__init__(self)
! 
          self.hotstack = 0
          self.case = None
! 
          if isinstance (cpu,types.StringType):
              self.cpu = self.sensor(cpu, '@', self.hotstack)
          else:
              self.cpu = self.sensor(cpu[0], cpu[1], self.hotstack)
! 
!         if case:
              if isinstance (case,types.StringType):
                  self.case = self.sensor(case, '@', self.hotstack)
***************
*** 323,327 ****
          self.retwidth = 0
  
!         
      def getRamStat(self):
  
--- 332,336 ----
          self.retwidth = 0
  
! 
      def getRamStat(self):
  
***************
*** 330,368 ****
          f.close()
          rxp_ram = re.compile('^%s' % self.ram)
!         
          for line in data.split("\n"):
              m = rxp_ram.match(line)
              if m :
                  return "%sM" % (int(string.split(line)[1])/1024)
!         
!     
!     def draw(self, (type, object), x, osd):
          casetemp = None
          widthcase = 0
          widthram  = 0
  
!         font  = osd.get_font('small0')
          if self.hotstack != 0:
              font.color = 0xff0000
          elif font.color == 0xff0000 and self.hotstack == 0:
              font.color = 0xffffff
!         
!         cputemp = self.cpu.temp()        
          widthcpu = font.stringsize(cputemp)
!         osd.drawimage(os.path.join(config.ICON_DIR, 'misc/cpu.png'),
!                        (x, osd.y + 8, -1, -1))
!         osd.drawstring(cputemp, font, None, x + 15, osd.y + 55 - font.h, widthcpu, 
font.h,
!                        'left', 'top')
          widthcpu = max(widthcpu, 32) + 10
  
          if self.case:
              casetemp = self.case.temp()
-             
              widthcase = font.stringsize(casetemp)
!             osd.drawimage(os.path.join(config.ICON_DIR, 'misc/case.png'),
!                                         (x + 15 + widthcpu, osd.y + 7, -1, -1))
!             osd.drawstring(casetemp, font, None, x + 40 + widthcpu,
!                            osd.y + 55 - font.h, widthcase, font.h,
!                            'left', 'top')
              widthcase = max(widthcase, 32) + 10
  
--- 339,384 ----
          f.close()
          rxp_ram = re.compile('^%s' % self.ram)
! 
          for line in data.split("\n"):
              m = rxp_ram.match(line)
              if m :
                  return "%sM" % (int(string.split(line)[1])/1024)
! 
! 
!     def draw(self, width, height):
!         self.clear()
          casetemp = None
          widthcase = 0
          widthram  = 0
  
!         font  = gui.get_font('small0')
          if self.hotstack != 0:
              font.color = 0xff0000
          elif font.color == 0xff0000 and self.hotstack == 0:
              font.color = 0xffffff
! 
!         cputemp = self.cpu.temp()
          widthcpu = font.stringsize(cputemp)
! 
!         i = gui.imagelib.load(os.path.join(config.ICON_DIR, 'misc','cpu.png'), 
(None, None))
!         self.objects.append(gui.Image(i, (0, 8)))
! 
!         t = gui.Text(cputemp, (15, 55-font.height),
!                      (widthcpu, font.height), font, 'left', 'top')
!         self.objects.append(t)
! 
          widthcpu = max(widthcpu, 32) + 10
  
          if self.case:
              casetemp = self.case.temp()
              widthcase = font.stringsize(casetemp)
! 
!             i = gui.imagelib.load(os.path.join(config.ICON_DIR, 'misc','case.png'), 
(None, None))
!             self.objects.append(gui.Image(i, (15 + widthcpu, 7)))
! 
!             t = gui.Text(casetemp, (40+widthcpu, 55-font.height),
!                         (widthcase, font.height), font, 'left', 'top')
!             self.objects.append(t)
! 
              widthcase = max(widthcase, 32) + 10
  
***************
*** 371,388 ****
              widthram = font.stringsize(text)
              if casetemp:
!                 img_width = x + 15 + widthcpu + widthcase + 15
              else:
!                 img_width = x + 15 + widthcpu
!             osd.drawimage(os.path.join(config.ICON_DIR, 'misc/memory.png'),
!                            (img_width, osd.y + 7, -1, -1))
!             osd.drawstring(text, font, None, img_width + 15, osd.y + 55 - font.h,
!                            widthram, font.h, 'left', 'top')
!                        
          if self.retwidth == 0:
              self.retwidth = widthcpu + 15
!             if self.case: 
                  self.retwidth = self.retwidth + widthcase + 12
              if self.ram:
                  self.retwidth = self.retwidth + 15 + widthram
!                 
          return self.retwidth
--- 387,407 ----
              widthram = font.stringsize(text)
              if casetemp:
!                 img_width = 15 + widthcpu + widthcase + 15
              else:
!                 img_width = 15 + widthcpu
! 
!             i = gui.imagelib.load(os.path.join(config.ICON_DIR, 
'misc','memory.png'), (None, None))
!             self.objects.append(gui.Image(i, (img_width, 7)))
! 
!             t = gui.Text(casetemp, (img_width+15, 55-font.height),
!                         (widthram, font.height), font, 'left', 'top')
! 
! 
          if self.retwidth == 0:
              self.retwidth = widthcpu + 15
!             if self.case:
                  self.retwidth = self.retwidth + widthcase + 12
              if self.ram:
                  self.retwidth = self.retwidth + 15 + widthram
! 
          return self.retwidth



-------------------------------------------------------
This SF.Net email is sponsored by BEA Weblogic Workshop
FREE Java Enterprise J2EE developer tools!
Get your free copy of BEA WebLogic Workshop 8.1 today.
http://ads.osdn.com/?ad_id=5047&alloc_id=10808&op=click
_______________________________________________
Freevo-cvslog mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog

Reply via email to