コード例 #1
0
    def register():
        if not server_utilities.header_exist("nome"):
            response = responses.missing_element_response("nome")
            log.log("MISSING", response["message"],
                    server_utilities.get_headers_list())
            return response
        else:
            nome = server_utilities.get_header("nome")

        if not server_utilities.header_exist("cognome"):
            response = responses.missing_element_response("cognome")
            log.log("MISSING", response["message"],
                    server_utilities.get_headers_list())
            return response
        else:
            cognome = server_utilities.get_header("cognome")

        if not server_utilities.header_exist("key"):
            response = responses.missing_element_response("key")
            log.log("MISSING", response["message"],
                    server_utilities.get_headers_list())
            return response
        else:
            key = server_utilities.get_header("key")

        if not server_utilities.header_exist("email"):
            response = responses.missing_element_response("email")
            log.log("MISSING", response["message"],
                    server_utilities.get_headers_list())
            return response
        else:
            email = server_utilities.get_header("email")

        if not server_utilities.header_exist("profile_pic"):
            response = responses.missing_element_response("profile_pic")
            log.log("MISSING", response["message"],
                    server_utilities.get_headers_list())
            return response
        else:
            profile_pic = server_utilities.get_header("profile_pic")

        _ = users.add_user({
            "nome": nome,
            "cognome": cognome,
            "key": key,
            "profile_pic": profile_pic,
            "email": email,
            "classe": None
        })

        return {"result": "OK", "new_user": _}
コード例 #2
0
    def prenota():

        # Controllo se la richiesta soddisfa i requisiti
        if not server_utilities.header_exist("key"):
            response = responses.missing_element_response("key")
            log.log("MISSING", response["message"],
                    server_utilities.get_headers_list())
            return response
        else:
            key = server_utilities.get_header("key")

        if not server_utilities.header_exist("x-date"):
            response = responses.missing_element_response("x-date")
            log.log("MISSING", response["message"],
                    server_utilities.get_headers_list())
            return response
        else:
            date = server_utilities.get_header("x-date")
            if not dates.verify_date(date):
                response = responses.invalid_date_response()
                log.log("DATE", response["message"],
                        server_utilities.get_headers_list())
                return response

        # Aggiungo al database la prenotazione
        user = users.search_user(key)

        if user is not None:
            if prenotazioni.check_date_reservations(user["email"], date):
                response = responses.reservation_already_registered(date)
                log.log("REGISTERED", response["message"],
                        server_utilities.get_headers_list())
                return response
            else:
                database_utilities.append_user({
                    "nome": user["nome"],
                    "cognome": user["cognome"],
                    "date": date,
                    "email": user["email"],
                    "classe": user["classe"]
                })
        else:
            response = responses.key_doesnt_exist()
            log.log("KEY", response["message"],
                    server_utilities.get_headers_list())
            return response

        # Ritorno OK al client
        return {"result": "OK"}
コード例 #3
0
    def add_info():
        if not server_utilities.header_exist("key"):
            response = responses.missing_element_response("key")
            log.log("MISSING", response["message"],
                    server_utilities.get_headers_list())
            return response
        else:
            key = server_utilities.get_header("key")

        if not server_utilities.header_exist("classe"):
            response = responses.missing_element_response("classe")
            log.log("MISSING", response["message"],
                    server_utilities.get_headers_list())
            return response
        else:
            classe = server_utilities.get_header("classe")

        if users.add_info(key, classe) is True:
            return {"result": "OK"}
コード例 #4
0
    def add_holiday():

        db = database_utilities.load_db(database_utilities.dates_file_path)

        if not server_utilities.header_exist("set"):
            response = responses.missing_element_response("set")
            log.log("MISSING", response["message"],
                    server_utilities.get_headers_list())
            return response
        else:
            x_set = server_utilities.get_header("set")

        if x_set == "true":

            database_utilities.save_db(flask.request.get_json(),
                                       database_utilities.dates_file_path)

            return {"result": "OK"}

        else:
            return {"result": "OK", "dates": db}
コード例 #5
0
    def chronology():
        if not server_utilities.header_exist("key"):
            response = responses.missing_element_response("key")
            log.log("MISSING", response["message"],
                    server_utilities.get_headers_list())
            return response
        else:
            key = server_utilities.get_header("key")

        user = users.search_user(key)

        if user is None:
            response = responses.key_doesnt_exist()
            log.log("KEY", response["message"],
                    server_utilities.get_headers_list())
            return response
        else:
            return {
                "result": "OK",
                "chronology":
                prenotazioni.check_user_reservations(user["email"])
            }
