From 90291b489583fd4de621d81a0d2d82ff2f77d7f3 Mon Sep 17 00:00:00 2001 From: gn64_jp Date: Fri, 2 Apr 2010 01:05:18 +0000 Subject: [PATCH] implement new logging system. git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/rec10@535 4e526526-5e11-4fc0-8910-f8fd03428081 --- rec10/trunk/src/Makefile.base | 2 ++ rec10/trunk/src/epgdb.py | 8 ++++---- rec10/trunk/src/guess.py | 12 ++++++------ rec10/trunk/src/install.py | 4 ++-- rec10/trunk/src/readme.txt | 18 ++++++++++++------ rec10/trunk/src/recdblist.py | 11 ++++++++++- rec10/trunk/src/timerec.py | 33 ++++++++++++++++----------------- rec10/trunk/src/ts2x264.py | 6 +++--- rec10/trunk/src/tv2avi.py | 18 +++++++++--------- rec10/trunk/src/tv2ts.py | 12 ++++++------ 10 files changed, 70 insertions(+), 54 deletions(-) diff --git a/rec10/trunk/src/Makefile.base b/rec10/trunk/src/Makefile.base index 6058989..efe5fdd 100644 --- a/rec10/trunk/src/Makefile.base +++ b/rec10/trunk/src/Makefile.base @@ -18,6 +18,8 @@ install: cp ./rec10.conf /etc/rec10.conf if ! [ -d /tmp/rec10 ]; then mkdir -p /tmp/rec10 ;fi chmod 777 /tmp/rec10 + if ! [ -d /var/log/rec10 ]; then echo "" > /var/log/rec10 ;fi + chmod 777 /var/log/rec10 uninstall: rm -rf $(DEST) rm -rf /tmp/rec10 diff --git a/rec10/trunk/src/epgdb.py b/rec10/trunk/src/epgdb.py index e382779..2b9993f 100644 --- a/rec10/trunk/src/epgdb.py +++ b/rec10/trunk/src/epgdb.py @@ -33,7 +33,7 @@ def update(chtxt): xml2db_dom.xml2db_dom(os.path.join(tmppath, chtxt + "epgdata.xml"), chdb.chtxtsearch(chtxt)['bctype']) def updatebc(bctype): bctypel = chdb.bctypesearch(bctype) - print bctype + #print bctype try: ts2epg.write(tmppath + bctype + "epgdata.xml", chdb.bctypesearch(bctype)['ch']) xml2db_dom.xml2db_dom(tmppath + bctype + "epgdata.xml", bctype) @@ -41,9 +41,9 @@ def updatebc(bctype): time.sleep(5) rec10d.rec10db.update_by_bctype_epg_ch(bctype) except Exception, inst: - print "error occurs in updatebc(epgdb)" - print type(inst) - print inst + recdblist.printutf8("error occurs in updatebc(epgdb)") + recdblist.printutf8(str(type(inst))) + recdblist.printutf8(str(inst)) xml2db_dom.xml2db_dom(tmppath + bctype + "epgdata.bak.xml", bctype) rec10d.rec10db.update_status_by_bctype_epg_ch(bctype, "2") def updatebc_bak(bctype): diff --git a/rec10/trunk/src/guess.py b/rec10/trunk/src/guess.py index 57ee890..07993a2 100644 --- a/rec10/trunk/src/guess.py +++ b/rec10/trunk/src/guess.py @@ -56,13 +56,13 @@ def detMultiDeltaDays(num_with_title_with_dates): for ft3 in f3[i]: for ft4 in f3[j]: for gdd in detSingleDeltaDay(i, ft3[2], j, ft4[2]): - print gdd + #print gdd if fret.get(gdd[0])!=None: - print fret + #print fret fret[gdd[0]]=fret[gdd[0]]+gdd[1] else: fret[gdd[0]]=gdd[1] - print fret + #print fret maxk=0 maxp=0 for i in range(maxnum): @@ -70,8 +70,8 @@ def detMultiDeltaDays(num_with_title_with_dates): if maxp /dev/pts/0 -などのようにすれば/dev/pts/0端末に出力します(ttyコマンドで調べられます) + +ログは/var/log/rec10に移動しました。 8.rectoolのインストール Makefile.PLを実行します。 @@ -68,7 +67,14 @@ chdata.pyを実行してください(python chdata.py) yukikaze.jp@gmail.com [History] -0.9.3 release(internal) +10/04/02 0.9.4 release +バグ修正 +インストーラーの大幅な改善 +ログシステムの変更 +エンコードの変更 +チャンネル変更に対応(CS) + +10/03/20 0.9.3 release(internal) lots of bug fixes. change DB. implement updating function(from 0.9.1 or 0.9.2) diff --git a/rec10/trunk/src/recdblist.py b/rec10/trunk/src/recdblist.py index a694ca0..db71f64 100644 --- a/rec10/trunk/src/recdblist.py +++ b/rec10/trunk/src/recdblist.py @@ -6,6 +6,7 @@ """ task names """ +import os import os.path global REC_RESERVE @@ -70,7 +71,15 @@ REC_BAYES_SUGGEST ="bayes_suggest" version = 94 def printutf8(unicode): - print unicode.encode('utf-8') + str=unicode.encode('utf-8') + print str + logfname="/var/log/rec10" + mode="a" + if not os.path.exists(logfname): + mode="w" + f=open(logfname,mode) + f.write(str+"\n") + f.close() def addlog(tspath,txt,log_title): logo=tspath logo=logo.replace("_1.wav",".ts") diff --git a/rec10/trunk/src/timerec.py b/rec10/trunk/src/timerec.py index a3a5d2b..97e1229 100644 --- a/rec10/trunk/src/timerec.py +++ b/rec10/trunk/src/timerec.py @@ -83,7 +83,7 @@ def task(): recdblist.printutf8(u"放送種別:"+bctype + u"||該当チューナー実行中件数:" + str(status.getBSCSRecording()) + u":直近予約件数:" + str(recdb.countRecNow_minutes_BSCS("10"))) recnum = int(configreader.getenv("bscs_max")) -recnum if recnum >0 : - print update + recdblist.printutf8(str(update)) rec10d.rec10db.update_status_by_bctype_epg_ch(bctype, "0") epgdb.updatebc(bctype) update = chdb.update() @@ -272,16 +272,16 @@ def search_keyword(key): topt=status.getSettings_auto_opt() recdb.recreserv(titlet,chtxtt, btimet, etimet,topt) except Exception, inst: - print "error occures in search_keyword_auto_jbk" - print str(type(inst)) - print str(inst) + recdblist.printutf8("error occures in search_keyword_auto_jbk") + recdblist.printutf8(str(type(inst))) + recdblist.printutf8(str(inst)) else: try: recdb.add_auto_keyword(chtxtt, titlet, btimet, etimet) except Exception, inst: - print "error occures in search_keyword" - print str(type(inst)) - print str(inst) + recdblist.printutf8("error occures in search_keyword") + recdblist.printutf8(str(type(inst))) + recdblist.printutf8(str(inst)) def type_reserve(typetxt,chtxt,title,bt,et,opt): btime = bt.strftime("%Y-%m-%d %H:%M:%S") etime = et.strftime("%Y-%m-%d %H:%M:%S") @@ -319,9 +319,9 @@ def type_reserve(typetxt,chtxt,title,bt,et,opt): auto_rec.add_key("ALL", titlen,exp+" "+longexp) recdblist.printutf8(u"追いかけ機能実行中: "+title+" : "+titlen+" "+btimen+" "+etimen) except Exception, inst: - print "Error happened in Oikake DB" - print str(type(inst)) - print str(inst) + recdblist.printutf8("Error happened in Oikake DB") + recdblist.printutf8(str(type(inst))) + recdblist.printutf8(str(inst)) else: recdblist.printutf8(u"追いかけ機能エラー:番組データが見付かりません。") else: @@ -350,16 +350,16 @@ def type_reserve(typetxt,chtxt,title,bt,et,opt): auto_rec.add_key("ALL", titlen,exp+" "+longexp) recdblist.printutf8(u"追いかけ機能実行中: "+title+" : "+titlen+" "+btimen+" "+etimen) except Exception, inst: - print "Error happened in Oikake DB" - print type(inst) - print inst + recdblist.printutf8("Error happened in Oikake DB") + recdblist.printutf8(str(type(inst))) + recdblist.printutf8(str(inst)) elif dt <= 20 * 60: try: recdb.del_reckey(typetxtnow, title, chtxt, btime) recdb.rec_reckey(typetxtfinal, title, chtxt, btime, etime, opt) except Exception, inst: - print type(inst) - print inst + recdblist.printutf8(str(type(inst))) + recdblist.printutf8(str(inst)) def type_final(typetxt,chtxt,title,bt,et,opt): btime = bt.strftime("%Y-%m-%d %H:%M:%S") etime = et.strftime("%Y-%m-%d %H:%M:%S") @@ -372,7 +372,6 @@ def type_final(typetxt,chtxt,title,bt,et,opt): tnow = datetime.datetime.now() dtt = bt-tnow dt = dtt.days * 24 * 60 * 60 + dtt.seconds - print dt if dt < 6 * 60 and dt > 0: newtitle=title recdb.del_reckey(typetxtnow, title, chtxt, btime) @@ -522,7 +521,7 @@ def type_decode_que(typetxt,chtxt,title,bt,et,opt): recdb.rec_reckey(typetxtmiss, title, chtxt, btime, etime, opt) else: ch=checker.checkB25Decode(recpath + "/" + title + ".ts.b25", recpath + "/" + title + ".ts") - print ch + #print ch if ch == 1: os.remove(recpath + "/" + title + ".ts.b25") bt = datetime.datetime.strptime(btime, "%Y-%m-%d %H:%M:%S") diff --git a/rec10/trunk/src/ts2x264.py b/rec10/trunk/src/ts2x264.py index d37e680..aa880d9 100644 --- a/rec10/trunk/src/ts2x264.py +++ b/rec10/trunk/src/ts2x264.py @@ -59,9 +59,9 @@ def ts2x264(pin, pout, opts):#sizeは"HD"か"SD" try: encode(pin, pout,size,is24fps,quality,crf) except Exception, inst: - print "error occures in ts2x264.py encode" - print type(inst) - print inst + recdblist.printutf8("error occures in ts2x264.py encode") + recdblist.printutf8(str(type(inst))) + recdblist.printutf8(str(inst)) def encode(pin,pout,size,is24fps,quality,crf): mencoder=configreader.getpath("mencoder") x264=configreader.getpath("x264") diff --git a/rec10/trunk/src/tv2avi.py b/rec10/trunk/src/tv2avi.py index fc561db..2129ea8 100644 --- a/rec10/trunk/src/tv2avi.py +++ b/rec10/trunk/src/tv2avi.py @@ -73,27 +73,27 @@ def b252ts(pout, chtxt, btime, etime, opt): if pentaaudio == 1: pentaaudio2sep(aviin) except Exception, inst: - print "Error happened in b252ts in tv2avi" - print str(type(inst)) - print str(inst) + recdblist.printutf8("Error happened in b252ts in tv2avi") + recdblist.printutf8(str(type(inst))) + recdblist.printutf8(str(inst)) status.changeB25Decoding(-1) def ts2avi(pin, pout, opt): status.changeEncoding(1) try: ts2x264.ts2x264(pin, pout, opt) except Exception, inst: - print "error occures in tv2avi.py ts2avi" - print type(inst) - print inst + recdblist.printutf8("error occures in tv2avi.py ts2avi") + recdblist.printutf8(str(type(inst))) + recdblist.printutf8(str(inst)) status.changeEncoding(-1) def ts2raw(pin, pout, opt): status.changeEncoding(1) try: ts2x264.ts2x264(pin, pout, opt) except Exception, inst: - print "error occures in tv2avi.py ts2raw" - print type(inst) - print inst + recdblist.printutf8("error occures in tv2avi.py ts2raw") + recdblist.printutf8(str(type(inst))) + recdblist.printutf8(str(inst)) status.changeEncoding(-1) def dualaudiots2avi(pin, pout): bontsdemux = configreader.getpath('bontsdemux') diff --git a/rec10/trunk/src/tv2ts.py b/rec10/trunk/src/tv2ts.py index 3ff62d4..7eca6f4 100644 --- a/rec10/trunk/src/tv2ts.py +++ b/rec10/trunk/src/tv2ts.py @@ -29,9 +29,9 @@ def tv2ts(pout, ch, csch, time): try: tv2b25ts(pout + ".b25", ch, time) except Exception, inst: - print "error occures in tv2ts.py tv2ts" - print type(inst) - print inst + recdblist.printutf8("error occures in tv2ts.py tv2ts") + recdblist.printutf8(str(type(inst))) + recdblist.printutf8(str(inst)) if len(ch) > 2:#BS/CSは100とかCS??とかなので3文字以上 status.changeBSCSRecording(-1) else: @@ -85,9 +85,9 @@ def tv2b25ts(pout, ch, time): recdblist.printutf8(doexe) recdblist.addlog(pout, unicode(commands.getoutput(doexe.encode('utf-8')),'utf-8'), u"recpt1-log") except Exception, inst: - print "error occures in tv2ts.py tv2b25ts" - print type(inst) - print inst + recdblist.printutf8("error occures in tv2ts.py tv2b25ts") + recdblist.printutf8(str(type(inst))) + recdblist.printutf8(str(inst)) if len(ch) > 2:#BS/CSは100とかCS??とかなので3文字以上 status.changeBSCSRecording(-1) else: -- 2.11.0