diff -uNr a/logotron/MANIFEST.TXT b/logotron/MANIFEST.TXT --- a/logotron/MANIFEST.TXT 46aa85dc41260ed3901fcc47ab6d238e7923b2c48870c88d606e158869ea517b5fe5a93456ab5d628e84a2c844f1b86efb1ab091af22a2d93e1a28f65356c990 +++ b/logotron/MANIFEST.TXT a1be0a9cd5f7ffbc471ee3677c4d670e6cf3754bd0dd96bf29e7e061c6fe8631422208fbc9137e797431963ffb5b479a532620a223fb4d80b1619069b47a22f1 @@ -1,2 +1,3 @@ 589248 logotron_genesis "Genesis." 589480 multsel_and_datefix "Multiline selections and fix for date arrow." +589662 raw_line_export "Export lines in Phf format; fix for debug knob." diff -uNr a/logotron/README.txt b/logotron/README.txt --- a/logotron/README.txt 2209f578062ecc5636e67fcb9904cd26204c832ffd170b373773b6b6e1bd1fb85e79e99be44a49bb1aabc99cdae4f6df4cef203bdadbe3773c3586048a61888f +++ b/logotron/README.txt 45fa8f8a0d6e12ede0c94ba6b85a7b43b8409ba841127decb2409df358dbb5c3ee6c5f2b5c17f3f5fa8829abc7ac38c979bf628ce447bd419ace2078cf3d5d8d @@ -65,9 +65,18 @@ (3) Double-quoted search terms. (4) Paste archiving. (5) Multi-headed IRC bot for weather resistance. -(6) 'Ecologically clean' export of raw log material. -(7) Informative eggogology for bot commands. -(8) Automatic synchronization with mirrors (see 6) +(6) Informative eggogology for bot commands. +(7) Automatic synchronization with mirrors A ZNC log eater is also required, to properly fill in the archives. This is not yet available at the time of this writing. + +############### +Aug. 11 Update: +############### + +(1) Multi-line selection is implemented. + +(2) User may request export of raw log lines in Phf-classical format. + E.g. : + http://logs.nosuchlabs.com/log-raw/trilema?istart=1925000&iend=1925500 diff -uNr a/logotron/nsabot.conf b/logotron/nsabot.conf --- a/logotron/nsabot.conf b02775926d528d67d44fa777248a014d1f5a37fc3486042a4a6e8a2ceb77651fc1681abff6e57e35a1e48e5896d4534c69759ac86bdc85ec1161f661811fcdb4 +++ b/logotron/nsabot.conf 61c5df75c043b567b3f5fc2150c4d7c1d31b6fd04a356cfc9280728f88d71c739d4a6b425c3edcc1b8be55aa2fd4ba589e8fe9405060299e2e876a5169d1c0d6 @@ -58,6 +58,12 @@ # On what port will sit the www logtron www_port = 5002 +# Maximum # of Raw Lines which may be requested in one shot: +max_raw = 500 + +# Toggle for WWWtron debug +www_dbg = 0 + [db] # Change to your DB (set it up so only answers locally) db_name = nsalog diff -uNr a/logotron/reader.py b/logotron/reader.py --- a/logotron/reader.py 5cff8bf56c249454f81e92cbe693dd68ed16626918e9fce4f159b1173c2c1a58cc66cf9eb4925cf7b97c969fdf834f56b0dafd1bbdf249456c9ce610e2f238c6 +++ b/logotron/reader.py bfec2394fbf0f13088bf392ee6946e964a58343b3c7400ac87206212b52d6295738fb17aa100410442bbbafce4fbc09da32c22ea3e52fd379cca4f302be7a735 @@ -17,7 +17,7 @@ import re from datetime import datetime from urlparse import urljoin -from flask import Flask, request, session, url_for, redirect, \ +from flask import Flask, request, session, url_for, redirect, Response, \ render_template, abort, g, flash, _app_ctx_stack, make_response, \ jsonify from flask import Flask @@ -45,10 +45,12 @@ # DBism: DB_Name = cfg.get("db", "db_name") DB_User = cfg.get("db", "db_user") - DB_DEBUG = cfg.get("db", "db_debug") + DB_DEBUG = int(cfg.get("db", "db_debug")) # Logism: Base_URL = cfg.get("logotron", "base_url") Era = int(cfg.get("logotron", "era")) + DEBUG = int(cfg.get("logotron", "www_dbg")) + Max_Raw_Ln = int(cfg.get("logotron", "max_raw")) # WWW: WWW_Port = int(cfg.get("logotron", "www_port")) @@ -66,9 +68,6 @@ ## Format for Date in Log Lines Date_Short_Format = "%Y-%m-%d" - -## WWW Debug Knob -DEBUG = False ############################################################################## app = Flask(__name__) @@ -368,6 +367,48 @@ tail = tail) +@app.route('/log-raw/') +def rawlog(chan): + res = "" + + # Handle rubbish chan: + if chan not in Channels: + return Response("EGGOG: No such Channel!", mimetype='text/plain') + + # Get start and end indices: + idx_start = request.args.get('istart', default = 0, type = int) + idx_end = request.args.get('iend', default = 0, type = int) + + # Malformed bounds? + if idx_start > idx_end: + return Response("EGGOG: Start must precede End!", + mimetype='text/plain') + + # Demanded too many in one burst ? + if (idx_end - idx_start) > Max_Raw_Ln : + return Response("EGGOG: May request Max. of %s Lines !" % Max_Raw_Ln, + mimetype='text/plain') + + # Get the loglines from DB + lines = query_db( + '''select * from loglines where chan=%s + and idx between %s and %s order by idx asc;''', + [chan, idx_start, idx_end], one=False) + + # Retrieve raw lines in classical Phf format: + for l in lines: + action = "" + if l['self']: + action = "*;" + res += "%s;%s;%s%s;%s\n" % (l['idx'], + l['t'].strftime('%s'), + action, + l['speaker'], + l['payload']) + + # Return plain text: + return Response(res, mimetype='text/plain') + Name_Chars = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-"