OSDN Git Service

stop using trunk directory in rectool
[rec10/rec10-git.git] / rec10 / trunk / src / epgdb.py
index d42160a..727209d 100644 (file)
@@ -1,7 +1,7 @@
 #!/usr/bin/python
 # coding: UTF-8
 # Rec10 TS Recording Tools
-# Copyright (C) 2009-2010 Yukikaze
+# Copyright (C) 2009-2011 Yukikaze
 import datetime
 import os
 import shutil
@@ -17,26 +17,28 @@ import xml2db_dom
 import configreader
 import recdblist
 path = str(os.path.dirname(os.path.abspath(__file__))) + "/"
-tmppath = configreader.getPathSetting("tmp")+"/"
+tmppath = configreader.getConfPath("tmp")+"/"
 if tmppath=="/":
     tmppath=path
+if not os.path.exists(tmppath):
+    os.mkdir(tmppath)
 def update(chtxt):
     recdblist.printutf8(chtxt)
     tnow = datetime.datetime.now()
     try:
-        lastup = datetime.datetime.strptime(chdb.searchFromCHtxt(chtxt)[0]['update'], "%Y-%m-%d %H:%M:%S")
+        lastup = datetime.datetime.strptime(chdb.searchCHFromChtxt(chtxt)[0]['update'], "%Y-%m-%d %H:%M:%S")
     except:
         lastup = datetime.datetime.strptime("2009-04-01 00:00:00", "%Y-%m-%d %H:%M:%S")
     dt = tnow-lastup
     dt = dt.days * 24 * 60 + dt.seconds
     if dt > 2 * 60 * 60:
-        ts2epg.write(os.path.join(tmppath, chtxt + "epgdata.xml"), chdb.getChCSchFromCHtxt(chtxt)['ch'])
-        xml2db_dom.xml2db_dom(os.path.join(tmppath, chtxt + "epgdata.xml"), chdb.searchFromCHtxt(chtxt)['bctype'])
-def updateForBctype(bctype):
-    bctypel = chdb.searchFromBctype(bctype)
+        ts2epg.writeEpgXML(os.path.join(tmppath, chtxt + "epgdata.xml"), chdb.searchCHFromChtxt(chtxt)['ch'])
+        xml2db_dom.xml2db_dom(os.path.join(tmppath, chtxt + "epgdata.xml"), chdb.searchCHFromChtxt(chtxt)['bctype'])
+def updatebc(bctype):
+    bctypel = chdb.searchCHFromBctype(bctype)
     #print bctype
     try:
-        ts2epg.write(tmppath + bctype + "epgdata.xml", chdb.searchFromBctype(bctype)['ch'])
+        ts2epg.writeEpgXML(tmppath + bctype + "epgdata.xml", chdb.searchCHFromBctype(bctype)['ch'])
         xml2db_dom.xml2db_dom(tmppath + bctype + "epgdata.xml", bctype)
         shutil.copyfile(tmppath + bctype + "epgdata.xml", tmppath + bctype + "epgdata.bak.xml")
         time.sleep(5)
@@ -45,6 +47,19 @@ def updateForBctype(bctype):
         recdblist.addCommonlogEX("Error","updatebc(epgdb.py)", str(type(inst)), str(inst)+"\n"+traceback.format_exc(),log_level=200)
         xml2db_dom.xml2db_dom(tmppath + bctype + "epgdata.bak.xml", bctype)
         rec10d.rec10db.update_status_by_bctype_epg_ch(bctype, "2")
+def updateLogo_bc(bctype):
+    bctypel = chdb.searchCHFromBctype(bctype)
+    #print bctype
+    try:
+        ts2epg.writeLogoEpgXML(tmppath + bctype + "logo.xml", chdb.searchCHFromBctype(bctype)['ch'])
+        xml2db_dom.xml2db_dom_logo(tmppath + bctype + "logo.xml", bctype)
+        shutil.copyfile(tmppath + bctype + "logo.xml", tmppath + bctype + "logo.bak.xml")
+        time.sleep(5)
+        rec10d.rec10db.update_logostatus_by_bctype_epg_ch(bctype,"1")
+    except Exception, inst:
+        recdblist.addCommonlogEX("Error","updatebc(epgdb.py)", str(type(inst)), str(inst)+"\n"+traceback.format_exc(),log_level=200)
+        xml2db_dom.xml2db_dom(tmppath + bctype + "logo.bak.xml", bctype)
+        rec10d.rec10db.update_logostatus_by_bctype_epg_ch(bctype,"2")
 def searchTime(titletxt, timet, deltatime, chtxt):
     time = datetime.datetime.strptime(timet, "%Y-%m-%d %H:%M:%S")
     ret = []
@@ -259,4 +274,4 @@ def searchEpgSchedule(epgbtime,epgetime):
         ret1 = rec10d.rec10db.search_epgschedule_timeline(epgbtime1, epgetime1)
         ret.append(ret1)
     ret = list(set(ret))
-    return ret
\ No newline at end of file
+    return ret