#!/usr/bin/python
# coding: UTF-8
# Rec10 TS Recording Tools
-# Copyright (C) 2009 Yukikaze
+# Copyright (C) 2009-2010 Yukikaze
from SocketServer import *
-import recdb
+
import configreader
+import re
+import recdb
+import recdblist
RECV_BUF = 8192
class Handler(BaseRequestHandler):
"""
def handle(self):
- print "connect from:", self.client_address
- cons=getTask()
- print cons+" is sent"
- self.request.send(cons)
+ print("connect from:", self.client_address)
+ cons = getTask()
+ recdblist.printutf8(cons + " is sent")
+ self.request.send(cons.encode('UTF-8'))
"""while True:
#ret = self.request.recv(RECV_BUF)
#if len(ret) == 0:
self.request.close()
def getTask():
- tasks=recdb.getnow("1")
- rett=""
+ tasks = recdb.getnow("1")
+ rett = ""
for task in tasks:
- if task["type"]==recdb.REC_ENCODE_QUE:
- title=task['title']
- opt=task['opt']
- btime=task['btime']
- etime=task['etime']
- chtxt=task['chtxt']
- recdb.del_reckey(recdb.REC_ENCODE_QUE, title, chtxt, btime)
- recdb.rec_reckey(recdb.REC_ENCODE_GRID, title, chtxt, btime, etime, opt)
- rett="title="+title+","+"opt="+opt+";"
+ if task["type"] == recdblist.REC_ENCODE_QUE and not re.search("d",task['opt']) and not re.search("5",task['opt']):
+ title = task['title']
+ opt = task['opt']
+ btime = task['btime']
+ etime = task['etime']
+ chtxt = task['chtxt']
+ recdb.del_reckey(recdblist.REC_ENCODE_QUE, title, chtxt, btime)
+ recdb.rec_reckey(recdblist.REC_ENCODE_GRID, title, chtxt, btime, etime, opt)
+ rett = "title=" + title + "," + "opt=" + opt + ";"
break
return rett
def main():
- port=int(configreader.getpath("gridserver_port"))
+ port = int(configreader.getpath("gridserver_port"))
sv = ThreadingTCPServer(('', port), Handler)
- print "This is a Rec10 GridServer."
- print "Waiting for connections at port"+str(port)
- print 'listen to:', sv.socket.getsockname()
+ recdblist.printutf8("This is a Rec10 GridServer.")
+ recdblist.printutf8("Waiting for connections at port" + str(port))
+ recdblist.printutf8('listen to:')
+ print (sv.socket.getsockname())
sv.serve_forever()
if __name__ == '__main__': main()