OSDN Git Service

implement recque system.
[rec10/rec10-git.git] / rec10 / trunk / src / recque.py
index b5c7ad4..898077c 100644 (file)
@@ -22,36 +22,37 @@ def writeRecQue(parentpath,chtxt,title,opts):
     f.close()
 
 def readRecQue(recquepath):
-    f=open(os.path.join(parentpath,title+".recq"),"r")
-    line = unicode(f.readline(),'utf-8')
-    title=""
-    opts=""
-    chtxt=""
-    while line:
-        linec=line.split(",")
-        if len(linec)>3:
-            if linec[0]=="99":
-                title=linec[4]
-                opts=linec[5]
-                chtxt=linec[2]+u"_"+linec[3]
-                break
+    if int(time.time()-os.path.getmtime(recquepath))>300:
+        f=open(recquepath,"r")
         line = unicode(f.readline(),'utf-8')
-    dbkey=""
-    if opts.find("E"):
+        title=""
+        opts=""
+        chtxt=""
+        while line:
+            linec=line.split(",")
+            if len(linec)>3:
+                if linec[0]=="99":
+                    title=linec[4]
+                    opts=linec[5]
+                    chtxt=linec[2]+u"_"+linec[3]
+                    break
+            line = unicode(f.readline(),'utf-8')
         dbkey=""
-        opts=opts.replace("E","")
-    if opts.find("D"):
-        dbkey=recdblist.REC_ENCODE_QUE
-        opts=opts.replace("D","")
-    if opts.find("R"):
-        dbkey=recdblist.REC_TS_DECODE_QUE
-        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)
+        if opts.find("E"):
+            dbkey=""
+            opts=opts.replace("E","")
+        if opts.find("D"):
+            dbkey=recdblist.REC_ENCODE_QUE
+            opts=opts.replace("D","")
+        if opts.find("R"):
+            dbkey=recdblist.REC_TS_DECODE_QUE
+            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)
 def searchRecQue(folderpath):
     for file in glob.glob(os.path.join(folderpath,"*.recq")):
         dtime = time.time()-os.path.getmtime(avipath)