/usr/share/pyshared/londiste/file_read.py is in skytools 2.1.12-6.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | """Reads events from file instead of db queue."""
import sys, os, re, skytools
from playback import *
from table_copy import *
__all__ = ['FileRead']
file_regex = r"^tick_0*([0-9]+)\.sql$"
file_rc = re.compile(file_regex)
class FileRead(CopyTable):
"""Reads events from file instead of db queue.
Incomplete implementation.
"""
def __init__(self, args, log = None):
CopyTable.__init__(self, args, log, copy_thread = 0)
def launch_copy(self, tbl):
# copy immidiately
self.do_copy(t)
def work(self):
last_batch = self.get_last_batch(curs)
list = self.get_file_list()
def get_list(self):
"""Return list of (first_batch, full_filename) pairs."""
src_dir = self.cf.get('file_src')
list = os.listdir(src_dir)
list.sort()
res = []
for fn in list:
m = file_rc.match(fn)
if not m:
self.log.debug("Ignoring file: %s" % fn)
continue
full = os.path.join(src_dir, fn)
batch_id = int(m.group(1))
res.append((batch_id, full))
return res
if __name__ == '__main__':
script = Replicator(sys.argv[1:])
script.start()
|