Update of /cvsroot/freevo/freevo/WIP/RobShortt
In directory sc8-pr-cvs1:/tmp/cvs-serv10463

Modified Files:
        Plugins.py main.py-plugins 
Log Message:
More work on a plugin interface.  I have also brought in Dischi's
video / audio / images / games plugin support.


Index: Plugins.py
===================================================================
RCS file: /cvsroot/freevo/freevo/WIP/RobShortt/Plugins.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** Plugins.py  23 Feb 2003 18:19:43 -0000      1.2
--- Plugins.py  26 Feb 2003 23:59:47 -0000      1.3
***************
*** 4,8 ****
  
  
! class PluginMaster:
  
      def __init__(self):
--- 4,8 ----
  
  
! class Plugins:
  
      def __init__(self):
***************
*** 40,46 ****
  
  
      def init_plugins(self):
  
!         print 'PluginMaster:  Initializing plugins.'
  
          for plugin in self.plugins.values():
--- 40,65 ----
  
  
+         # Next we load the standard video/audio/image/games plugins.
+         for t in ('video', 'audio', 'image', 'games'):
+             config.FREEVO_PLUGINS[t] = []
+             dirname = 'src/%s/plugins' % t
+             if os.path.isdir(dirname):
+                 for plugin in [ os.path.splitext(fname)[0] for fname in 
os.listdir(dirname)
+                                 if os.path.isfile(os.path.join(dirname, fname))\
+                                 and os.path.splitext(fname)[1].lower()[1:] == 'py' \
+                                 and not fname == '__init__.py']:
+                     try:
+                         exec('import %s.plugins.%s' % (t, plugin))
+                         if hasattr(eval('%s.plugins.%s'  % (t, plugin)), 'actions'):
+                             print 'Plugin %s/%s loaded.' % (t, plugin)
+                         config.FREEVO_PLUGINS[t] += [ eval('%s.plugins.%s.actions'\
+                                                        % (t, plugin)) ]
+                     except:
+                         traceback.print_exc()
+ 
+ 
      def init_plugins(self):
  
!         print 'Plugins:  Initializing plugins.'
  
          for plugin in self.plugins.values():
***************
*** 63,82 ****
--- 82,111 ----
  
      def init(self):
+         # Called by Plugins.init_plugins()
+         # All plugins need to override this.
          pass
  
  
      def start(self):
+         # Can be overriden for some control over plugins
+         # which spawn a thread.
          pass
  
  
      def stop(self):
+         # Can be overriden for some control over plugins
+         # which spawn a thread.
          pass
  
  
      def run(self):
+         # Can be overriden for some control over plugins
+         # which spawn a thread.
          pass
  
  
      def update(self):
+         # Some graphical plugins may need to update their
+         # display over a set amount of time
          pass
  

Index: main.py-plugins
===================================================================
RCS file: /cvsroot/freevo/freevo/WIP/RobShortt/main.py-plugins,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** main.py-plugins     20 Feb 2003 01:03:13 -0000      1.2
--- main.py-plugins     26 Feb 2003 23:59:47 -0000      1.3
***************
*** 10,15 ****
  # -----------------------------------------------------------------------
  # $Log$
! # Revision 1.2  2003/02/20 01:03:13  rshortt
! # Updating this to the current main.py so that it actually works.
  #
  # Revision 1.16  2003/02/19 08:08:30  krister
--- 10,44 ----
  # -----------------------------------------------------------------------
  # $Log$
! # Revision 1.3  2003/02/26 23:59:47  rshortt
! # More work on a plugin interface.  I have also brought in Dischi's
! # video / audio / images / games plugin support.
! #
! # Revision 1.24  2003/02/24 04:03:25  krister
! # Added a --trace option to see all function calls in freevo.
! #
! # Revision 1.23  2003/02/22 22:32:27  krister
! # Removed debug code, cleanup
! #
! # Revision 1.22  2003/02/22 07:13:19  krister
! # Set all sub threads to daemons so that they die automatically if the main thread 
dies.
! #
! # Revision 1.21  2003/02/21 18:43:50  outlyer
! # Fixed the spelling from Enablind to Enabled :) Also commented out the
! # code Krister added to prove a point. Consider it proven...
! #
! # I should mention that the idle tool does work fine on other skins, especially
! # since it has no configuration information elsewhere.
! #
! # Revision 1.20  2003/02/21 16:25:10  dischi
! # main items can have images
! #
! # Revision 1.19  2003/02/21 06:51:15  krister
! # XXX Debug the event loop, remove later.
! #
! # Revision 1.18  2003/02/21 05:26:59  krister
! # Enable the IdleTool if Aubins skin is used.
! #
! # Revision 1.17  2003/02/20 20:14:44  dischi
! # needed for a new gentoo runtime with pylirc
  #
  # Revision 1.16  2003/02/19 08:08:30  krister
***************
*** 112,115 ****
--- 141,148 ----
  sys.path.append('.')
  
+ # Gentoo runtime has some python files in runtime/python
+ if os.path.exists('./runtime/python'):
+     sys.path.append('./runtime/python')
+     
  import config
  
***************
*** 130,135 ****
  from item import Item
  
! from Plugins import PluginMaster
! plugin_master = None
  
  
--- 163,168 ----
  from item import Item
  
