Esempio n. 1
0
def list_acervo():
    cdorg = request.args.get('cdorg')
    acervo = DAO.run(acervo_qtd_query, {'org': cdorg}).fetchone()[0]
    meses = DAO.run(list_acervo_query, {'org': cdorg}).fetchall()

    result = {"ACERVO_ATUAL": acervo}
    historico = []
    prev_acervo = acervo
    for mes in meses:
        acervo_fim_mes = prev_acervo
        entradas = mes[1]
        saidas = mes[2]
        saldo = entradas - saidas
        acervo_inicio_mes = acervo_fim_mes - saldo  # Olhando para trás

        mes_dict = {
            'MES': mes[0],
            'ENTRADAS': entradas,
            'SAIDAS': saidas,
            'ACERVO_FIM_MES': acervo_fim_mes,
            'SALDO': saldo,
            'ACERVO_INICIO_MES': acervo_inicio_mes
        }

        historico.append(mes_dict)
        prev_acervo = acervo_inicio_mes

    result['HISTORICO'] = historico
    return jsonify(result)
Esempio n. 2
0
def list_acervo_classe():
    cdorg = request.args.get('cdorg')
    data = DAO.run(acervo_classe_pai_query, {'org': cdorg})
    results = []
    for row in data:
        row_dict = {
            'CLASSE_ID_PAI': row[0],
            'CLASSE_PAI': row[1],
            'QTD': row[2]
        }
        results.append(row_dict)
    return jsonify(results)
Esempio n. 3
0
def list_vistas():
    cdorg = request.args.get('cdorg')
    data = DAO.run(list_vistas_query, {'org': cdorg})
    results = []
    for row in data:
        row_dict = {
            'TOTAL': row[0],
            'HOJE': row[1],
            'ATE_30': row[2],
            'DE_30_A_40': row[3],
            'MAIS_40': row[4],
        }
        results.append(row_dict)
    return jsonify(results)
Esempio n. 4
0
def list_orgaos():
    data = DAO.run(list_orgaos_query)
    results = []
    for row in data:
        row_dict = {
            'CDORG': row[0],
            'CRAAI': row[1],
            'COMARCA': row[2],
            'FORO': row[3],
            'ORGAO': row[4],
            'TITULAR': row[5],
        }
        results.append(row_dict)
    return jsonify(results)
Esempio n. 5
0
    def __init__(self, parrent=None):
        dao = DAO()
        gr = GraphResults()
        gr.setWatches(dao)

        parser = OptionParser()
        parser.add_option("-u", type="string", dest="user")
        parser.add_option("-t", type="string", dest="term")

        (options, args) = parser.parse_args()
        # make sure correct args passed
        if not options.user or not options.term:
            print "Usage: -u 'name of user' -t 'term to graph'\n"
            sys.exit(1)

        gr.setResults(dao, options.user, options.term)

        print "Counts: \n", gr.getCount()
        print "Dates: \n", gr.getDates()

        gr.makeGraph(options.user, options.term, gr.getDates(), gr.getCount())
Esempio n. 6
0
def get_foto():
    cdmat = request.args.get('cdmat')
    data = DAO.run(foto_mat_query, {"mat": cdmat}).fetchone()
    bs4_img = base64.b64encode(data[0].read()).decode()
    return jsonify({"foto": bs4_img})
Esempio n. 7
0
from datetime import date
from optparse import OptionParser
from database import DAO

#User & term to look at.
parser = OptionParser()
parser.add_option("-u", type="string", dest="user")
parser.add_option("-t", type="string", dest="term")
(options, args) = parser.parse_args()

if not options.user or not options.term:
    print "Usage: -u 'alark' -t 'graphics' -d 'MM/DD/YYYY'\n"
    sys.exit(1)

#Database initialization
dao = DAO()
hits = 0
user = options.user
term = options.term
dateToHits = {}


#Gets Tweets using Auth. Call & searchs for a keyword
def getTweetsAuth(name, idea):
    global hits
    global dateToHits
    for tweet in tweepy.Cursor(auth.user_timeline,
                               screen_name=name,
                               include_rts=0,
                               count=300).items(300):
        dayCreated = tweet.created_at
Esempio n. 8
0
# Clayton

from database import DAO

import matplotlib.pyplot as plt
from datetime import datetime
from optparse import OptionParser
import sys

dao = DAO()

u1 = 'alark'
u2 = 'bjo3rn'
t1 = 'graphics'
t2 = 'code'

print dao.getUsersAndTerms()
print dao.getAllHits()
print dao.getAllHits()

