Пример #1
0
def stats():
    try:
        logging.info("stats route::enter")
        main_obj = Main()
        file_handle = open(session['filename'], encoding="utf8", mode="r")
        main_obj.file_contents = file_handle.read()
        friend1 = Friend()
        friend2 = Friend()
        date_object = Dates()
        main_obj.prepare_stats(friend1, friend2, date_object)

        @after_this_request
        def remove_file(response):
            try:
                logging.debug("remove_file::enter")
                file_handle.close()
                os.remove(session['filename'])
                logging.debug("remove_file::exit")
            except Exception as error:
                app.logger.error(
                    "Error removing or closing downloaded file handle", error)
            return response

        logging.info("stats route::exit")
        return render_template("stats.html",
                               main_obj=main_obj,
                               friend1=friend1,
                               friend2=friend2,
                               date_object=date_object)
    except Exception as e:
        logging.exception("Exception in stats route handler")
Пример #2
0
def sample():
    try:
        logging.info("sample route::enter")
        main_obj = Main()
        file_handle = open('sample.txt', encoding="utf8", mode="r")
        main_obj.file_contents = file_handle.read()
        friend1 = Friend()
        friend2 = Friend()
        date_object = Dates()
        main_obj.prepare_stats(friend1, friend2, date_object)
        logging.info("sample route::exit")
        return render_template("stats.html",
                               main_obj=main_obj,
                               friend1=friend1,
                               friend2=friend2,
                               date_object=date_object)
    except Exception as e:
        logging.exception("Exception in stats route handler")