! from Plugins import Plugins
! plugins = None
  
  
***************
*** 281,285 ****
  #
  def getcmd():
!     global plugin_master
      items = []
  
--- 314,318 ----
  #
  def getcmd():
!     global plugins
      items = []
  
***************
*** 305,309 ****
                                          menu_items[i].arg, eventhandler,
                                          None, 'main', menu_items[i].icon)]
! 
      
      mainmenu = menu.Menu('FREEVO MAIN MENU', items, packrows=0, umount_all = 1)
--- 338,343 ----
                                          menu_items[i].arg, eventhandler,
                                          None, 'main', menu_items[i].icon)]
!                 if menu_items[i].image:
!                     items[-1].setImage(('image', menu_items[i].image))
      
      mainmenu = menu.Menu('FREEVO MAIN MENU', items, packrows=0, umount_all = 1)
***************
*** 313,319 ****
      muted = 0
      mainVolume = 0 # XXX We are using this for PcmVolume as well.
!     
!     #m = idle.IdleTool()
!     #m.refresh()
      while 1:
          
--- 347,358 ----
      muted = 0
      mainVolume = 0 # XXX We are using this for PcmVolume as well.
! 
!     # XXX TEST CODE
!     if config.SKIN_XML_FILE.find('aubin_round') != -1:
!         print 'Enabled the IdleTool'
!         m = idle.IdleTool()
!     else:
!         m = None
!     m and m.refresh()
      while 1:
          
***************
*** 322,333 ****
  
              event = osd._cb()
!             if event: break
              event = rc.poll()
!             if event: break
!             #if not rc.app: m.poll()
              time.sleep(0.1)
  
! 
!         #m.refresh()
          # Handle volume control   XXX move to the skin
          if event == rc.VOLUP:
--- 361,374 ----
  
              event = osd._cb()
!             if event:
!                 break
              event = rc.poll()
!             if event:
!                 break
!             if not rc.app:
!                 m and m.poll()
              time.sleep(0.1)
  
!         m and m.refresh()
          # Handle volume control   XXX move to the skin
          if event == rc.VOLUP:
***************
*** 467,471 ****
  #
  def main_func():
!     global plugin_master
  
      # Add the drives to the config.removable_media list. There doesn't have
--- 508,512 ----
  #
  def main_func():
!     global plugins
  
      # Add the drives to the config.removable_media list. There doesn't have
***************
*** 491,515 ****
      global im_thread
      im_thread = identifymedia.Identify_Thread()
      im_thread.start()
      
-     plugin_master = PluginMaster()
- 
      # scan for plugins
!     for t in ('video', 'audio', 'image', 'games'):
!         config.FREEVO_PLUGINS[t] = []
!         dirname = 'src/%s/plugins' % t
!         if os.path.isdir(dirname):
!             for plugin in [ os.path.splitext(fname)[0] for fname in 
os.listdir(dirname)
!                             if os.path.isfile(os.path.join(dirname, fname))\
!                             and os.path.splitext(fname)[1].lower()[1:] == 'py' \
!                             and not fname == '__init__.py']:
!                 try:
!                     exec('import %s.plugins.%s' % (t, plugin))
!                     if hasattr(eval('%s.plugins.%s'  % (t, plugin)), 'actions'):
!                         print 'load %s plugin %s ' % (t, plugin)
!                     config.FREEVO_PLUGINS[t] += [ eval('%s.plugins.%s.actions'\
!                                                        % (t, plugin)) ]
!                 except:
!                     traceback.print_exc()
  
      # Kick off the main menu loop
--- 532,540 ----
      global im_thread
      im_thread = identifymedia.Identify_Thread()
+     im_thread.setDaemon(1)
      im_thread.start()
      
      # scan for plugins
!     plugins = Plugins()
  
      # Kick off the main menu loop
***************
*** 522,525 ****
--- 547,576 ----
  #
  if __name__ == "__main__":
+     def tracefunc(frame, event, arg, _indent=[0]):
+         if event == 'call':
+             filename = frame.f_code.co_filename
+             funcname = frame.f_code.co_name
+             lineno = frame.f_code.co_firstlineno
+             if 'self' in frame.f_locals:
+                 try:
+                     classinst = frame.f_locals['self']
+                     classname = repr(classinst).split()[0].split('(')[0][1:]
+                     funcname = '%s.%s' % (classname, funcname)
+                 except:
+                     pass
+             here = '%s:%s:%s()' % (filename, lineno, funcname)
+             _indent[0] += 1
+             tracefd.write('%4s %s%s\n' % (_indent[0], ' ' * _indent[0], here))
+             tracefd.flush()
+         elif event == 'return':
+             _indent[0] -= 1
+ 
+         return tracefunc
+ 
+     if len(sys.argv) >= 2 and sys.argv[1] == '--trace':
+         tracefd = open(os.path.join(os.environ['FREEVO_STARTDIR'],
+                                     'trace.txt'), 'w')
+         sys.settrace(tracefunc)
+     
      try:
          main_func()




-------------------------------------------------------
This SF.net email is sponsored by: Scholarships for Techies!
Can't afford IT training? All 2003 ictp students receive scholarships.
Get hands-on training in Microsoft, Cisco, Sun, Linux/UNIX, and more.
www.ictp.com/training/sourceforge.asp
_______________________________________________
Freevo-cvslog mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog

Reply via email to