-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathrun_batchimport.py
66 lines (50 loc) · 2.04 KB
/
run_batchimport.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright 2013 Paul Tremberth, Newlynn Labs
# See LICENSE for details.
import optparse
import ConfigParser
import os
import traceback
# ----------------------------------------------------------------------
def main():
option_parser = optparse.OptionParser()
option_parser.add_option("-c", "--config", dest="configfile", help="configuration file", default=None)
(options, args) = option_parser.parse_args()
config_parser = ConfigParser.RawConfigParser()
if options.configfile:
config_parser.read(options.configfile)
else:
print "you must provide a config file"
sys.exit(0)
if config_parser.has_section('INDEX_FILES'):
index_files = dict((
(index_name, index_file)
for index_name, index_file in config_parser.items('INDEX_FILES')
))
else:
print "no INDEX_FILES section"
index_files = None
args = ['java']
args.append('-server')
args.append('-Xmx1G')
if config_parser.has_option('BATCHIMPORT_SETTINGS', 'jar_location'):
args.append('-jar')
args.append(config_parser.get('BATCHIMPORT_SETTINGS', 'jar_location'))
if config_parser.has_option('BATCHIMPORT_SETTINGS', 'dbfile_location'):
args.append(config_parser.get('BATCHIMPORT_SETTINGS', 'dbfile_location'))
if config_parser.has_option('BATCHIMPORT_SETTINGS', 'nodes_file'):
args.append(config_parser.get('BATCHIMPORT_SETTINGS', 'nodes_file'))
if config_parser.has_option('BATCHIMPORT_SETTINGS', 'relations_file'):
args.append(config_parser.get('BATCHIMPORT_SETTINGS', 'relations_file'))
if config_parser.has_section('INDEX_FILES'):
for index_name, index_file in config_parser.items('INDEX_FILES'):
args.append('node_index')
args.append(index_name)
args.append('fulltext')
args.append(index_file)
# check what's being executed
print " ".join(args)
os.execvp("java", args)
if __name__ == '__main__':
main()