Author: dmeyer
Date: Sun Jan 29 20:25:02 2006
New Revision: 7902

Added:
   trunk/apps/bin/freevo-daemon   (contents, props changed)
      - copied, changed from r7899, /trunk/ui/src/helpers/daemon.py
Removed:
   trunk/ui/src/helpers/daemon.py

Log:
move daemon helper to app

Copied: trunk/apps/bin/freevo-daemon (from r7899, 
/trunk/ui/src/helpers/daemon.py)
==============================================================================
--- /trunk/ui/src/helpers/daemon.py     (original)
+++ trunk/apps/bin/freevo-daemon        Sun Jan 29 20:25:02 2006
@@ -1,25 +1,17 @@
-#!/usr/bin/env python
+#! /usr/bin/python
 # -*- coding: iso-8859-1 -*-
-# -----------------------------------------------------------------------
-# daemon.py - helper script to start freevo on keypress
-# -----------------------------------------------------------------------
+# -----------------------------------------------------------------------------
+# freevo-daemon.py - application to start freevo on keypress
+# -----------------------------------------------------------------------------
 # $Id$
 #
-# Notes:
-#
-# Todo:        
-#
-# -----------------------------------------------------------------------
-# $Log$
-# Revision 1.3  2004/07/10 12:33:39  dischi
-# header cleanup
+# -----------------------------------------------------------------------------
+# Freevo - A Home Theater PC framework
+# Copyright (C) 2002-2005 Krister Lagerstrom, Dirk Meyer, et al.
 #
-# Revision 1.2  2004/02/28 18:02:19  dischi
-# do not eat the cpu
+# First Edition: Dirk Meyer <[EMAIL PROTECTED]>
+# Maintainer:    Dirk Meyer <[EMAIL PROTECTED]>
 #
-# -----------------------------------------------------------------------
-# Freevo - A Home Theater PC framework
-# Copyright (C) 2002-2005 Krister Lagerstrom, Dirk Meyer, et al. 
 # Please see the file doc/CREDITS for a complete list of authors.
 #
 # This program is free software; you can redistribute it and/or modify
@@ -36,44 +28,72 @@
 # with this program; if not, write to the Free Software Foundation, Inc.,
 # 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 #
-# ----------------------------------------------------------------------- */
-
+# -----------------------------------------------------------------------------
 
+# python imports
 import os
 import sys
-import config
 import pylirc
 import time
 
+
+# insert freevo path information
+__site__ = '../lib/python%s.%s/site-packages' % sys.version_info[:2]
+__site__ = os.path.normpath(os.path.join(os.path.dirname(__file__), __site__))
+if not __site__ in sys.path:
+    sys.path.insert(0, __site__)
+
+# freevo core imports
+from freevo.conf import Config, Var
+
+# config object for this application
+config = Config(app='daemon', desc=_('daemon configuration'), schema=[
+
+    Var(name='options', default='',
+        desc=_('Options for Freevo, e.g. -fs to start X')),
+
+    Var(name='lircrc', default='/etc/freevo/lircrc',
+        desc=_('lircrc file'))
+
+    ])
+
+
 def start():
+    """
+    Start lirc watching
+    """
     try:
-        pylirc.init('freevo', config.LIRCRC)
+        pylirc.init('freevo', config.lircrc)
         pylirc.blocking(1)
     except RuntimeError:
         print 'WARNING: Could not initialize PyLirc!'
         sys.exit(0)
     except IOError:
-        print 'WARNING: %s not found!' % config.LIRCRC
+        print 'WARNING: %s not found!' % config.lircrc
         sys.exit(0)
 
+
 def stop():
+    """
+    Stop lirc while Freevo is running.
+    """
     pylirc.exit()
 
 
-
-if __name__ == "__main__":
-    if len(sys.argv)>1 and sys.argv[1] == '--help':
-        print 'Freevo helper script to start Freevo on lirc command.'
-        print 'Everytime Freevo is not running and EXIT or POWER is pressed,'
-        print 'this script will start Freevo. If the display in freevo.conf'
-        print 'is x11 or dga, this script will start Freevo in a new'
-        print 'X session.'
-        print 'usage: freevo daemon [ start | stop ]'
-        sys.exit(0)
+if len(sys.argv)>1 and sys.argv[1] == '--help':
+    print 'Freevo helper script to start Freevo on lirc command.'
+    print 'Everytime Freevo is not running and EXIT or POWER is pressed,'
+    print 'this script will start Freevo. If the display in freevo.conf'
+    print 'is x11 or dga, this script will start Freevo in a new'
+    print 'X session.'
+    print 'usage: freevo-daemon [ start | stop ]'
+    sys.exit(0)
 
         
-script = os.path.join(os.path.dirname(__file__), 
'../../../../../../bin/freevo')
-script = os.path.normpath(script)
+script = os.path.join(os.path.dirname(__file__), 'freevo')
+
+config.load()
+config.save()
 
 start()
 
@@ -82,11 +102,5 @@
     code = pylirc.nextcode();
     if code and code[0] in ( 'EXIT', 'POWER' ):
         stop()
-        if config.CONF.display in ( 'x11', 'dga' ):
-            options = '-fs'
-        else:
-            options = ''
-            
-        os.system('%s %s >/dev/null 2>/dev/null' % (script, options))
+        os.system('%s %s >/dev/null 2>/dev/null' % (script, config.options))
         start()
-        


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog

Reply via email to