1
2 """Reads events from file instead of db queue."""
3
4 import sys, os, re, skytools
5
6 from playback import *
7 from table_copy import *
8
9 __all__ = ['FileRead']
10
11 file_regex = r"^tick_0*([0-9]+)\.sql$"
12 file_rc = re.compile(file_regex)
13
14
16 """Reads events from file instead of db queue.
17
18 Incomplete implementation.
19 """
20
23
27
29 last_batch = self.get_last_batch(curs)
30 list = self.get_file_list()
31
33 """Return list of (first_batch, full_filename) pairs."""
34
35 src_dir = self.cf.get('file_src')
36 list = os.listdir(src_dir)
37 list.sort()
38 res = []
39 for fn in list:
40 m = file_rc.match(fn)
41 if not m:
42 self.log.debug("Ignoring file: %s" % fn)
43 continue
44 full = os.path.join(src_dir, fn)
45 batch_id = int(m.group(1))
46 res.append((batch_id, full))
47 return res
48
49 if __name__ == '__main__':
50 script = Replicator(sys.argv[1:])
51 script.start()
52