示例#1
0
def save_feedback_in_db(form, feedback_folder):
    """
    Save the feedback in the db.
    """
    fb = Feedbacks()
    fb.version = getCurrentVersion()
    fb.datetime = datetime.datetime.now()
    fb.name = form['name'].data
    fb.email = form['email'].data
    fb.category = dict(form.category.choices).get(form.category.data)
    fb.searched_string = form['searched_string'].data
    fb.searched_start = form['searched_start'].data
    fb.searched_end = form['searched_end'].data
    fb.found_string = form['found_string'].data
    fb.found_start = form['found_start'].data
    fb.found_end = form['found_end'].data
    fb.feedback = form['feedback'].data
    fb.json = form['dictJS'].data
    fb.start_coord = form['start_coord_fb'].data
    fb.end_coord = form['end_coord_fb'].data
    fb.report = os.path.join(
        feedback_folder,
        "dequa_fb_" + fb.datetime.strftime("%Y%m%d-%H%M%S.%f") + ".md")
    db.session.add(fb)
    db.session.commit()
    return fb
示例#2
0
def navigation():
    # add version to the track usage
    g.track_var["version"] = getCurrentVersion()
    # do everything
    form = FeedbackForm()
    try:
        arguments_GET_request = request.args
        params_research = interface.retrieve_parameters_from_GET(
            arguments_GET_request)

        # usiamo questo per dirgli cosa disegnare!
        # assumiamo nulla per ora
        # geo_type = -2
        # f_ponti = False

        # se e stato inviato il form, scriviamo sul feedback file
        # anche questo da spostare su un metodo

        # form.searched_string.data = params_research['da'] # equivalente al precedente "da"
        t0 = time.perf_counter()
        if request.method == 'POST':
            feedbacksent = interface.take_care_of_the_feedback(
                form, feedback_folder)
            results_dictionary = interface.create_first_dictionary()
            # return render_template(html_file, geo_type=geo_type, start_coordx=-1,
            #     searched_name=da, start_name=start_name,
            #     form=form, feedbacksent=feedbacksent)
            return render_template(html_file,
                                   form=form,
                                   results_dictionary=results_dictionary,
                                   feedbacksent=feedbacksent)
            # non sono 100% sicuro che form vada ritornato sempre (nel caso precedente era ritornato solo in caso di 0)
            # ma dovrebbe funzionare
        # altrimenti, dobbiamo fare qualocsa
        else:
            dictionary_of_stuff_found = interface.find_what_needs_to_be_found(
                params_research)
            return render_template(
                html_file,
                form=form,
                results_dictionary=dictionary_of_stuff_found,
                feedbacksent=0)

    except Exception as e:
        interface.take_care_of_the_error(request, e, error_folder)
        dictionary_of_err = {
            "error": True,
            "repr": repr(e),
            "type": type(e).__name__,
            "msg": str(e),
            "traceback": traceback.format_exc()
        }
        #app.logger.info("error: {}".format(traceback.format_exc()))
        return render_template(html_file,
                               form=form,
                               results_dictionary=dictionary_of_err,
                               feedbacksent=0)
示例#3
0
def index():
    # add version to the track usage
    g.track_var["version"] = getCurrentVersion()
    # do everything
    # app.logger.info('Prova info')
    # app.logger.error('Prova error')
    # app.logger.debug('Prova debug')
    # app.logger.warning('Prova warning')
    # app.logger.critical('Prova critical')
    # app.logger.log(10,'Prova log debug')
    # app.logger.log(20,'Prova log info')
    return render_template('info/info.html')
示例#4
0
def save_error_in_db(request, err, error_folder):
    """
    Wrapper that save the error in the db
    """
    curr_time = datetime.datetime.now()
    file_error_name = os.path.join(
        error_folder, "dequa_err_" + curr_time.strftime("%Y%m%d-%H%M%S.%f"))
    er = Errors()
    er.version = getCurrentVersion()
    er.datetime = curr_time
    er.error_type = type(err).__name__
    er.error_message = str(err)
    er.url = request.url
    er.method = request.method
    er.browser = request.user_agent.string
    er.pickle = file_error_name + ".err"
    er.report = file_error_name + ".md"
    db.session.add(er)
    db.session.commit()
    return er
示例#5
0
def asynch_initialize_votes():
    """
    Updates the votes on the new ideas that we plan to implement
    """
    # add version to the track usage
    g.track_var["version"] = getCurrentVersion()
    try:
        ideas_votes = interface.initialize_votes()
        return ideas_votes
    except Exception as e:
        interface.take_care_of_the_error(request, e, error_folder)
        dictionary_of_err = {
            "error": True,
            "repr": repr(e),
            "type": type(e).__name__,
            "msg": str(e),
            "traceback": traceback.format_exc()
        }
        app.logger.info("error: {}".format(traceback.format_exc()))
        # in case of error, reload the page
        #return render_template(html_file, form=form, results_dictionary=dictionary_of_err, feedbacksent=0)

        return jsonify(dictionary_of_err)
示例#6
0
def asynch_navigation():
    # add version to the track usage
    g.track_var["version"] = getCurrentVersion()
    try:
        arguments_GET_request = request.args
        params_research = interface.retrieve_parameters_from_GET(
            arguments_GET_request)
        dictionary_of_stuff_found = interface.find_what_needs_to_be_found(
            params_research)
        return jsonify(dictionary_of_stuff_found)
    except Exception as e:
        interface.take_care_of_the_error(request, e, error_folder)
        dictionary_of_err = {
            "error": True,
            "repr": repr(e),
            "type": type(e).__name__,
            "msg": str(e),
            "traceback": traceback.format_exc()
        }
        app.logger.info("error: {}".format(traceback.format_exc()))
        # in case of error, reload the page
        #return render_template(html_file, form=form, results_dictionary=dictionary_of_err, feedbacksent=0)

        return jsonify(dictionary_of_err)