Exemplo n.º 1
0
 def configure():
     logging.basicConfig(filename=SettingsManager.get_instance(
     ).get_logging_settings.log_file,
                         level=SettingsManager.get_instance(
                         ).get_logging_settings.log_level,
                         format=SettingsManager.get_instance().
                         get_logging_settings.log_format)
Exemplo n.º 2
0
def is_authenticated(token):
    try:
        decoded_token = decode_string(
            token,
            SettingsManager.get_instance().get_application_settings.key,
            SettingsManager.get_instance().get_application_settings.algorithm)

        return decoded_token is not None
    except Exception as err:
        raise err
Exemplo n.º 3
0
def get_token(data):
    try:
        payload = json.loads(
            data.decode(SettingsManager.get_instance().
                        get_application_settings.encoding))
        return encode(
            payload,
            SettingsManager.get_instance().get_application_settings.key,
            SettingsManager.get_instance().get_application_settings.algorithm)
    except Exception as err:
        raise err
Exemplo n.º 4
0
    def post(self):
        try:
            token = request.data.decode(SettingsManager.get_instance().
                                        get_application_settings.encoding)

            return adapt_one_success(is_authenticated(token))
        except Exception as err:
            return adapt_critical('Error: ' + str(err.args))
Exemplo n.º 5
0
    def get(self):
        try:
            token = get_token(
                request.data).decode(SettingsManager.get_instance().
                                     get_application_settings.encoding)

            return adapt_one_success(token)
        except Exception as err:
            return adapt_critical('Error: ' + str(err.args))
from neo4j.v1 import GraphDatabase
from neo4j.v1 import basic_auth

from logger import Logger
from settings import SettingsManager
from query_builder import *
from entities import Hashtag

driver = GraphDatabase.driver(
    SettingsManager.get_instance().get_database_settings.host,
    auth=basic_auth(
        SettingsManager.get_instance().get_database_settings.user,
        SettingsManager.get_instance().get_database_settings.password))


def retrieve():
    result = []
    session = driver.session()

    try:
        query = build_get_query()
        data = session.run(query)

        for item in data:
            hashtag = Hashtag()
            hashtag.id = item['h']['id']
            hashtag.text = item['h']['text']

            result.append(hashtag)

        return result