This repository was archived by the owner on May 27, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgeocode
More file actions
executable file
·69 lines (51 loc) · 2.3 KB
/
geocode
File metadata and controls
executable file
·69 lines (51 loc) · 2.3 KB
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
66
67
68
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from configparser import ConfigParser
from os import path, environ, getcwd, chdir
# Altera para diretório de trabalho
chdir(path.dirname(path.realpath(__file__)))
if path.exists('./config/wsgi.cfg'):
config = ConfigParser()
config.read('./config/wsgi.cfg')
for key in config.options('env'):
environ[key.upper()] = config.get('env', key)
# Adiciona diretório atual ao path.
import sys
sys.path.insert(0, path.dirname(path.realpath(__file__)))
# Carregar ambiente virtual se disponível.
if path.exists('./venv'):
activate_this = path.join(getcwd(), './venv/bin/activate_this.py')
with open(activate_this) as file_:
exec(file_.read(), dict(__file__ = activate_this))
# Apaga base se executar da linha de comando.
if __name__ == '__main__':
import click
@click.command(name = 'geocode', add_help_option = False)
@click.option('--arquivo', type=str, help = 'Executa em modo terminal com o arquivo especificado.')
@click.option('--delimitador', default=';', help = 'Determina o limitador no arquivo CSV (modo terminal).')
@click.option('--campos', default='*', help = 'Determina os campos do arquivo CSV a serem usados (modo terminal).')
@click.option('--rebuild', is_flag = True, help = 'Reconstroi base de dados de busca.')
@click.option('--server', is_flag = True, help = 'Executa servidor em modo DEBUG.')
def comando(arquivo, delimitador, campos, rebuild, server):
"""Executar o GEOCODE em linha de comando para realizar diversas funções."""
if arquivo:
import terminal
delimitador_ = delimitador if not delimitador is None else ';';
campos_ = campos if not campos is None else '*';
terminal.run(arquivo, delimitador_, campos_)
click.get_current_context().exit()
if rebuild:
from modelos import apagar_base, criar_base
apagar_base()
criar_base()
elif server:
click.echo('Iniciando servidor localmente em modo DEBUG...')
from app import create_app
app = create_app()
app.run(debug = True)
else:
click.echo(click.get_current_context().get_help())
comando()
else:
from app import create_app
application = create_app()