OSDN Git Service

bs check implement.
authorgn64_jp <gn64_jp@4e526526-5e11-4fc0-8910-f8fd03428081>
Sun, 7 Nov 2010 13:02:15 +0000 (13:02 +0000)
committergn64_jp <gn64_jp@4e526526-5e11-4fc0-8910-f8fd03428081>
Sun, 7 Nov 2010 13:02:15 +0000 (13:02 +0000)
git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/rec10@749 4e526526-5e11-4fc0-8910-f8fd03428081

rec10/trunk/src/dbMySQL.py
rec10/trunk/src/scan_ch.py

index 7768129..4800133 100644 (file)
@@ -28,7 +28,7 @@ class DB_MySQL:
             cur.close()
             con.close()
         except Exception, inst:
-            if not (type(inst)==MySQLdb.ProgrammingError and (inst[0] == 1007 or inst[0]==1050)):
+            if not ((type(inst)==MySQLdb.ProgrammingError and inst[0]==1007)or(type(inst)==MySQLdb.OperationError and inst[0]==1050)):
                 recdblist.Commonlogex("Error", "init (dbMySQL.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
         db = self.connect_db()
         try:
@@ -54,7 +54,7 @@ class DB_MySQL:
             UNIQUE uni (type,chtxt,title,btime,deltaday)\
             )')
         except Exception, inst:
