def attend(self, order):
     Logger.info(
         f"Attending order_id={order['orderId']} item_id={order['item']['id']}"
     )
     self.__product_dao.update_item(order_id=int(order['orderId']),
                                    item_id=int(order["item"]["id"]),
                                    status="DONE")
 def call_support(self, user_id: int, message: str):
     Logger.info(f"publishing to {self.__drink_topic}: {user_id}")
     self.__producer.send(topic=self.__drink_topic,
                          value={
                              "userId": user_id,
                              "message": message
                          })
 def process_dataset(self):
     movies_count = 0
     for movie in self.__dataset_repository.iterate_over_movies():
         if movies_count > self.__max_movies:
             break
         self.__movies_repository.add_movie(movie)
         Logger.info(f"Sent movie {movies_count+1}/{self.__max_movies} - {movie['name']}")
         movies_count += 1
    def list_movies():
        response: dict
        status_code: int = 200
        try:
            Logger.info(f"list_movies")
            response = service.list_movies()
        except Exception as exception:
            status_code = 500
            response = UtilController.build_error_payback(exception, status_code)

        return UtilController.build_response(response, status_code)
    def ranking_by_gender(gender: str):
        response: dict
        status_code: int = 200
        try:
            Logger.info(f"ranking_by_gender - gender={gender}")
            response = ranking_service.ranking_by_gender(gender)
        except Exception as exception:
            Logger.error(str(exception))
            status_code = 500
            response = UtilController.build_error_payback(exception, status_code)

        return UtilController.build_response(response, status_code)
    def post_watched(user_id: int, movie_id: int):
        response: dict = {}
        status_code: int = 204
        try:
            Logger.info(f"post_watched: user_id:{user_id} movie_id={movie_id}")
            watched_service.post_watched(user_id, movie_id)
        except Exception as exception:
            Logger.error(str(exception))
            status_code = 500
            response = UtilController.build_error_payback(
                exception, status_code)

        return UtilController.build_response(response, status_code)
    def list_reminder():
        response: dict
        status_code: int = 200
        try:
            Logger.info(f"list_reminder")
            response = reminder_service.list_reminder()
        except Exception as exception:
            Logger.error(str(exception))
            status_code = 500
            response = UtilController.build_error_payback(
                exception, status_code)

        return UtilController.build_response(response, status_code)
    def get_reminder(user_id: int):
        response: dict
        status_code: int = 200
        try:
            Logger.info(f"get_reminder: user_id={user_id}")
            response = reminder_service.get_reminder(user_id)
        except Exception as exception:
            Logger.error(str(exception))
            status_code = 500
            response = UtilController.build_error_payback(
                exception, status_code)

        return UtilController.build_response(response, status_code)
    def post_support(user_id: int):
        response: dict
        status_code: int = 204
        try:
            Logger.info(f"post_support")
            message = request.json
            response = support_service.call_support(user_id, message)
        except Exception as exception:
            Logger.error(str(exception))
            status_code = 500
            response = UtilController.build_error_payback(exception, status_code)

        return UtilController.build_response(response, status_code)
    def filter_movie(movie_id: int):
        response: dict
        status_code: int = 200
        try:
            Logger.info(f"filter_movie - movie_id:{movie_id}")
            response = service.filter_movie(movie_id)
            if not response:
                status_code = 404
                response = {}
        except Exception as exception:
            status_code = 500
            response = UtilController.build_error_payback(exception, status_code)

        return UtilController.build_response(response, status_code)
예제 #11
0
    def similar_to(self, shoes: Shoes) -> List[Shoes]:
        query: str = '''
            SELECT ?shoes ?shoes_name ?characteristic
            FROM <http://mecansei.com/ontology/v1>{
                :''' + shoes.id + ''' :similar ?shoes .
                ?shoes :has_characteristic ?characteristic;
                    :name ?shoes_name .
            }
            ORDER BY ?shoes ?shoes_name ?characteristic
        '''
        Logger.info(query)

        response = self.__client.select(query, reasoning=True)
        return self.__build_shoes_array(response)
    def filter_movies_by_gender(gender: str):
        response: dict
        status_code: int = 200
        try:
            Logger.info(f"filter_movies_by_gender - gender:{gender}")
            response = service.filter_movies_by_gender(gender)
            if not response:
                status_code = 404
                response = {}
        except Exception as exception:
            status_code = 500
            response = UtilController.build_error_payback(exception, status_code)

        return UtilController.build_response(response, status_code)
