+++ /dev/null
-#!/usr/bin/python\r
-# coding: UTF-8\r
-# Rec10 TS Recording Tools\r
-# Copyright (C) 2009-2011 Yukikaze\r
-import datetime\r
-import os\r
-import os.path\r
-import glob\r
-import time\r
-import traceback\r
-\r
-import configreader\r
-import recdblist\r
-import recdb\r
-tmppath = configreader.getConfPath("tmp")+"/"\r
-if not os.path.exists(tmppath):\r
- os.mkdir(tmppath)\r
-def writeRecQue(parentpath,chtxt,title,opts):\r
- outputpath=os.path.join(parentpath,title+".recq")\r
- tmpoppath=os.path.join(tmppath,title+".recq")\r
- f=open(outputpath,"w")\r
- optt=opts\r
- #optt=opts.replace("E","")\r
- #optt=optt.replace("D","")\r
- #optt=optt.replace("R","")\r
- str="99"+","+datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")+","+configreader.getConfEnv("iff")+","+chtxt+","+title+","+optt\r
- f.write(str.encode('utf-8'))\r
- f.close()\r
- if not os.path.exists(outputpath):\r
- if os.path.exists(tmpoppath):\r
- os.remove(tmpoppath)\r
- f2=open(tmpoppath,"w")\r
- f2.write(str.encode('utf-8'))\r
- f2.close()\r
- try:\r
- os.chmod(tmpoppath)\r
- except:\r
- ""\r
- shutil.copy(tmpoppath,outputpath)\r
- os.remove(tmpoppath)\r
-def readRecQue(recquepath):\r
- f=open(recquepath,"r")\r
- line = unicode(f.readline(),'utf-8')\r
- title=""\r
- opts=""\r
- chtxt=""\r
- while line:\r
- linec=line.split(",")\r
- if len(linec)>3:\r
- if linec[0]=="99":\r
- title=linec[4]\r
- opts=linec[5]\r
- chtxt=linec[2]+u"_"+linec[3]\r
- break\r
- line = unicode(f.readline(),'utf-8')\r
- dbkey=""\r
- if opts.find("E")>-1:\r
- dbkey=""\r
- opts=opts.replace("E","")\r
- elif opts.find("D")>-1:\r
- dbkey=recdblist.REC_ENCODE_QUE\r
- opts=opts.replace("D","")\r
- elif opts.find("R")>-1:\r
- dbkey=recdblist.REC_TS_DECODE_QUE\r
- opts=opts.replace("R","")\r
- bt=datetime.datetime.now()+datetime.timedelta(minutes=5)\r
- et=bt+datetime.timedelta(minutes=30)\r
- btime=bt.strftime("%Y-%m-%d %H:%M:%S")\r
- etime=et.strftime("%Y-%m-%d %H:%M:%S")\r
- if len(dbkey)>2:\r
- recdb.reserveReckey(dbkey, title, chtxt, btime, etime, opts)\r
-def searchRecQue(folderpath):\r
- for file in glob.glob(os.path.join(folderpath,"*.recq")):\r
- dtime = time.time()-os.path.getmtime(file)\r
- dtime = int(dtime)\r
- if dtime > 300:\r
- try:\r
- readRecQue(os.path.join(folderpath, file))\r
- os.remove(os.path.join(folderpath, file))\r
- except Exception, inst:\r
- recdblist.addCommonlogEX("Error", "searchRecQue(recque.py)", str(type(inst)), str(inst)+traceback.format_exc(),log_level=200)\r
- \r