OSDN Git Service

implement iepg data adding on web.
authorgn64_jp <gn64_jp@4e526526-5e11-4fc0-8910-f8fd03428081>
Mon, 31 Aug 2009 08:29:19 +0000 (08:29 +0000)
committergn64_jp <gn64_jp@4e526526-5e11-4fc0-8910-f8fd03428081>
Mon, 31 Aug 2009 08:29:19 +0000 (08:29 +0000)
git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/rec10@137 4e526526-5e11-4fc0-8910-f8fd03428081

Rec10WEB/trunk/src/fin.htm
Rec10WEB/trunk/src/finover.htm
Rec10WEB/trunk/src/iepg_add.htm [new file with mode: 0644]
Rec10WEB/trunk/src/iepg_fin.htm [new file with mode: 0644]
Rec10WEB/trunk/src/iepg_show.htm [new file with mode: 0644]
Rec10WEB/trunk/src/rec10web.py
Rec10WEB/trunk/src/rec10web_dbMySQL.py
Rec10WEB/trunk/src/rswi.htm

index 0c374d7..8c773b4 100644 (file)
@@ -3,9 +3,10 @@
     <head>
         <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
         <meta http-equiv="refresh" content="3; url=rec10web.py">
-        <title>Rec10 Simple Web Interface ver.0.6.0</title>
+        <title>Rec10 Simple Web Interface ver.0.7.0</title>
     </head>
-    <h1>Rec10 Simple Web Interface ver.0.6.0</h1><br>
+    <body>
+    <h1>Rec10 Simple Web Interface ver.0.7.0</h1><br>
     <br>
     予約が終了しました。移動します。
     </body>
index aded4b2..1a0b6ac 100644 (file)
@@ -3,9 +3,10 @@
     <head>
         <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
         <meta http-equiv="refresh" content="3; url=rec10web.py">
-        <title>Rec10 Simple Web Interface ver.0.6.0</title>
+        <title>Rec10 Simple Web Interface ver.0.7.0</title>
     </head>
-    <h1>Rec10 Simple Web Interface ver.0.6.0</h1><br>
+    <body>
+    <h1>Rec10 Simple Web Interface ver.0.7.0</h1><br>
     <br>
     最大録画可能数を越えています。
     </body>
diff --git a/Rec10WEB/trunk/src/iepg_add.htm b/Rec10WEB/trunk/src/iepg_add.htm
new file mode 100644 (file)
index 0000000..53e0eb2
--- /dev/null
@@ -0,0 +1,48 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+  <head>
+    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+    <title>Rec10 Simple Web Interface ver.0.7.0 iEPGデータ追加</title>
+    <script src="./dojo/dojo/dojo.js" djConfig="parseOnLoad:true">
+        </script>
+        <!-- テーマの読み込み -->
+        <style type="text/css">
+            @import "./dojo/dojo/resources/dojo.css";
+            @import "./dojo/dijit/themes/tundra/tundra.css";
+
+
+        </style>
+        <script type="text/javascript">
+
+            dojo.require("dojo.parser");
+            // ※ ここで、使用するウィジェットの読み込みを行う
+            dojo.require("dijit.form.Button");
+            dojo.require("dijit.form.TextBox");
+            dojo.require("dijit.form.Form");
+        </script>
+  </head>
+  <body class="tundra">
+    <div dojoType="dijit.form.Form" action="rec10web.py" onExecute="this.submit()">
+        <h1>Rec10 Simple Web Interface ver.0.7.0 iEPGデータ追加</h1><br>
+        <input type="text"
+                   length="40"
+                   dojoType="dijit.form.TextBox"
+                   value="<!--iepg_title-value//-->"
+                   id="iepg_station"
+        name="iepg_station">
+        <select name="iepg_chtxt"
+                    dojoType="dijit.form.FilteringSelect"
+                    autocomplete="false"
+                    value="<!--ch-value//-->"
+                    onChange="setType">
+                <!--text_for_replace_chtxt_input//-->
+        </select>
+        <div dojoType="dijit.form.Button" type="submit">追加</div>
+        <div name="exec"
+                 dojoType="dijit.form.ValidationTextBox"
+                 value="iepg-add_yes"
+                 style="display:none">
+        </div>
+    </div>
+  </body>
+</html>
diff --git a/Rec10WEB/trunk/src/iepg_fin.htm b/Rec10WEB/trunk/src/iepg_fin.htm
new file mode 100644 (file)
index 0000000..861b789
--- /dev/null
@@ -0,0 +1,12 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+  <head>
+    <title></title>
+    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+  </head>
+  <body>
+    <h1>Rec10 Simple Web Interface ver.0.7.0</h1><br>
+    epgデータの追加を完了しました。<br>
+    録画を行う場合はもう一度おねがいします。<br>
+  </body>
+</html>
diff --git a/Rec10WEB/trunk/src/iepg_show.htm b/Rec10WEB/trunk/src/iepg_show.htm
new file mode 100644 (file)
index 0000000..0a376e3
--- /dev/null
@@ -0,0 +1,40 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+  <head>
+    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+    <title>Rec10 Simple Web Interface ver.0.7.0 iEPGデータ表示</title>
+    <script src="./dojo/dojo/dojo.js" djConfig="parseOnLoad:true">
+        </script>
+        <!-- テーマの読み込み -->
+        <style type="text/css">
+            @import "./dojo/dojo/resources/dojo.css";
+            @import "./dojo/dijit/themes/tundra/tundra.css";
+
+
+        </style>
+        <script type="text/javascript">
+
+            dojo.require("dojo.parser");
+            // ※ ここで、使用するウィジェットの読み込みを行う
+            dojo.require("dijit.form.Button");
+            dojo.require("dijit.form.TextBox");
+            dojo.require("dijit.form.Form");
+            var iepgStore = new dojo.data.ItemFileWriteStore({data:{items:[
+                        <!--text_for_replace_iepg//-->
+            ]}});
+        </script>
+  </head>
+  <body class="tundra">
+    <div dojoType="dijit.form.Form" action="rec10web.py" onExecute="this.submit()">
+        <h1>Rec10 Simple Web Interface ver.0.7.0 iEPGデータ表示</h1><br>
+        <table dojoType="dojox.grid.DataGrid" id="iepggrid" store="iepgStore">
+            <thead>
+                <tr>
+                    <th field="name" width="auto">放送局名</th>
+                    <th field="chtxt" width="auto">内部放送局コード(chtxt)</th>
+                </tr>
+            </thead>
+        </table>
+    </div>
+  </body>
+</html>
index a81592f..1edceeb 100644 (file)
@@ -12,17 +12,19 @@ import datetime
 import rec10web_dbSQLite
 import ConfigParser
 import time
