3 # Rec10 TS Recording Tools
4 # Copyright (C) 2009-2010 Yukikaze
15 print str.encode('utf-8')
17 version = recdblist.version
18 recdblist.printutf8(u"rec10の環境インストールを開始します。")
20 recdblist.printutf8(u"環境インストール処理中・・・")
21 path = str(os.path.dirname(os.path.abspath(__file__)))
22 confp = ConfigParser.SafeConfigParser()
25 if os.path.exists(os.path.join(path,Conf)):
26 confpath=os.path.join(path,Conf)
27 elif os.path.exists(os.path.join("/etc","rec10.conf")):
28 confpath=os.path.join("/etc","rec10.conf")
29 elif os.path.exists(os.path.join("/etc/rec10","rec10.conf")):
30 confpath=os.path.join("/etc/rec10","rec10.conf")
34 recdblist.printutf8(u"rec10.confが見つかりません。")
35 recdblist.printutf8(u"このinstall.pyと同じフォルダに置くか、/etc/rec10.confもしくは/etc/rec10/rec10.confにおいてください。")
37 recdblist.printutf8(u"設定ファイルの読み込みを確認//設定ファイルのパスは"+confpath)
38 if confp.get('path',"recpath")=="/path of /recording":
39 recdblist.printutf8(u"録画先のフォルダを設定してください(recpath=)")
41 recdblist.printutf8(u"DB処理に入ります")
42 if os.path.exists(os.path.join(path,"rec10d.py")):
45 except Exception, inst:
46 recdblist.printutf8(u"DB処理中にエラーが出ました。configファイルのDB設定を見直してください。")
47 recdblist.printutf8(str(type(inst)))
48 recdblist.printutf8(str(inst))
49 recdblist.printutf8(u"チャンネル設定に入ります")
50 if os.path.exists(os.path.join(path,"chlist.xml")):
51 recdblist.printutf8(u"チャンネルリストが見つかりました。||chlist.xml")
53 recdblist.printutf8(u"チャンネルリストが見つかりません。"+os.path.join(path,"chlist.xml")+u"を作成してください。")
54 recdblist.printutf8(u"東京/名古屋/神戸のサンプルがchlist_sample_*.xmlにあるため、参考にしてください。")
56 bsok=int(confp.get('env',"bs"))
57 csok=int(confp.get('env',"cs"))
59 chdata.new_chdata(bsok,csok)
60 recdblist.printutf8(u"おめでとうございます 初期設定は完了しました。")
61 recdblist.printutf8(u"rec10を実行するユーザーのcrontabに"+os.path.join(path,"rec10")+u"を追加してください(5分周期が目安)")
63 rec10d.rec10db.change_installed_in_status()
65 printutf8(cmd+u"の場所を確認中")
66 txt=commands.getoutput(u"which "+cmd)
67 if len(txt.split(" "))>3:
68 printutf8(cmd+u"の場所を確認できませんでした。終了します")
71 printutf8(cmd+u" : "+txt)
72 if len(txt.splitlines()):
73 txt=txt.splitlines()[0]
77 path = str(os.path.dirname(os.path.abspath(__file__)))
78 printutf8(u"rec10 ver 0.9.4 installer.")
79 printutf8(u"rec10のインストールを開始します。")
81 configwriter.setpath(u"wine", getpath(u"wine"))
82 configwriter.setpath(u"recpt1", getpath(u"recpt1"))
83 configwriter.setpath(u"x264", getpath(u"x264"))
84 configwriter.setpath(u"mp4box", getpath(u"MP4Box"))
85 configwriter.setpath(u"mencoder", getpath(u"mencoder"))
86 configwriter.setpath(u"ffmpeg", getpath(u"ffmpeg"))
87 #configwriter.setpath(u"xvfb-run", getpath(u"xvfb-run"))
88 configwriter.setpath(u"mkvmerge", getpath(u"mkvmerge"))
89 configwriter.setpath(u"b25", getpath(u"b25"))
90 printutf8(u"必須環境の設定が完了しました")
91 printutf8(u"個人設定に入ります")
92 if os.path.exists("/etc/rec10.conf"):
93 printutf8(u"以前の設定ファイルが見つかりました。")
94 printutf8(u"インポートしますか?")
95 useB=raw_input("[Y/n]:")
96 if useB=="N" or useB == "n":
100 printutf8(u"設定ファイルのインポーを行います。")
101 printutf8(u"rec10の録画ファイルが置かれる場所を入力してください(1/"+str(maxn)+")")
102 printutf8(u"100GB程度は確保されている必要があります")
103 recpath=getConf(useB,"/etc/rec10.conf","path","recpath","path : ")
104 configwriter.setpath(u"recpath",recpath)
105 printutf8(u"DBの設定に入ります。")
106 printutf8(u"rec10が使用するMySQLのユーザーを設定してください。(2/"+str(maxn)+")")
107 mysql_user=getConf(useB,"/etc/rec10.conf","db","mysql_user","mysql_user : ")
108 configwriter.setdbpath("mysql_user", mysql_user)
109 printutf8(u"パスワードを設定してください(3/"+str(maxn)+")")
110 mysql_passwd=getConf(useB,"/etc/rec10.conf","db","mysql_passwd","mysql_passwd : ")
111 configwriter.setdbpath("mysql_passwd", mysql_passwd)
112 printutf8(u"同時録画可能数の設定に入ります")
113 printutf8(u"TE(地デジ)録画可能数(PT*だと2 白Friioだと1)(4/"+str(maxn)+")")
114 te_max=str(int(getConf(useB,"/etc/rec10.conf","env","te_max","te_max : ")))
115 configwriter.setenv("te_max", te_max)
116 printutf8(u"BS/CS110録画可能数(PT*だと2 黒Friioだと1)(5/"+str(maxn)+")")
117 bscs_max=str(int(getConf(useB,"/etc/rec10.conf","env","bscs_max","bscs_max : ")))
118 configwriter.setenv("bscs_max", bscs_max)
119 printutf8(u"同時エンコード最大数を設定してください(6/"+str(maxn)+")")
120 printutf8(u"CPUのコア数が目安です")
121 enc_max=raw_input("[2]:")
125 enc_max=str(int(enc_max))
126 configwriter.setenv("enc_max", enc_max)
127 printutf8(u"二カ国語放送/5.1ch放送の音声変換の設定です。\nNeroAACエンコーダーを使用しますか?(NeroAACEncを別途入手してtstoolsに入れてください。))")
128 printutf8(u"入手先:http://www.nero.com/jpn/technologies-aac-codec.html\n (7/"+str(maxn)+")")
129 audioenc=raw_input("[y/N]: ")
130 if audioenc=="y" or audioenc=="Y":
131 configwriter.setpath("useNeroAAC", "1")
132 printutf8(u"NeroAACEncのパスを指定してください")
133 aacpath=getConf(useB,"/etc/rec10.conf","path","NeroAAC","[/usr/local/bin/neroAacEnc] : ")
134 if aacpath.replace(" ","")=="":
135 aacpath="/usr/local/bin/neroAacEnc"
136 configwriter.setpath("NeroAAC",aacpath)
138 configwriter.setpath("useNeroAAC", "0")
139 printutf8(u"lameを使用します。")
140 printutf8(u"保存する画質を教えてください(7/"+str(maxn)+")")
141 printutf8(u"x264のcrfの値です。標準だと30分で800MBほどになります")
142 crf=getConf(useB,"/etc/rec10.conf","env","crf","[24] : ")
143 if crf.replace(" ","")=="":
145 configwriter.setenv("crf", crf)
146 printutf8(u"アニメーションを保存する画質を教えてください(8/"+str(maxn)+")")
147 printutf8(u"x264のcrfの値です。標準だと30分で800MBほどになります")
148 a_crf=getConf(useB,"/etc/rec10.conf","env","animation_crf","[20] : ")
149 if a_crf.replace(" ","")=="":
151 configwriter.setenv("animation_crf", a_crf)
152 printutf8(u"x264の圧縮率を設定してください(8/"+str(maxn)+")")
153 printutf8(u"x264のpresetの値です。標準だとmedium、小さければ小さいほど高圧縮になります")
154 preset=getConf(useB,"/etc/rec10.conf","env","x264_preset","[4] : ")
155 if preset.replace(" ","")=="":
157 configwriter.setenv("x264_preset", preset)
158 printutf8(u"保存するコンテナの設定(9/"+str(maxn)+")")
159 printutf8(u"MP4を標準にしますか(もしくはMKVが使えます)")
160 useMP4=raw_input("[y/N]:")
161 if useMP4=="Y" or useMP4 == "y" :
165 configwriter.setenv("make_mp4", useMP4)
166 printutf8(u"TSファイルの自動削除(10/"+str(maxn)+")")
167 printutf8(u"中間体のtsファイルを削除しますか")
168 printutf8(u"(削除するとやり直しができないため残しておくことを推奨します。)")
169 removeTS=raw_input("[y/N]:")
170 if removeTS=="Y" or removeTS == "y" :
174 configwriter.setenv("remove_ts", removeTS)
175 printutf8(u"チャンネルの設定に入ります(11/"+str(maxn)+")")
176 printutf8(u"rec10を設置する地域を選んでください。")
177 printutf8(u"1:東京 2:神戸 3:名古屋 4:その他")
182 shutil.copy(os.path.join(path,"chlist_sample_tokyo.xml"),os.path.join(path,"chlist.xml"))
184 printutf8(u"既存のchlis.xmlを上書きできないため、前のものを使います。")
187 shutil.copy(os.path.join(path,"chlist_sample_kobe.xml"),os.path.join(path,"chlist.xml"))
189 printutf8(u"既存のchlis.xmlを上書きできないため、前のものを使います。")
192 shutil.copy(os.path.join(path,"chlist_sample_nagoya.xml"),os.path.join(path,"chlist.xml"))
194 printutf8(u"既存のchlis.xmlを上書きできないため、前のものを使います。")
196 if not os.path.exists(os.path.join(path,"chlist.xml")):
197 printutf8(u"チャンネルの設定が必要です。")
198 printutf8(u"chlist_sample_*を参考にchlist.xmlを作成した後に次のステップに進んでください。")
200 printutf8(u"BS放送は受信可能ですか?(12/"+str(maxn)+")")
201 bsok=raw_input("y/N:")
202 if bsok=="Y" or bsok == "y" :
206 configwriter.setenv("bs", bsok)
207 printutf8(u"CS放送(スカパーe2)は受信可能ですか?(13/"+str(maxn)+")")
208 csok=raw_input("y/N:")
209 if csok=="Y" or csok == "y" :
211 printutf8(u"標準パックの番組は入力してありますがそれ以外は追加でchlist_cs.xmlに追加する必要があります。")
214 configwriter.setenv("cs", csok)
216 printutf8(u"自機識別オプション(14/"+str(maxn)+")")
217 printutf8(u"本rec10の識別名を入力してください")
218 printutf8(u"複数台のrec10を運用する場合に効果的です。空白でもかまいません。")
219 printutf8(u"例 kobe01")
220 iff=getConf(useB,"/etc/rec10.conf","env","iff","[] : ")
221 configwriter.setenv("iff", iff)
222 confp = ConfigParser.SafeConfigParser()
223 confp.read("/etc/rec10.conf")
225 configwriter.setpath("recorded",confp.get("path","recorded"))
226 configwriter.setpath("move_destpath",confp.get("path","move_destpath"))
227 configwriter.setpath("tmp",confp.get("path","tmp"))
229 configwriter.setenv("x264_addline",confp.get("env","x264_addline"))
231 configwriter.setenv("x264_addline","")
232 if confp.get("path","b25_remote")=="":
233 configwriter.setpath("b25_remote", "0")
234 elif confp.get("path","b25_remote")=="1":
235 configwriter.setpath("b25_remote", confp.get("path","b25_remote"))
236 configwriter.setpath("b25", confp.get("path","b25"))
237 configwriter.setpath("b25_env", confp.get("path","b25_env"))
239 configwriter.setpath("b25_remote", confp.get("path","b25_remote"))
241 configwriter.writeconf()
242 printutf8(u"初期設定が終了しました。")
243 printutf8(u"makeを実行した後にrootにてmake installを実行するとインストールされます。")
244 def getConf(useBeforeConf,Confpath,dbsection,key,defaultstr):
246 if os.path.exists(Confpath) and useBeforeConf==1:
248 confp = ConfigParser.SafeConfigParser()
249 confp.read("/etc/rec10.conf")
250 tstr=u"["+confp.get(dbsection,key)+u"]:"
253 tmpconf=raw_input(tstr)
254 if tmpconf.replace(" ","")=="" and os.path.exists(Confpath) and useBeforeConf==1 :
255 confp = ConfigParser.SafeConfigParser()
256 confp.read("/etc/rec10.conf")
258 tmpconf=confp.get(dbsection,key)
265 if rec10d.rec10db.select_installed_in_status()==1:
266 if rec10d.rec10db.select_version_in_status()==0:
268 recdblist.printutf8(u"既存のDBが見つかりました。0.9.1と仮定してアップデート処理を行います。")
272 recdblist.printutf8(u"既存のDBが見つかりました。アップデート処理を行います。")
273 tversion=int(rec10d.rec10db.select_version_in_status())
274 while (recdblist.version>tversion):
276 tversion=int(rec10d.rec10db.select_version_in_status())
278 rec10d.rec10db.drop_in_status()
279 rec10d.rec10db.drop_in_settings()
281 rec10d.rec10db.new_in_status()
282 rec10d.rec10db.new_in_settings()
283 rec10d.rec10db.change_version_in_status(recdblist.version)
284 def update_db(version):
287 rec10d.rec10db.update_db_to93()
289 rec10d.rec10db.update_db_93to94()
290 if __name__ == "__main__":