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)
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
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
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))
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