-            if not (type(inst)==MySQLdb.ProgrammingError and (inst[0] == 1007 or inst[0]==1050)):
+            if not ((type(inst)==MySQLdb.ProgrammingError and inst[0]==1007)or(type(inst)==MySQLdb.OperationError and inst[0]==1050)):
                 recdblist.Commonlogex("Error", "init (dbMySQL.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
         self.close_db(db)
         self.new_epg_timeline("")
@@ -81,7 +81,7 @@ class DB_MySQL:
         try:
             db[1].execute('drop table epg_ch')
         except Exception, inst:
-            if not (type(inst)==MySQLdb.ProgrammingError and (inst[0] == 1007 or inst[0]==1050)):
+            if not ((type(inst)==MySQLdb.ProgrammingError and inst[0]==1007)or(type(inst)==MySQLdb.OperationError and inst[0]==1050)):
                 recdblist.Commonlogex("Error", "new_epg_ch drop (dbMySQL.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
 
         try:
@@ -98,7 +98,7 @@ class DB_MySQL:
             isshow TINYINT\
             )')
         except Exception, inst:
-            if not (type(inst)==MySQLdb.ProgrammingError and (inst[0] == 1007 or inst[0]==1050)):
+            if not ((type(inst)==MySQLdb.ProgrammingError and inst[0]==1007)or(type(inst)==MySQLdb.OperationError and inst[0]==1050)):
                 recdblist.Commonlogex("Error", "new_epg_ch (dbMySQL.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
 
         self.close_db(db)
@@ -260,7 +260,7 @@ class DB_MySQL:
         try:
             db[1].execute('drop table auto_proc_tmp')
         except Exception, inst:
-            if not (type(inst)==MySQLdb.ProgrammingError and (inst[0] == 1007 or inst[0]==1050)):
+            if not ((type(inst)==MySQLdb.ProgrammingError and inst[0]==1007)or(type(inst)==MySQLdb.OperationError and inst[0]==1050)):
                 recdblist.Commonlogex("Error", "new_auto_proc_tmp drop (dbMySQL.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
 
         try:
@@ -273,7 +273,7 @@ class DB_MySQL:
             UNIQUE unibayeskey(title)\
             )')
         except Exception, inst:
-            if not (type(inst)==MySQLdb.ProgrammingError and (inst[0] == 1007 or inst[0]==1050)):
+            if not ((type(inst)==MySQLdb.ProgrammingError and inst[0]==1007)or(type(inst)==MySQLdb.OperationError and inst[0]==1050)):
                 recdblist.Commonlogex("Error", "new_auto_proc_tmp (dbMySQL.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
 
         self.close_db(db)
@@ -282,7 +282,7 @@ class DB_MySQL:
         try:
             db[1].execute('INSERT INTO auto_proc SELECT * FROM auto_proc_tmp')
         except Exception, inst:
-            if not (type(inst)==MySQLdb.ProgrammingError and (inst[0] == 1007 or inst[0]==1050)):
+            if not ((type(inst)==MySQLdb.ProgrammingError and inst[0]==1007)or(type(inst)==MySQLdb.OperationError and inst[0]==1050)):
                 recdblist.Commonlogex("Error", "update_auto_proc (dbMySQL.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
 
         self.close_db(db)
@@ -291,7 +291,7 @@ class DB_MySQL:
         try:
             db[1].execute('drop table auto_proc')
         except Exception, inst:
-            if not (type(inst)==MySQLdb.ProgrammingError and (inst[0] == 1007 or inst[0]==1050)):
+            if not ((type(inst)==MySQLdb.ProgrammingError and inst[0]==1007)or(type(inst)==MySQLdb.OperationError and inst[0]==1050)):
                 recdblist.Commonlogex("Error", "new_auto_proc drop (dbMySQL.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
 
         try:
@@ -304,7 +304,7 @@ class DB_MySQL:
             UNIQUE unibayeskey(title)\
             )')
         except Exception, inst:
-            if not (type(inst)==MySQLdb.ProgrammingError and (inst[0] == 1007 or inst[0]==1050)):
+            if not ((type(inst)==MySQLdb.ProgrammingError and inst[0]==1007)or(type(inst)==MySQLdb.OperationError and inst[0]==1050)):
                 recdblist.Commonlogex("Error", "new_auto_proc (dbMySQL.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
 
         self.close_db(db)
@@ -321,7 +321,7 @@ class DB_MySQL:
         try:
             db[1].execute('drop table in_settings')
         except Exception, inst:
-            if not (type(inst)==MySQLdb.ProgrammingError and (inst[0] == 1007 or inst[0]==1050)):
+            if not ((type(inst)==MySQLdb.ProgrammingError and inst[0]==1007)or(type(inst)==MySQLdb.OperationError and inst[0]==1050)):
                 recdblist.Commonlogex("Error", "drop_in_settings (dbMySQL.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
         self.close_db(db)
     def new_in_settings(self):
@@ -337,7 +337,7 @@ class DB_MySQL:
             )')
             db[1].execute("INSERT IGNORE into in_settings VALUE (0,0,\"H\",1)")
         except Exception, inst:
-            if not (type(inst)==MySQLdb.ProgrammingError and (inst[0] == 1007 or inst[0]==1050)):
+            if not ((type(inst)==MySQLdb.ProgrammingError and inst[0]==1007)or(type(inst)==MySQLdb.OperationError and inst[0]==1050)):
                 recdblist.Commonlogex("Error", "new_in_settings (dbMySQL.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
 
         self.close_db(db)
@@ -398,7 +398,7 @@ class DB_MySQL:
             UNIQUE uni (chtxt,title,btime,category)\
             )')
         except Exception, inst:
-            if not (type(inst)==MySQLdb.ProgrammingError and (inst[0] == 1007 or inst[0]==1050)):
+            if not ((type(inst)==MySQLdb.ProgrammingError and inst[0]==1007)or(type(inst)==MySQLdb.OperationError and inst[0]==1050)):
                 recdblist.Commonlogex("Error", "new_in_timeline_log (dbMySQL.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
 
         self.close_db(db)
@@ -699,7 +699,7 @@ class DB_MySQL:
             UNIQUE unijbk (keyword)\
             )")
         except Exception, inst:
-            if not (type(inst)==MySQLdb.ProgrammingError and (inst[0] == 1007 or inst[0]==1050)):
+            if not ((type(inst)==MySQLdb.ProgrammingError and inst[0]==1007)or(type(inst)==MySQLdb.OperationError and inst[0]==1050)):
                 recdblist.Commonlogex("Error", "new_in_auto_jbk_key (dbMySQL.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
         self.close_db(db)
     def add_in_auto_jbk_key(self,key):
@@ -727,7 +727,7 @@ class DB_MySQL:
         try:
             db[1].execute('drop table in_status')
         except Exception, inst:
-            if not (type(inst)==MySQLdb.ProgrammingError and (inst[0] == 1007 or inst[0]==1050)):
+            if not ((type(inst)==MySQLdb.ProgrammingError and inst[0]==1007)or(type(inst)==MySQLdb.OperationError and inst[0]==1050)):
                 recdblist.Commonlogex("Error", "drop_in_status (dbMySQL.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
         self.close_db(db)
     def new_in_status(self):
@@ -745,7 +745,7 @@ class DB_MySQL:
             )")
             db[1].execute("INSERT IGNORE into in_status VALUE (0,0,0,0,0,0)")
         except Exception, inst:
-            if not (type(inst)==MySQLdb.ProgrammingError and (inst[0] == 1007 or inst[0]==1050)):
+            if not ((type(inst)==MySQLdb.ProgrammingError and inst[0]==1007)or(type(inst)==MySQLdb.OperationError and inst[0]==1050)):
                 recdblist.Commonlogex("Error", "new_in_status (dbMySQL.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
         self.close_db(db)
     def select_all_in_status(self):
@@ -782,7 +782,7 @@ class DB_MySQL:
                 r = list(dl)
                 version=int(str(r[0]))
         except Exception, inst:
-            if not (type(inst)==MySQLdb.ProgrammingError and (inst[0] == 1007 or inst[0]==1050)):
+            if not ((type(inst)==MySQLdb.ProgrammingError and inst[0]==1007)or(type(inst)==MySQLdb.OperationError and inst[0]==1050)):
                 recdblist.Commonlogex("Error", "select_version_in_status (dbMySQL.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
         return version
     def change_version_in_status(self,version):
@@ -865,7 +865,7 @@ class DB_MySQL:
             WHERE bctype = %s", \
                           (bctype,))
         except Exception, inst:
-            if not (type(inst)==MySQLdb.ProgrammingError and (inst[0] == 1007 or inst[0]==1050)):
+            if not ((type(inst)==MySQLdb.ProgrammingError and inst[0]==1007)or(type(inst)==MySQLdb.OperationError and inst[0]==1050)):
                 recdblist.Commonlogex("Error", "new_epg_timeline delete (dbMySQL.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
         try:
             db[1].execute("\
@@ -882,7 +882,7 @@ class DB_MySQL:
             UNIQUE unitv(bctype,channel,start,stop,title)\
             )")
         except Exception, inst:
-            if not (type(inst)==MySQLdb.ProgrammingError and (inst[0] == 1007 or inst[0]==1050)):
+            if not ((type(inst)==MySQLdb.ProgrammingError and inst[0]==1007)or(type(inst)==MySQLdb.OperationError and inst[0]==1050)):
                 recdblist.Commonlogex("Error", "new_epg_timeline (dbMySQL.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
         #db.commit()
         self.close_db(db)
@@ -964,7 +964,7 @@ class DB_MySQL:
             )')
             db[1].execute('CREATE INDEX keycharindex ON in_auto_bayes_key(keychar)')
         except Exception, inst:
-            if not (type(inst)==MySQLdb.ProgrammingError and (inst[0] == 1007 or inst[0]==1050)):
+            if not ((type(inst)==MySQLdb.ProgrammingError and inst[0]==1007)or(type(inst)==MySQLdb.OperationError and inst[0]==1050)):
                 recdblist.Commonlogex("Error", "new_in_auto_bayes_key (dbMySQL.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
         self.close_db(db)
 
@@ -1026,7 +1026,7 @@ class DB_MySQL:
                 ON DUPLICATE KEY UPDATE \
                 ratio_all=CONVERT((ratio_all*%s+%s)/%s,DECIMAL(32,14))",retl)
             except Exception, inst:
-                if not (type(inst)==MySQLdb.ProgrammingError and (inst[0] == 1007 or inst[0]==1050)):
+                if not ((type(inst)==MySQLdb.ProgrammingError and inst[0]==1007)or(type(inst)==MySQLdb.OperationError and inst[0]==1050)):
                     recdblist.Commonlogex("Error", "change_multi_ratio_all_in_auto_bayes_key (dbMySQL.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
         self.close_db(db)
     def change_ratio_rec_reduce_in_auto_bayes_key(self,chtxt,beforenum,newnum):
@@ -1058,7 +1058,7 @@ class DB_MySQL:
                 ON DUPLICATE KEY UPDATE \
                 ratio_rec=CONVERT((ratio_rec*%s+%s)/%s,DECIMAL(32,14))",retl)
             except Exception, inst:
-                if not (type(inst)==MySQLdb.ProgrammingError and (inst[0] == 1007 or inst[0]==1050)):
+                if not ((type(inst)==MySQLdb.ProgrammingError and inst[0]==1007)or(type(inst)==MySQLdb.OperationError and inst[0]==1050)):
                     recdblist.Commonlogex("Error", "change_multi_ratio_rec_in_auto_bayes_key (dbMySQL.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
         self.close_db(db)
     def select_by_key_in_auto_bayes_key(self,key,chtxt):
@@ -1090,7 +1090,7 @@ class DB_MySQL:
             UNIQUE uni (chtxt,title,btime,etime)\
             )')
         except Exception, inst:
-            if not (type(inst)==MySQLdb.ProgrammingError and (inst[0] == 1007 or inst[0]==1050)):
+            if not ((type(inst)==MySQLdb.ProgrammingError and inst[0]==1007)or(type(inst)==MySQLdb.OperationError and inst[0]==1050)):
                 recdblist.Commonlogex("Error", "new_auto_timeline_keyword (dbMySQL.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
     def add_auto_timeline_keyword(self,chtxt="", title="", btime="", etime=""):
         db = self.connect_db()
@@ -1123,7 +1123,7 @@ class DB_MySQL:
             UNIQUE uni (chtxt,title,btime,etime)\
             )')
         except Exception, inst:
-            if not (type(inst)==MySQLdb.ProgrammingError and (inst[0] == 1007 or inst[0]==1050)):
+            if not ((type(inst)==MySQLdb.ProgrammingError and inst[0]==1007)or(type(inst)==MySQLdb.OperationError and inst[0]==1050)):
                 recdblist.Commonlogex("Error", "new_auto_timeline_bayes (dbMySQL.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
     def add_auto_timeline_bayes(self,chtxt="", title="", btime="", etime="",point=""):
         db = self.connect_db()
index 056436c..fb7cba7 100644 (file)
@@ -77,13 +77,18 @@ def addCh(ch,bctype,chtxthead):
 def getChProgNum(ch):
     pout=os.path.join(tmppath,"ch_"+str(ch)+".ts")
     tv2ts.tv2tsmix(pout, ch, "10")
-    retl=getTsProgNum(pout)
+    retl=getTsProgNum(ch,pout)
     os.remove(pout)
     return retl
-def getTsProgNum(tspath):
+def getTsProgNum(ch,tspath):
     pin=tspath
     pout=os.path.join(tmppath,"chscan.txt")
-    doexe = tssplitterp + " -ch \""+ pin + "\" \""+ pout + "\""
+    chopt="-ch"
+    if ch.find("CS"):
+        chopt="-cs"
+    elif int(ch)>99:
+        chopt="-bs"
+    doexe = tssplitterp + " "+chopt+" \""+ pin + "\" \""+ pout + "\""
     doexe = "nice -n 18 " + doexe
     os.environ['LANG']="ja_JP.UTF-8"
     txt = unicode(commands.getoutput(doexe.encode('utf-8')),'utf-8','ignore')