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