OSDN Git Service

remove error log.
[rec10/rec10-git.git] / rec10 / trunk / src / tv2ts.py
1 #!/usr/bin/python
2 # coding: UTF-8
3 #import sys # モジュール属性 argv を取得するため
4 import commands
5 import os
6 import os.path
7 import time
8 import traceback
9
10 import configreader
11 import status
12 import recdblist
13 mypath = str(os.path.dirname(os.path.abspath(__file__))) + "/"
14 def tv2tsmix(pout, ch, time,getlog=0):
15     tv2b25ts(pout + ".b25", ch, time)
16     txt=b252tsmix(pout + ".b25", pout)
17     return txt
18     #if os.access(pout, os.F_OK):
19     #    try:
20     #        os.remove(pout + ".b25")
21     #    except:
22     #        ""
23 def tv2ts(pout, ch, csch, time):
24     if len(ch) > 2:#BS/CSは100とかCS??とかなので3文字以上
25         status.changeBSCSRecording(1)
26     else:
27         status.changeTERecording(1)
28     try:
29         tv2b25ts(pout + ".b25", ch, time)
30     except Exception, inst:
31         recdblist.addCommonlogEX(u"Error",u"tv2ts(tv2ts.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
32     if len(ch) > 2:#BS/CSは100とかCS??とかなので3文字以上
33         status.changeBSCSRecording(-1)
34     else:
35         status.changeTERecording(-1)
36     b252tsmix(pout + ".b25", pout + ".tsmix")
37     tch="0"
38     if csch!=u"0":
39         tch=csch
40     elif ch==u"101":
41         tch="101"
42     elif ch==u"102":
43         tch="102"
44     #else:
45     #    tch=ch
46     tsmix2ts(pout + ".tsmix", pout, tch)
47     if os.access(pout, os.F_OK):
48         try:
49             #os.remove(path + "/" + t + ext)
50             ""
51         except:
52             ""
53 def b252ts(pout, ch, csch):
54     b252tsmix(pout + ".b25", pout + ".tsmix")
55     tch=u"0"
56     if csch!=u"0":
57         tch=csch
58     elif ch==u"101":
59         tch=u"101"
60     elif ch==u"102":
61         tch=u"102"
62     tsmix2ts(pout + ".tsmix", pout, tch)
63 def tv2b25ts(pout, ch, time):
64     exe = configreader.getConfPath('recpt1')
65     if len(ch) > 2:#BS/CSは100とかCS??とかなので3文字以上
66         status.changeBSCSRecording(1)
67     else:
68         status.changeTERecording(1)
69     try:
70         doexe = exe + ' ' + ch + ' ' + time + ' \'' + pout + '\''
71         recdblist.printutf8(doexe)
72         recdblist.addLog(pout, doexe, u"recpt1ログ-コマンド")
73         recdblist.addLog(pout, unicode(commands.getoutput(doexe.encode('utf-8')),'utf-8'), u"recpt1ログ-詳細")
74     except Exception, inst:
75         recdblist.addCommonlogEX(u"Error",u"tv2b25ts(tv2ts.py)", str(type(inst)),str(inst))
76     if len(ch) > 2:#BS/CSは100とかCS??とかなので3文字以上
77         status.changeBSCSRecording(-1)
78     else:
79         status.changeTERecording(-1)
80 def b252tsmix(pin, pout):
81     if not (os.path.exists(pout) and os.path.getsize(pin)>os.path.getsize(pout)*0.95 and os.path.getsize(pin)<os.path.getsize(pout)*1.05):
82         exe=""
83         if configreader.getConfPath('b25_remote')=="1":
84             try:
85                 exe = configreader.getConfPath('b25_env')+" && "
86             except:
87                 inst=u"b25_remoteがオンになっていますが、b25_envが設定されていないかコメントアウトされています。"
88                 recdblist.addCommonlogEX(u"Error",u"b252tsmix(tv2ts.py)", "",inst)
89         exe = exe + "nice -n 17 " + configreader.getConfPath('b25')
90         doexe = exe + u' \"' + pin + u'\" \"' + pout + u'\"'
91         recdblist.printutf8(doexe)
92         txt = unicode(commands.getoutput(doexe.encode('utf-8')),'utf-8')
93         recdblist.addLog(pin, doexe, u"b25ログ-コマンド")
94         recdblist.addLog(pin, txt, u"b25ログ-詳細")
95         return txt
96 def tsmix2ts(pin, pout, csch):#csch=0ならcsの処理をしない
97     doexe = configreader.getConfPath("tssplitter") + " \""+ pin + "\" \""+ pout + "\" " + str(csch)
98     doexe = "nice -n 18 " + doexe
99     os.environ['LANG']="ja_JP.UTF-8"
100     txt = unicode(commands.getoutput(doexe.encode('utf-8')),'utf-8')
101     recdblist.addLog(pin, doexe, u"TsSplitログ-コマンド")
102     recdblist.addLog(pin, txt, u"TsSplitログ-詳細")
103     time.sleep(1)
104     if os.access(pout, os.F_OK) and os.path.getsize(pout)>10*1000*1000:
105         os.remove(pin)
106