OSDN Git Service

convert CRLF to LF
[rec10/rec10-git.git] / rec10 / trunk / src / recque.py
index 64be4a8..739a41e 100644 (file)
@@ -1,82 +1,80 @@
-#!/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
+#!/usr/bin/python
+# coding: UTF-8
+# Rec10 TS Recording Tools
+# Copyright (C) 2009-2012 Yukikaze
+import datetime
+import os
+import os.path
+import glob
+import time
+import traceback
+
+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):
+    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')
+    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=""
+    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","")
+    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.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)
+        dtime = int(dtime)
+        if dtime > 300:
+            try:
+                readRecQue(os.path.join(folderpath, file))
+                os.remove(os.path.join(folderpath, file))
+            except Exception, inst:
+                recdblist.addCommonlogEX("Error", "searchRecQue(recque.py)", str(type(inst)), str(inst)+traceback.format_exc(),log_level=200)
+