/usr/share/pyshared/freevo/video/commdetectclient.py is in python-freevo 1.9.2b2-4.2.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 | #! /usr/bin/python
# -*- coding: iso-8859-1 -*-
# -----------------------------------------------------------------------
# A client interface to the commercial detecting server.
# -----------------------------------------------------------------------
# $Id: commdetectclient.py 11905 2011-11-14 21:54:46Z adam $
#
# Author: Justin Wetherell
#
# Notes: some parts taken or inspired by Freevo's encodingserver
# Todo:
#
# -----------------------------------------------------------------------
# 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.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MER-
# CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# -----------------------------------------------------------------------
"""
A client interface to the commercial detecting server.
"""
import logging
logger = logging.getLogger("freevo.video.commdetectclient")
import xmlrpclib, sys
from util.marmalade import jellyToXML, unjellyFromXML
import config
server_string = 'http://%s:%s/' % \
(config.COMMDETECTSERVER_IP, config.COMMDETECTSERVER_PORT)
server = xmlrpclib.Server(server_string, allow_none=1)
#server = object() - uncomment this and comment the previous line to enable pychecker testing
jam = jellyToXML
unjam = unjellyFromXML
def returnFromJelly(status, response):
"""Un-serialize CommDetectServer responses"""
if status:
return (status, unjam(response))
else:
return (status, response)
def connectionTest(teststr='testing'):
"""
Test connectivity
Returns false if the CommDetectServer cannot be reached
"""
try:
(status, response) = server.echotest(teststr)
except:
return (False, 'CommDetectClient: connection error')
return (status, response)
def initCommDetectJob(source):
"""Initialize the commdetectjob."""
_debug_('initCommDetectJob(%s)' % (source))
if not (source):
return (False, "CommDetectClient: no source")
try:
(status, response) = server.initCommDetectJob(source)
except:
print "Unexpected error:", sys.exc_info()[0]
raise
return (False, 'CommDetectClient: connection error')
return (status, response)
def queueIt(idnr, now=False):
"""
Insert the current job in the commdetectqueue
If now is true, the commdetect queue is automatically started
"""
if not idnr:
return (False, "CommDetectClient: no idnr")
try:
(status, response) = server.queueIt(idnr, now)
except:
return (False, 'CommDetectClient: connection error')
return (status, response)
def startQueue():
"""Start the commdetect queue"""
try:
(status, response) = server.startQueue()
except:
return (False, 'CommDetectClient: connection error')
return (status, response)
def listJobs():
"""
Get a list with all jobs in the commdetect queue and their current state
"""
try:
(status, response) = server.listJobs()
except:
return (False, 'CommDetectClient: connection error')
return returnFromJelly(status, response)
if __name__ == '__main__':
if len(sys.argv) >= 2:
function = sys.argv[1]
else:
function = 'none'
from time import sleep
if function == "test":
(result, response) = connectionTest('connection test')
print 'result: %s, response: %s ' % (result, response)
print listJobs()
if function == "runtest":
(status, idnr) = initCommDetectJob('/opt/media/tv/01-09_21_00_Dirty_Jobs_-_Bug_Breeder.mpeg')
print "Job has idnr nr : %s" % idnr
print idnr
sleep(5)
print queueIt(idnr, True)
'''
To run this as standalone use the following before running python v4l2.py
pythonversion=$(python -V 2>&1 | cut -d" " -f2 | cut -d"." -f1-2)
export PYTHONPATH=/usr/lib/python${pythonversion}/site-packages/freevo
export FREEVO_SHARE=/usr/share/freevo
export FREEVO_CONFIG=/usr/share/freevo/freevo_config.py
export FREEVO_CONTRIB=/usr/share/freevo/contrib
export RUNAPP=""
python encodingclient.py test
'''
|