+
 path=str(os.path.dirname(os.path.abspath(__file__)))+"/"
 confp=ConfigParser.SafeConfigParser()
 Conf='config.ini'
 confp.read(path+Conf)
+global f
+f=cgi.FieldStorage()
 def getpath(string):
     global confp
     return confp.get('path',string)
 def getdbpath(string):
     global confp
     return confp.get('db',string)
-
 def getdb():
     retdb=""
     if getdbpath('db')=='MySQL':
@@ -95,7 +97,6 @@ def getchtxt():
 def edit_date(id):
     ret=database.select_by_id_rectime(id)
     return ret[0]
-
 def reserv_recday(keyword,chtxt,btime,etime,deltatime,opt,deltaday,day):
     """
     dayは月曜日を1日曜日を7とした数字
@@ -210,13 +211,11 @@ def change_reserv(id,type,keyword,chtxt,btime,etime,deltatime,opt,deltaday):
     return rett
 def station2chtxt(station):
     ret=""
-    for bctype, ontv, chtxt, ch, csch ,updatetime in database.select_by_station_chdata(station):
-        ret=chtxt
-    return ret
-def station_name2chtxt(station):
-    ret=""
-    for bctype, ontv, chtxt, ch, csch ,updatetime in database.select_by_station_name_chdata(station):
-        ret=chtxt
+    sta=database.select_by_station_iepg(station):
+    if len(sta)>0:
+        ret=sta[0][1]
+    else:
+        ret="n\/a"
     return ret
 def readHtmlSrcSimple():
     f = open(path+'rswi.htm')
@@ -244,27 +243,83 @@ def readRecSchedule():
     ret=f.read()
     f.close()
     return ret
+def readiEPGadd():
+    f = open(path+'iepg_add.htm')
+    ret=f.read()
+    f.close()
+    return ret
+def readiEPGfin():
+    f = open(path+'iepg_fin.htm')
+    ret=f.read()
+    f.close()
+    return ret
+def readiEPGshow():
+    f = open(path+'iepg_show.htm')
+    ret=f.read()
+    f.close()
+    return ret
+def mode_iepg_add(station):
+    htmdate=readiEPGadd()
+    htmdate=htmdate.replace("<!--text_for_replace_chtxt_input//-->",getchtxt())
+    htmdate=htmdate.replace("<!--ch-value//-->","")
+    htmdate=htmdate.replace("<!--iepg_title-value//-->",station)
+    return htmdate
+def mode_iepg_fin():
+    htmdate=readiEPGfin()
+    return htmdate
+def mode_iepg_show():
+    htmdate=readiEPGshow()
+    lsts=database.select_all_iepg()
+    s=""
+    for lst in lsts:
+        s=s+"{name:\""+lst[0]+"\",chtxt:\""+lst[1]+"\"},\n"
+    return htmdate
+def mode_schedule():
+    htmdate=readRecSchedule()
+    return htmdate
+def mode_edit():
+    editnum=exect.replace("edit:","")
+    htmdate= readHtmlEdit()
+    iddata=edit_date(editnum)
+    htmdate=htmdate.replace("<!--text_for_replace_chtxt_input//-->",getchtxt())
+    htmdate=htmdate.replace("<!--ch-value//-->",iddata['chtxt'])
+    htmdate=htmdate.replace("<!--btime-value//-->",iddata['btime'])
+    htmdate=htmdate.replace("<!--etime-value//-->",iddata['etime'])
+    htmdate=htmdate.replace("<!--type-value//-->",iddata['type'])
+    htmdate=htmdate.replace("<!--ch-value//-->",iddata['chtxt'])
+    htmdate=htmdate.replace("<!--title-value//-->",iddata['title'])
+    htmdate=htmdate.replace("<!--size-value//-->",size)
+    htmdate=htmdate.replace("<!--opts-value//-->",iddata["opt"])
+    htmdate=htmdate.replace("<!--exec-value//-->","edit-exec:"+editnum)
+    return htmdate
 dbpath=path+"ch.db"
 database=getdb()
-f=cgi.FieldStorage()
-
 btime=""
 etime=""
 title=""
 chtxt=""
 type="res"
 bt=""
+station_name=""
+mode=""
 getRecDate()
 if f.getfirst('mode')=="schedule":
     getRecDate()
-
 ###ここからiEPG用の読み出し
 if f.getfirst('station_name'):
     station=f.getfirst('station_name')
-    chtxt=station_name2chtxt(station)
+    chtxt=station2chtxt(station)
+    if chtxt=="n\/a":
+        mode="iepg-add"
+        station_name=station
+        exect="iepg-add"
 if f.getfirst('station'):
     station=f.getfirst('station')
     chtxt=station2chtxt(station)
+    if chtxt=="n\/a":
+        mode="iepg-add"
+        station_name=station
+        exect="iepg-add"
 ###ここから外部からの読み出しの場合
 if f.getfirst('type'):
     type=f.getfirst('type')
@@ -274,11 +329,9 @@ if f.getfirst('chtxt'):
     chtxt=f.getfirst('chtxt')
 if f.getfirst('btime'):
     btime=f.getfirst('btime')
-    #bt=datetime.datetime.strptime(btime,"%Y-%m-%d %H:%M:%S")
     bt=datetime.datetime(*time.strptime(btime,"%Y-%m-%d %H:%M:%S")[:-3])
 if f.getfirst('etime'):
     etime=f.getfirst('etime')
-    #et=datetime.datetime.strptime(etime,"%Y-%m-%d %H:%M:%S")
     et=datetime.datetime(*time.strptime(etime,"%Y-%m-%d %H:%M:%S")[:-3])
     if bt !="":
         delt=et-bt
@@ -308,6 +361,16 @@ if f.getfirst('deltaday',""):
 exect=""
 if f.getfirst('exec',""):
     exect=f.getfirst('exec',"")
+if exect=="schedule":
+    mode="schedule"
+elif re.search('edit:',exect):
+    mode="edit"
+elif exect=="iepg-add":
+    mode="iepg-add"
+elif exect=="iepg-show":
+    mode="iepg-show"
+elif exect=="iepg-add_yes"
+    mode="iepg-add-yes"
 htmdate= readHtmlSrcSimple()
 htmdate=htmdate.replace("<!--text_for_replace_chtxt_input//-->",getchtxt())
 htmdate=htmdate.replace("<!--btime-value//-->",btime)
@@ -354,7 +417,6 @@ if (chtxt != "")and(title != "")and(btime!="")and(etime!="")and(opts!="")and(exe
     elif restxt=="over":
         htmdate=readRecFinisOver()
     exect=""
-#
 if (chtxt != "")and(title != "")and(btime!="")and(etime!="")and(opts!="")and(re.search('edit-exec:',exect)):
     editnum=exect.replace("edit-exec:","")
     #restxt=change_reserv(id, type, keyword, chtxt, btime, etime, deltatime, opt, deltaday)
@@ -364,22 +426,19 @@ if (chtxt != "")and(title != "")and(btime!="")and(etime!="")and(opts!="")and(re.
     elif restxt=="over":
         htmdate=readRecFinisOver()
     exect=""
-if exect=="schedule":
-    htmdate=readRecSchedule()
-if re.search('edit:',exect):
-    editnum=exect.replace("edit:","")
-    htmdate= readHtmlEdit()
-    iddata=edit_date(editnum)
-    htmdate=htmdate.replace("<!--text_for_replace_chtxt_input//-->",getchtxt())
-    htmdate=htmdate.replace("<!--ch-value//-->",iddata['chtxt'])
-    htmdate=htmdate.replace("<!--btime-value//-->",iddata['btime'])
-    htmdate=htmdate.replace("<!--etime-value//-->",iddata['etime'])
-    htmdate=htmdate.replace("<!--type-value//-->",iddata['type'])
-    htmdate=htmdate.replace("<!--ch-value//-->",iddata['chtxt'])
-    htmdate=htmdate.replace("<!--title-value//-->",iddata['title'])
-    htmdate=htmdate.replace("<!--size-value//-->",size)
-    htmdate=htmdate.replace("<!--opts-value//-->",iddata["opt"])
-    htmdate=htmdate.replace("<!--exec-value//-->","edit-exec:"+editnum)
+if mode=="schedule":
+    htmdate=mode_normal()
+elif mode=="edit":
+    htmdate=mode_edit()
+elif mode=="iepg-add":
+    htmdate=mode_iepg_add(f.getfirst('iepg_station'))
+elif mode=="iepg-add-yes":
+    if f.getfirst('iepg_station') and f.getfirst('iepg_chtxt'):
+        database.add_iepg(f.getfirst('iepg_station'),f.getfirst('iepg_chtxt'))
+    htmdate=mode_iepg_fin()
+elif mode=="iepg-show":
+    htmdate=mode_iepg_show()
 print "Content-Type: text/html\n"
 print htmdate
 
+
index 65dcb91..6366402 100644 (file)
@@ -183,4 +183,50 @@ class DB_MySQL:
     def del_by_id_rectime(self,id):
         db=self.connect_db()
         db[1].execute('DELETE FROM rectime WHERE id='+id)
-        self.close_db(db)
\ No newline at end of file
+        self.close_db(db)
+    def new_iepg(self):
+        db=self.connect_db()
+        db[1].execute("\
+        CREATE TABLE iepg \
+            (\
+            station VARCHAR(200) NOT NULL,\
+            chtxt VARCHAR(30) NOT NULL,\
+            UNIQUE uniepg(type,chtxt)\
+            )")
+        self.close_db(db)
+    def add_iepg(self,station,chtxt):
+        db=self.connect_db()
+        db[1].execute('INSERT IGNORE INTO iepg VALUES (%s,%s)', (station,chtxt))
+        self.close_db(db)
+    def select_by_chtxt_iepg(self,chtxt):
+        db=self.connect_db()
+        db[1].execute("\
+        SELECT \
+        station,chtxt \
+        FROM iepg \
+        WHERE chtxt=%s "\
+        ,(chtxt,))
+        retall=db[1].fetchall()
+        self.close_db(db)
+        return retall
+    def select_by_station_iepg(self,station):
+        db=self.connect_db()
+        db[1].execute("\
+        SELECT \
+        station,chtxt \
+        FROM iepg \
+        WHERE station=%s "\
+        ,(station,))
+        retall=db[1].fetchall()
+        self.close_db(db)
+        return retall
+    def select_all_iepg(self):
+        db=self.connect_db()
+        db[1].execute("\
+        SELECT \
+        station,chtxt \
+        FROM iepg "\
+        ,(station,))
+        retall=db[1].fetchall()
+        self.close_db(db)
+        return retall
\ No newline at end of file
index e299d7c..8b6c93d 100644 (file)
     <!-- テーマの読み込み -->
     <body class="tundra">
         <div dojoType="dijit.form.Form" action="rec10web.py" onExecute="this.submit()">
-        <h1>Rec10 Simple Web Interface ver.0.6.0</h1><br>
+        <h1>Rec10 Simple Web Interface ver.0.7.0</h1><br>
         <select name="type"
                 dojoType="dijit.form.FilteringSelect"
                 autocomplete="false"