コード例 #6
0
    def remove_date():
        if not server_utilities.header_exist("key"):
            response = responses.missing_element_response("key")
            log.log("MISSING", response["message"],
                    server_utilities.get_headers_list())
            return response
        else:
            key = server_utilities.get_header("key")

        if not server_utilities.header_exist("x-date"):
            response = responses.missing_element_response("x-date")
            log.log("MISSING", response["message"],
                    server_utilities.get_headers_list())
            return response
        else:
            date = server_utilities.get_header("x-date")

        user = users.search_user(key)
        db = database_utilities.load_db(
            database_utilities.prenotazioni_file_path)

        prenotazione = {
            "nome": user["nome"],
            "cognome": user["cognome"],
            "date": date,
            "email": user["email"],
            "classe": user["classe"]
        }

        try:
            db["prenotazioni"].remove(prenotazione)
            db["totale"] -= 1
            database_utilities.save_db(
                db, database_utilities.prenotazioni_file_path)
        except Exception:
            pass

        return {"result": "OK"}
コード例 #7
0
    def userinfo():
        if not server_utilities.header_exist("key"):
            response = responses.missing_element_response("key")
            log.log("MISSING", response["message"],
                    server_utilities.get_headers_list())
            return response
        else:
            key = server_utilities.get_header("key")

        user = users.search_user(key)

        if user is None:
            response = responses.key_doesnt_exist()
            log.log("KEY", response["message"],
                    server_utilities.get_headers_list())
            return response

        return {
            "result": "OK",
            "fullname": "{0} {1}".format(user["nome"], user["cognome"]),
            "profile_pic": user["profile_pic"],
            "classe": user["classe"]
        }
コード例 #8
0
def menu_logs():

    # Get logs from Nimble
    creds = get()
    hostip = str(creds[2], 'utf-8')
    username = str(creds[0], 'utf-8')
    password = str(creds[1], 'utf-8')

    try:

        logz = log(hostip, username, password)
    except:
        error = "ERR006 - Error getting system logs"
        return render_template('error/gen_error.html', error=error)

    return render_template('menu/logs.html', logz=logz)
コード例 #9
0
import json

from behave import given, when, then
import requests

import utilities.rw_csv as csv
from utilities.resources import ApiResources
from utilities.log import custom_logger as log

log = log()
log.info("\n\n")


@given(u'I set base REST API url and headers correctly')
def setup_baseurl(context):
    try:
        context.baseURL = context.config.userdata.get("base_url", "url")
        context.headers = {
            "token": context.config.userdata.get("access_token", "token"),
            "content-type": "application/json"
        }
        context.ad_account_id = context.config.userdata.get(
            "account_id", "1001")
        log.info(f"Base URL set to : {context.baseURL}")
        log.info(f"Headers set to : {context.headers}")
        log.info(f"account_id set to : {context.ad_account_id}")
    except Exception as e:
        log.exception(str(e))
        raise e

コード例 #10
0
    freq,  #freq of the gabor filters (px.)
    scale,  #std. of gabor gaussian (px.)
    tot,  #total size off ilter kernel (px.)
    nfilt,  #number of ffilters in the surround (only tested w/ 8)
    nang,  #number of angles at each sampling site
    npha,  #number of phases of filter 
    fdist,  #distance between center and surround (px.)
    samd  #distance between sampling points or filters
)

pname = MODEL + "_" + pname

if LAP:
    pname = pname + "LAP"

LOG = log.log(dirname + "/variability_runlog_" + pname + ".log",
              name="GSM variability computation")
print(pname)

if (len(glob.glob("./parameters/*" + pname + "_meansub.csv")) > 0
        and DEBUG == False):
    #if the parameters are here, load them in
    LOG.log("Using existing parameters")
    P = np.loadtxt("./parameters/pha_seg_probs_" + pname + "_meansub.csv")
    CNS = np.loadtxt("./parameters/pha_CNS_" + pname + "_meansub.csv")

    fac = np.loadtxt("./parameters/pha_fac_" + pname + ".csv")

    if MODEL == "ours":
        C1 = np.loadtxt("./parameters/pha_CS1_" + pname + "_meansub.csv")
        C2 = np.loadtxt("./parameters/pha_CS2_" + pname + "_meansub.csv")