- 5CFF8BF56C249454F81E92CBE693DD68ED16626918E9FCE4F159B1173C2C1A58CC66CF9EB4925CF7B97C969FDF834F56B0DAFD1BBDF249456C9CE610E2F238C6+ BFEC2394FBF0F13088BF392EE6946E964A58343B3C7400AC87206212B52D6295738FB17AA100410442BBBAFCE4FBC09DA32C22EA3E52FD379CCA4F302BE7A735logotron/reader.py(17 . 7)(17 . 7)
53 import re
54 from datetime import datetime
55 from urlparse import urljoin
56 from flask import Flask, request, session, url_for, redirect, \
57 from flask import Flask, request, session, url_for, redirect, Response, \
58 render_template, abort, g, flash, _app_ctx_stack, make_response, \
59 jsonify
60 from flask import Flask
(45 . 10)(45 . 12)
62 # DBism:
63 DB_Name = cfg.get("db", "db_name")
64 DB_User = cfg.get("db", "db_user")
65 DB_DEBUG = cfg.get("db", "db_debug")
66 DB_DEBUG = int(cfg.get("db", "db_debug"))
67 # Logism:
68 Base_URL = cfg.get("logotron", "base_url")
69 Era = int(cfg.get("logotron", "era"))
70 DEBUG = int(cfg.get("logotron", "www_dbg"))
71 Max_Raw_Ln = int(cfg.get("logotron", "max_raw"))
72 # WWW:
73 WWW_Port = int(cfg.get("logotron", "www_port"))
74
(66 . 9)(68 . 6)
76
77 ## Format for Date in Log Lines
78 Date_Short_Format = "%Y-%m-%d"
79
80 ## WWW Debug Knob
81 DEBUG = False
82 ##############################################################################
83
84 app = Flask(__name__)
(368 . 6)(367 . 48)
86 tail = tail)
87
88
89 @app.route('/log-raw/<chan>')
90 def rawlog(chan):
91 res = ""
92
93 # Handle rubbish chan:
94 if chan not in Channels:
95 return Response("EGGOG: No such Channel!", mimetype='text/plain')
96
97 # Get start and end indices:
98 idx_start = request.args.get('istart', default = 0, type = int)
99 idx_end = request.args.get('iend', default = 0, type = int)
100
101 # Malformed bounds?
102 if idx_start > idx_end:
103 return Response("EGGOG: Start must precede End!",
104 mimetype='text/plain')
105
106 # Demanded too many in one burst ?
107 if (idx_end - idx_start) > Max_Raw_Ln :
108 return Response("EGGOG: May request Max. of %s Lines !" % Max_Raw_Ln,
109 mimetype='text/plain')
110
111 # Get the loglines from DB
112 lines = query_db(
113 '''select * from loglines where chan=%s
114 and idx between %s and %s order by idx asc;''',
115 [chan, idx_start, idx_end], one=False)
116
117 # Retrieve raw lines in classical Phf format:
118 for l in lines:
119 action = ""
120 if l['self']:
121 action = "*;"
122 res += "%s;%s;%s%s;%s\n" % (l['idx'],
123 l['t'].strftime('%s'),
124 action,
125 l['speaker'],
126 l['payload'])
127
128 # Return plain text:
129 return Response(res, mimetype='text/plain')
130
131
132 Name_Chars = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-"
133