- C9A1CB11F1BCA0D8EE8F1351F0E2AD9AEA8D6E33D5915372854DF0352563FFF72D867002D17E0FD5A1A9475066EEC9078C20C3BDB5B81009456AC44290BF2660
+ 8AC522F24E0ADD9BA37C81161EDBB0BA5FE70DF54C03E73FC8A6A60BAC3BF993D1530088C5A3A8A7CAA90DB67EE6B3CDAE75A15B4C6D698ED3D95AFF12E54626
logotron/reader.py
(25 . 13)(25 . 15)
94
95 ##############################################################################
96 # Single mandatory arg: config file path
97
98 if len(sys.argv[1:]) != 1:
99 # If no args, print usage and exit:
100 print sys.argv[0] + " CONFIG"
101 exit(0)
102 # Default path for WSGI use (change to yours) :
103 config_path = "/home/nsabot/logger/nsabot.conf"
104 else:
105 # Read Config from given conf file
106 config_path = sys.argv[1]
107
108 # Read Config from given conf file
109 config_path = os.path.abspath(sys.argv[1])
110 #config_path = os.path.abspath(config_path)
111 cfg = ConfigParser.ConfigParser()
112 cfg.readfp(open(config_path))
113
(50 . 6)(52 . 7)
115 Era = int(cfg.get("logotron", "era"))
116 DEBUG = int(cfg.get("logotron", "www_dbg"))
117 Max_Raw_Ln = int(cfg.get("logotron", "max_raw"))
118 Days_Hide = int(cfg.get("logotron", "days_hide"))
119 # WWW:
120 WWW_Port = int(cfg.get("logotron", "www_port"))
121
(150 . 27)(153 . 29)
123 l['t'].strftime(Date_Short_Format),
124 l['idx'])
125
126 def gen_chanlist(selected_chan):
127 def gen_chanlist(selected_chan, show_all_chans=False):
128 # Get current time
129 now = datetime.now()
130
131 s = """<table align="center" class="chantable"><tr>"""
132 # Data for channel display :
133 chan_tbl = {}
134 for chan in Channels:
135 chan_tbl[chan] = {}
136 chan_tbl[chan]['show'] = False
137
138 chan_formed = chan
139 if chan == selected_chan:
140 chan_formed = "<span class='highlight'>" + chan + "</span>"
141 s += """<th><a href="{0}log/{1}">{2}</a></th>""".format(
142
143 chan_tbl[chan]['link'] = """<a href="{0}log/{1}"><b>{2}</b></a>""".format(
144 get_base(), chan, chan_formed)
145 s += "</tr><tr>"
146
147 for chan in Channels:
148
149
150 last_time = query_db(
151 '''select t, idx from loglines where chan=%s
152 and idx = (select max(idx) from loglines where chan=%s) ;''',
153 [chan, chan], one=True)
154
155 last_time_txt = ""
156 time_field = ""
157 if last_time != None:
158 span = (now - last_time['t'])
159 days = span.days
(183 . 19)(188 . 31)
161 last_time_txt += '%dh ' % hours
162 if minutes != 0:
163 last_time_txt += '%dm' % minutes
164
165 s += """<td><i><a href="{0}log/{1}/{2}#{3}">{4}</a></i></td>""".format(
166
167 time_field = """<i><a href="{0}log/{1}/{2}#{3}">{4}</a></i>""".format(
168 get_base(),
169 chan,
170 last_time['t'].strftime(Date_Short_Format),
171 last_time['idx'],
172 last_time_txt)
173
174 else:
175 last_time_txt = ""
176 s += "<td></td>"
177 if (days <= Days_Hide) or (chan == selected_chan) or show_all_chans:
178 chan_tbl[chan]['show'] = True
179
180 s += "</tr></table>"
181 chan_tbl[chan]['time'] = time_field
182
183 ## Generate channel selector bar :
184 s = """<table align="center" class="chantable"><tr>"""
185 for chan in Channels:
186 if chan_tbl[chan]['show']:
187 s += """<th>{0}</th>""".format(chan_tbl[chan]['link'])
188 s += "</tr><tr>"
189 ## Generate last-activ. links for above :
190 for chan in Channels:
191 if chan_tbl[chan]['show']:
192 s += """<td>{0}</td>""".format(chan_tbl[chan]['time'])
193 # wrap up:
194 s += "</tr>"
195 return s
196
197
(356 . 6)(373 . 9)
199
200 # Get possible 'reverse gear'
201 rev = request.args.get('rev', default = 0, type = int)
202
203 # Get possible 'show all'
204 show_all = request.args.get('all', default = 0, type = int)
205
206 # Get current time
207 now = datetime.now()
(398 . 7)(418 . 9)
209 sel = (sel_start, sel_end),
210 date = date,
211 tail = tail,
212 rev = not rev)
213 rev = not rev,
214 show_all = show_all,
215 idle_day = Days_Hide)
216
217
218 @app.route('/log-raw/<chan>')