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