예제 #13
0
    def find_shoes(self) -> List[Shoes]:
        query: str = """
            SELECT ?shoes ?shoes_name ?characteristic 
            FROM <http://mecansei.com/ontology/v1>{
                ?shoes a :Shoes;
                    :has_characteristic ?characteristic;
                    :name ?shoes_name .
            }
            ORDER BY ?shoes ?shoes_name ?characteristic 
        """
        Logger.info(query)

        response = self.__client.select(query)
        return self.__build_shoes_array(response)
    def filter_movies_by_query_string():
        response: dict
        status_code: int = 200
        try:
            query = request.args["q"]
            Logger.info(f"filter_movies_by_query_string - query:{query}")
            response = service.filter_movies_by_query_string(query)
            if not response:
                status_code = 404
                response = {}
        except Exception as exception:
            status_code = 500
            response = UtilController.build_error_payback(exception, status_code)

        return UtilController.build_response(response, status_code)
    def add_movie():
        response: dict
        status_code: int = 204
        try:
            movie = request.json
            Logger.info(f"add_movie: movie={movie['name']}")
            response = service.add_movie(
                movie=movie
            )
        except Exception as exception:
            Logger.error(str(exception))
            status_code = 500
            response = UtilController.build_error_payback(exception, status_code)

        return UtilController.build_response(response, status_code)
    def get_votes_by(movie_id: int):
        response: dict
        status_code: int = 200
        try:
            Logger.info(f"get_votes_by: movie_id={movie_id}")
            response = vote_service.get_votes_by(movie_id)
            if not response:
                status_code = 404
                response = {}
        except Exception as exception:
            Logger.error(str(exception))
            status_code = 500
            response = UtilController.build_error_payback(
                exception, status_code)

        return UtilController.build_response(response, status_code)
예제 #17
0
    def insert(self, shoes: Shoes):
        properties: str = ""
        for prop in shoes.properties:
            properties += f" {prop},"
        properties = properties[:-1]

        query: str = """
            INSERT DATA {
                GRAPH <http://mecansei.com/ontology/v1> {
                    :""" + shoes.id + """ a :Shoes ;
                    :has_characteristic""" + properties + """ ;
                    :name '""" + shoes.name + """' .
                }
            }
        """
        Logger.info(query)

        self.__client.update(query)
예제 #18
0
 def __init__(self, host: str, port: int, default_db: str):
     Logger.info(f"Connecting to mongo using host: {host} and port: {port}")
     self.__client = MongoClient(
         host=host,
         port=port
     )
     Logger.info(f"Mongo connected. Accessing database: {default_db}")
     self.__database = self.__client[default_db]
     Logger.info(f"Database connection status: {self.status()}")
예제 #19
0
 def publish(self, item):
     Logger.info(f"publishing prepared drink to balcony_topic: {item}")
     self.__producer.send(topic=self.__balcony_topic, value=item)
 def attend(self, order):
     Logger.info(
         f"Attending user_id={order['userId']} message={order['message']}")
예제 #21
0
import configparser
import os

from src.library.logger.Logger import Logger

if __name__ == "__main__":
    configuration = configparser.ConfigParser()
    configuration.read("./application.ini")

    environment: str = os.getenv("ENVIRONMENT", "DEV")
    Logger.info(f"Running with environment: {environment}")

    for key, value in configuration[environment].items():
        if not os.getenv(key.upper(), None):
            os.environ[key.upper()] = str(value)

    from src.web.serverconfig.FlaskConfig import FlaskConfig
    # Must be here to initiate the env variables before initialize
    # all components
    FlaskConfig()()
 def publish(self, order):
     Logger.info(f"publishing to drink_topic: {order['orderId']}")
     self.__producer.send(topic=self.__drink_topic, value=order)
예제 #23
0
 def consumes(self, item):
     Logger.info(f"publishing prepared food to balcony_topic: {item}")
     self.__producer.send(topic=self.__balcony_topic, value=item)