3 # Rec10 TS Recording Tools
4 # Copyright (C) 2009-2012 Yukikaze
15 tmppath = configreader.getConfPath("tmp")+"/"
16 if not os.path.exists(tmppath):
18 def writeRecQue(parentpath,chtxt,title,opts):
19 outputpath=os.path.join(parentpath,title+".recq")
20 tmpoppath=os.path.join(tmppath,title+".recq")
21 f=open(outputpath,"w")
23 str="99"+","+datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")+","+configreader.getConfEnv("iff")+","+chtxt+","+title+","+optt
24 f.write(str.encode('utf-8'))
26 if not os.path.exists(outputpath):
27 if os.path.exists(tmpoppath):
29 f2=open(tmpoppath,"w")
30 f2.write(str.encode('utf-8'))
36 shutil.copy(tmpoppath,outputpath)
38 def readRecQue(recquepath):
39 f=open(recquepath,"r")
40 line = unicode(f.readline(),'utf-8')
50 chtxt=linec[2]+u"_"+linec[3]
52 line = unicode(f.readline(),'utf-8')
55 dbkey=recdblist.REC_TS_DECODE_QUE
56 opts=opts.replace("R","")
57 elif opts.find("D")>-1:
58 dbkey=recdblist.REC_ENCODE_QUE
59 opts=opts.replace("D","")
60 elif opts.find("E")>-1:
62 opts=opts.replace("E","")
64 bt=datetime.datetime.now()+datetime.timedelta(minutes=5)
65 et=bt+datetime.timedelta(minutes=30)
66 btime=bt.strftime("%Y-%m-%d %H:%M:%S")
67 etime=et.strftime("%Y-%m-%d %H:%M:%S")
69 recdb.reserveReckey(dbkey, title, chtxt, btime, etime, opts)
70 def searchRecQue(folderpath):
71 for file in glob.glob(os.path.join(folderpath,"*.recq")):
72 dtime = time.time()-os.path.getmtime(file)
76 readRecQue(os.path.join(folderpath, file))
77 os.remove(os.path.join(folderpath, file))
78 except Exception, inst:
79 recdblist.addCommonlogEX("Error", "searchRecQue(recque.py)", str(type(inst)), str(inst)+traceback.format_exc(),log_level=200)