-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
59 lines (45 loc) · 1.51 KB
/
app.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
# -*- coding: utf-8 -*-
from cli import SylvaApp
import imp
from gooey import Gooey, GooeyParser
try:
import ujson as json
except ImportError:
import json # NOQA
import os
import sys
class Unbuffered(object):
""" Class to treat the problem with the buffer in Windows """
def __init__(self, stream):
self.stream = stream
def write(self, data):
self.stream.write(data)
self.stream.flush()
def __getattr__(self, attr):
return getattr(self.stream, attr)
sys.stdout = Unbuffered(sys.stdout)
APP_ROOT = os.path.dirname(__file__)
ICONS_PATH = os.path.join(APP_ROOT, "icons/")
RULES_PATH = os.environ.get("RULES_PATH",
os.path.join(APP_ROOT, "rules.py"))
rules = imp.load_source('rules', RULES_PATH)
running = True
@Gooey(dump_build_config=True,
program_name="SylvaDB - client",
image_dir=ICONS_PATH)
def main():
settings_msg = rules.CONFIG_SETTINGS['settings_msg']
file_help_msg = rules.CONFIG_SETTINGS['file_help_msg']
parser = GooeyParser(description=settings_msg)
parser.add_argument("FileChooser", help=file_help_msg,
widget="FileChooser")
parser.add_argument("--batch-size",
default=500,
type=int,
help='Batch size used to dump the data into SylvaDB')
args = parser.parse_args()
file_path = args.FileChooser.encode('utf-8')
app = SylvaApp(file_path)
app.populate_data()
if __name__ == '__main__':
main()