OSDN Git Service

add ch scan and installer.
[rec10/rec10-git.git] / rec10 / trunk / src / install.py
1 #!/usr/bin/python
2 # coding: UTF-8
3 # Rec10 TS Recording Tools
4 # Copyright (C) 2009 Yukikaze
5 import time
6 import os.path
7
8 import chdata
9 import recdblist
10 def install():
11     recdblist.printutf8(u"rec10のインストールを開始します。")
12     time.sleep(1)
13     recdblist.printutf8(u"インストール処理中・・・")
14     path = str(os.path.dirname(os.path.abspath(__file__)))
15     confp = ConfigParser.SafeConfigParser()
16     Conf = 'rec10.conf'
17     confpath=""
18     if os.path.exists(os.path.join(path,Conf)):
19         confpath=os.path.join(path,Conf)
20     elif os.path.exists(os.path.join("/etc","rec10.conf")):
21         confpath=os.path.join("/etc","rec10.conf")
22     elif os.path.exists(os.path.join("/etc/rec10","rec10.conf")):
23         confpath=os.path.join("/etc/rec10","rec10.conf")
24     if confpath!="":
25         confp.read(confpath)
26     else:
27         recdblist.printutf8(u"rec10.confが見つかりません。")
28         recdblist.printutf8(u"このinstall.pyと同じフォルダに置くか、/etc/rec10.confもしくは/etc/rec10/rec10.confにおいてください。")
29         sys.exit(1)
30     recdblist.printutf8(u"設定ファイルの読み込みを確認//設定ファイルのパスは"+confpath)
31     if confp.get('path',"recpath")=="/path of /recording":
32         recdblist.printutf8(u"録画先のフォルダを設定してください(recpath=)")
33         sys.exit(1)
34     recdblist.printutf8(u"DB処理に入ります")
35     if os.path.exists(os.path.join(path,"rec10d.py")):
36         try:
37             import rec10d
38         except Exception, inst:
39             recdblist.printutf8(u"DB処理中にエラーが出ました。configファイルのDB設定を見直してください。")
40             print type(inst)
41             print inst
42     recdblist.printutf8(u"チャンネル設定に入ります")
43     recdblist.printutf8(u"BS放送は受信可能ですか?")
44     bsok=raw_input("y/N")
45     if bsok=="Y" or bsok == "y" :
46         bsok=1
47     else:
48         bsok=0
49     recdblist.printutf8(u"CS放送は受信可能ですか?")
50     csok=raw_input("y/N")
51     if csok=="Y" or csok == "y" :
52         csok=1
53     else:
54         csok=0
55     chdata.new_chdata(bsok,csok)
56     recdblist.printutf8(u"チャンネルスキャンの開始(現在放送停止中のものはうまくとれません)")
57     import scan_ch
58     scan_ch.scan_ch()
59     recdblist.printutf8(u"チャンネルスキャン完了")
60     recdblist.printutf8(u"おめでとうございます 初期設定は完了しました。")
61     recdblist.printutf8(u"rec10を実行するユーザーのcrontabに"+os.path.join(path,"rec10")+"を追加してください(5分周期が目安)")
62     rec10d.rec10db.change_installed_in_status()
63     timerec.task()
64 if __name__ == "__main__":
65     install()