print dao.getResults(u1, t1)
print dao.getResults(u2, t1)
print dao.getResults(u1, t2)
Esempio n. 9
0
def list_detalhes():
    cdorg = request.args.get('cdorg')
    data = list(DAO.run(list_detalhes_query, {'org': cdorg}))

    colunas = """MMPM_ORDEM
                MMPM_MAPA_CRAAI
                MMPM_MAPA_FORUM
                MMPM_MAPA_BAIRRO
                MMPM_MAPA_MUNICIPIO
                MMPM_CRAAI
                MMPM_COMARCA
                MMPM_FORO
                MMPM_GRUPO
                MMPM_ORGAO
                MMPM_TELEFONESORGAO
                MMPM_EXIBEGRUPO
                MMPM_EXIBEFORO
                MMPM_ORDEMGRUPO
                MMPM_ORDEMQUADRO
                MMPM_MATRICULA
                MMPM_NOME
                MMPM_CELULAR
                MMPM_CARGO
                MMPM_CONCURSO
                MMPM_ANOCONCURSO
                MMPM_ROMANO
                MMPM_FUNCAO
                MMPM_ORDEMSUBSTITUCAO
                MMPM_FLAG_PGJ
                MMPM_FLAG_ELEITORAL
                MMPM_FLAG_CRAAI
                MMPM_DIAS
                MMPM_AFASTAMENTO
                MMPM_PGJ_FUNCAO
                MMPM_DTNASC
                MMPM_DTINICIOSUBS
                MMPM_DTFIMSUBS
                MMPM_FLAG_ASSESSOR
                MMPM_CDORGAO
                """.split("\n")

    colunas = [c.strip() for c in colunas]
    data = [dict(zip(colunas, d)) for d in data]

    if not data:
        return jsonify({})

    retorno = {
        "detalhes": {
            "MATRICULA": data[0]["MMPM_MATRICULA"],
            "NOME": data[0]["MMPM_NOME"],
            "CARGO": data[0]["MMPM_CARGO"],
            "CONCURSO": data[0]["MMPM_CONCURSO"],
            "ANOCONCURSO": data[0]["MMPM_ANOCONCURSO"],
            "ROMANO": data[0]["MMPM_ROMANO"],
            "FLAG_PGJ": data[0]["MMPM_FLAG_PGJ"],
            "FLAG_ELEITORAL": data[0]["MMPM_FLAG_ELEITORAL"],
            "FLAG_CRAAI": data[0]["MMPM_FLAG_CRAAI"],
            "DTNASC": data[0]["MMPM_DTNASC"],
            "FLAG_ASSESSOR": data[0]["MMPM_FLAG_ASSESSOR"],
            "CDORGAO": data[0]["MMPM_CDORGAO"],
            "TELEFONESORGAO": data[0]["MMPM_TELEFONESORGAO"].split(' | ')[1:],
            "ORGAO": data[0]["MMPM_ORGAO"],
            "CELULAR": data[0]["MMPM_CELULAR"],
        },
        "funcoes":
        data[0]["MMPM_PGJ_FUNCAO"].split('@'),
        "designacoes":
        get_designacao(data[1:]),
        "afastamento": (data[0]["MMPM_AFASTAMENTO"].split('@')
                        if data[0]["MMPM_AFASTAMENTO"] else [])
    }

    return jsonify(retorno)
Esempio n. 10
0
from database.DAO import *
from database.Readxml import *
import database.settings
import time

dao = DAO()
readxml = Readxml('xml/B1.xml')
readxml.set_dao(dao)
dao.set_readxml(readxml)
# dao.drop_database()
dao.create_tables()
dao.insert()
dao.select_trigger()
Esempio n. 11
0
# Monte
from database import DAO
import sys
from optparse import OptionParser

parser = OptionParser()
parser.add_option("-t", type="string", dest="term")
parser.add_option("-u", type="string", dest="user")

(options, args) = parser.parse_args()

if not options.term and not options.user:
	parser.print_help()
	sys.exit(1)


dao = DAO()

dao.addTermWatch(options.user,options.term)
Esempio n. 12
0
from database.DAO import *
from database.Readxml import *

dao = DAO()
readxml = Readxml('xml/paralelo.xml')
readxml.set_dao(dao)
dao.set_readxml(readxml)

dao.drop_tables()
dao.create_tables()
#insere estado inicial no wed_state


dao.insert()

Esempio n. 13
0
from database.DAO import *
from database.Readxml import *
dao = DAO()
readxml = Readxml('xml/B1.xml')

Readxml.dao = dao
DAO.readxml = readxml
Esempio n. 14
0
from database import DAO

dao = DAO()

data = dao.getAllHits()

for item in data:
    print item

Esempio n. 15
0
from database import DAO

dao = DAO()

data = dao.getUsersAndTerms()

print data


#User & term to look at.
parser = OptionParser()
parser.add_option("-u", type="string", dest="user")
parser.add_option("-t", type="string", dest="term")
(options, args) = parser.parse_args()

if not options.user or not options.term:
	print "Usage: -u 'alark' -t 'graphics' -d 'MM/DD/YYYY'\n"
	sys.exit(1)



#Database initialization
dao = DAO()
hits = 0
user = options.user
term = options.term
dateToHits = {}

#Gets Tweets using Auth. Call & searchs for a keyword
def getTweetsAuth(name, idea):
    global hits
    global dateToHits
    for tweet in tweepy.Cursor(auth.user_timeline, screen_name = name,include_rts=0, count =300).items(300):
        dayCreated = tweet.created_at
        if not dayCreated.date() in dateToHits:
            dateToHits[dayCreated.date()] = 0
        print tweet.text
        # Splits the up the line into words by using [_.,;: *\'\"@#&!?-]+ as delimters
# Monte
from database import DAO
import sys
from optparse import OptionParser

parser = OptionParser()
parser.add_option("-t", type="string", dest="term")
parser.add_option("-u", type="string", dest="user")
parser.add_option("-n", type="string", dest="hits")

(options, args) = parser.parse_args()

if not options.term or not options.user or not options.hits:
    parser.print_help()
    sys.exit(1)

dao = DAO()

dao.insertHits(options.user, options.term, options.hits)
# Monte
from database import DAO
import sys
from optparse import OptionParser

parser = OptionParser()
parser.add_option("-t", type="string", dest="term")
parser.add_option("-u", type="string", dest="user")
parser.add_option("-n", type="string", dest="hits")

(options, args) = parser.parse_args()

if not options.term or not options.user or not options.hits:
	parser.print_help()
	sys.exit(1)

dao = DAO()

dao.insertHits(options.user, options.term, options.hits)