-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwowauc_import.py
39 lines (33 loc) · 1.1 KB
/
wowauc_import.py
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
#! /usr/bin/env python
# -*- coding: utf-8 -*-
#
import psycopg2, re, datetime, sys, os, os.path, glob
from wowauc.Pusher import Pusher
from wowauc.Parser import Parser
exec file("wowauc.conf", "rt").read()
CURDIR = os.path.dirname(os.path.abspath(__file__)) + "/"
SRCDIR = CURDIR + dir_fetched + "/"
TMPDIR = CURDIR + dir_importing + "/"
DSTDIR = CURDIR + dir_imported + "/"
moving = True # false for debug
if __name__ == '__main__':
pusher = Pusher(debug = True)
pusher.connect(dbhost, dbname, dbuser, dbpass)
parser = Parser(pusher, 'eu', 'en_US', True)
try:
for fname in sorted(glob.glob(SRCDIR + '*.json')):
if moving:
tname = TMPDIR + os.path.basename(fname)
dname = DSTDIR + os.path.basename(fname)
os.rename(fname, tname)
parser.parse_file(tname)
os.rename(tname, dname)
else:
parser.parse_file(fname)
# break
finally:
if pusher.is_started():
print "abort"
pusher.abort()
pusher.disconnect()
print "done"