Author: duncan
Date: Thu Oct 19 16:56:04 2006
New Revision: 8425
Modified:
branches/rel-1/freevo/src/helpers/recordserver.py
branches/rel-1/freevo/src/helpers/webserver.py
branches/rel-1/freevo/src/plugins/freevo-rendezvous.py
branches/rel-1/freevo/src/tv/record_client.py
Log:
[ 1580628 ] Change debugging in recordserver, etc
Changes applied
Modified: branches/rel-1/freevo/src/helpers/recordserver.py
==============================================================================
--- branches/rel-1/freevo/src/helpers/recordserver.py (original)
+++ branches/rel-1/freevo/src/helpers/recordserver.py Thu Oct 19 16:56:04 2006
@@ -31,12 +31,17 @@
import config
from util import vfs
+appname = os.path.splitext(os.path.basename(sys.argv[0]))[0]
+appconf = appname.upper()
+
# change uid
if __name__ == '__main__':
+ uid='config.'+appconf+'_UID'
+ gid='config.'+appconf+'_GID'
try:
- if config.TV_RECORD_SERVER_UID and os.getuid() == 0:
- os.setgid(config.TV_RECORD_SERVER_GID)
- os.setuid(config.TV_RECORD_SERVER_UID)
+ if eval(uid) and os.getuid() == 0:
+ os.setgid(eval(gid))
+ os.setuid(eval(uid))
os.environ['USER'] = pwd.getpwuid(os.getuid())[0]
os.environ['HOME'] = pwd.getpwuid(os.getuid())[5]
except Exception, e:
@@ -46,7 +51,6 @@
from twisted.internet.app import Application
from twisted.internet import reactor
from twisted.python import log
-
from util.marmalade import jellyToXML, unjellyFromXML
import rc
@@ -64,21 +68,20 @@
from util.videothumb import snapshot
from event import *
-dbglvl=1
+DEBUG = hasattr(config, appconf+'_DEBUG') and eval('config.'+appconf+'_DEBUG')
or config.DEBUG
+
+logfile = '%s/%s-%s.log' % (config.LOGDIR, appname, os.getuid())
+log.startLogging(open(logfile, 'a'))
def _debug_(text, level=1):
- if config.DEBUG >= level:
+ if DEBUG >= level:
try:
log.debug(String(text))
except:
- log.debug('Failed to log a message')
+ print String(text)
_debug_('PLUGIN_RECORD: %s' % config.plugin_record)
-appname = os.path.splitext(os.path.basename(sys.argv[0]))[0]
-logfile = '%s/%s-%s.log' % (config.LOGDIR, appname, os.getuid())
-log.startLogging(open(logfile, 'a'))
-
plugin.init_special_plugin(config.plugin_record)
if config.TV_RECORD_PADDING_PRE == None:
@@ -118,8 +121,14 @@
pass
return 0
+
+ def isRecording(self):
+ _debug_('in isRecording', 4)
+ return glob.glob(config.FREEVO_CACHEDIR + '/record.*') and True or
False
+
+
def findNextProgram(self):
- _debug_('in findNextProgram', dbglvl+3)
+ _debug_('in findNextProgram', 4)
progs = self.getScheduledRecordings().getProgramList()
now = time.time()
@@ -129,7 +138,7 @@
proglist.sort(self.progsTimeCompare)
for progitem in proglist:
prog = progs[progitem]
- _debug_('%s' % (prog), dbglvl+1)
+ _debug_('%s' % (prog), 2)
try:
recording = prog.isRecording
@@ -139,9 +148,9 @@
if now >= prog.stop + config.TV_RECORD_PADDING_POST:
_debug_('%s: prog.stop=%s, now=%s' % (prog.title, \
- time.localtime(prog.stop+config.TV_RECORD_PADDING_POST),
now), dbglvl+1)
+ time.localtime(prog.stop+config.TV_RECORD_PADDING_POST),
now), 2)
continue
- _debug_('%s: prog.stop=%s' % (prog.title,
time.localtime(prog.stop)), dbglvl)
+ _debug_('%s: prog.stop=%s' % (prog.title,
time.localtime(prog.stop)), 1)
if not recording:
next_program = prog
@@ -149,10 +158,10 @@
self.next_program = next_program
if next_program == None:
- _debug_('No program scheduled to record', dbglvl)
+ _debug_('No program scheduled to record', 1)
return None
- _debug_('%s' % (next_program), dbglvl)
+ _debug_('%s' % (next_program), 1)
return next_program
@@ -163,7 +172,7 @@
real player running test, check /dev/videoX.
this could go into the upsoon client
'''
- _debug_('in isPlayerRunning', dbglvl+3)
+ _debug_('in isPlayerRunning', 4)
return (os.path.exists(config.FREEVO_CACHEDIR + '/playing'))
# note: add locking and r/rw options to get/save funs
@@ -740,6 +749,11 @@
message = status and 'player is running' or 'player is not running'
return (status, message)
+ def xmlrpc_isRecording(self):
+ status = self.isRecording()
+ message = status and 'is recording' or 'is not recording'
+ return (status, message)
+
def xmlrpc_findNextProgram(self):
response = self.findNextProgram()
status = response != None
@@ -1033,9 +1047,9 @@
app = Application("RecordServer")
rs = RecordServer()
if (config.DEBUG == 0):
- app.listenTCP(config.TV_RECORD_SERVER_PORT, server.Site(rs,
logPath='/dev/null'))
+ app.listenTCP(config.RECORDSERVER_PORT, server.Site(rs,
logPath='/dev/null'))
else:
- app.listenTCP(config.TV_RECORD_SERVER_PORT, server.Site(rs))
+ app.listenTCP(config.RECORDSERVER_PORT, server.Site(rs))
rs.startMinuteCheck()
rc_object.subscribe(rs.eventNotice)
app.run(save=0)
Modified: branches/rel-1/freevo/src/helpers/webserver.py
==============================================================================
--- branches/rel-1/freevo/src/helpers/webserver.py (original)
+++ branches/rel-1/freevo/src/helpers/webserver.py Thu Oct 19 16:56:04 2006
@@ -10,17 +10,6 @@
# Todo:
#
# -----------------------------------------------------------------------
-# $Log$
-# Revision 1.11 2004/07/10 12:33:39 dischi
-# header cleanup
-#
-# Revision 1.10 2004/07/09 16:20:54 outlyer
-# Remove the request logging for 0-level debug. Exceptions will still be
-# logged, but standard requests will not.
-#
-# (i.e. this removes the Apache-style access logging for DEBUG = 0)
-#
-# -----------------------------------------------------------------------
# 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.
@@ -39,21 +28,25 @@
# with this program; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
-# ----------------------------------------------------------------------- */
+# -----------------------------------------------------------------------
import sys, os
import config
+appname = os.path.splitext(os.path.basename(sys.argv[0]))[0]
+appconf = appname.upper()
+
# change uid
if __name__ == '__main__':
+ uid='config.'+appconf+'_UID'
+ gid='config.'+appconf+'_GID'
try:
- if hasattr(config, 'WWW_SERVER_UID'):
- if config.WWW_SERVER_UID and os.getuid() == 0:
- os.setgid(config.WWW_SERVER_GID)
- os.setuid(config.WWW_SERVER_UID)
- os.environ['USER'] = pwd.getpwuid(os.getuid())[0]
- os.environ['HOME'] = pwd.getpwuid(os.getuid())[5]
+ if eval(uid) and os.getuid() == 0:
+ os.setgid(eval(gid))
+ os.setuid(eval(uid))
+ os.environ['USER'] = pwd.getpwuid(os.getuid())[0]
+ os.environ['HOME'] = pwd.getpwuid(os.getuid())[5]
except Exception, e:
print e
@@ -68,6 +61,16 @@
print 'usage freevo webserver [ start | stop ]'
sys.exit(0)
+# No debugging in this module
+DEBUG = hasattr(config, appconf+'_DEBUG') and eval('config.'+appconf+'_DEBUG')
or config.DEBUG
+
+def _debug_(text, level=1):
+ if DEBUG >= level:
+ try:
+ log.debug(String(text))
+ except:
+ print String(text)
+
def helpimagesrewrite(request):
if request.postpath and request.postpath[0]=='help' and
request.postpath[1]=='images':
request.postpath.pop(0)
@@ -98,7 +101,7 @@
site = server.Site(rewriter)
application = app.Application('web')
- application.listenTCP(config.WWW_PORT, site)
+ application.listenTCP(config.WEBSERVER_PORT, site)
application.run(save=0)
Modified: branches/rel-1/freevo/src/plugins/freevo-rendezvous.py
==============================================================================
--- branches/rel-1/freevo/src/plugins/freevo-rendezvous.py (original)
+++ branches/rel-1/freevo/src/plugins/freevo-rendezvous.py Thu Oct 19
16:56:04 2006
@@ -8,11 +8,6 @@
# Todo:
#
# -----------------------------------------------------------------------
-# $Log$
-# Revision 1.3 2004/07/10 12:33:40 dischi
-# header cleanup
-#
-# -----------------------------------------------------------------------
# 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.
@@ -31,7 +26,7 @@
# with this program; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
-# ----------------------------------------------------------------------- */
+# -----------------------------------------------------------------------
import socket
@@ -62,7 +57,7 @@
desc = {'version':__version__}
myip = self.my_ipaddr('localhost')
info = Rendezvous.ServiceInfo("_http._tcp.local.", "Freevo
Web._http._tcp.local.", address=socket.inet_aton(myip),
- port=config.WWW_PORT, weight=0, priority=0, properties=desc,
server=socket.gethostname)
+ port=config.WEBSERVER_PORT, weight=0, priority=0, properties=desc,
server=socket.gethostname)
r.registerService(info)
def my_ipaddr(self,interface_hostname=None):
Modified: branches/rel-1/freevo/src/tv/record_client.py
==============================================================================
--- branches/rel-1/freevo/src/tv/record_client.py (original)
+++ branches/rel-1/freevo/src/tv/record_client.py Thu Oct 19 16:56:04 2006
@@ -8,20 +8,6 @@
# Todo:
#
# -----------------------------------------------------------------------
-# $Log$
-# Revision 1.20 2004/07/19 16:24:47 rshortt
-# Attempt to solve scheduled recordings upgrade problem.
-#
-# Revision 1.19 2004/07/10 12:33:41 dischi
-# header cleanup
-#
-# Revision 1.18 2004/03/13 20:11:36 rshortt
-# Some quick debug for addEditedFavorite()
-#
-# Revision 1.17 2004/03/13 18:31:51 rshortt
-# Lets see traceback and exception. We should clean this file up further.
-#
-# -----------------------------------------------------------------------
# Freevo - A Home Theater PC framework
# Copyright (C) 2003 Krister Lagerstrom, et al.
# Please see the file freevo/Docs/CREDITS for a complete list of authors.
@@ -40,7 +26,7 @@
# with this program; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
-# ----------------------------------------------------------------------- */
+# -----------------------------------------------------------------------
import config
@@ -55,7 +41,7 @@
FALSE = 0
server_string = 'http://%s:%s/' % \
- (config.TV_RECORD_SERVER_IP, config.TV_RECORD_SERVER_PORT)
+ (config.RECORDSERVER_IP, config.RECORDSERVER_PORT)
server = xmlrpclib.Server(server_string, allow_none=1)
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog