Exemplo n.º 1
0
def getData(argumentsParser, exist):  

    filteredList = list()

    i=0

    while (i < len(attributes)):

        if getattr(argumentsParser, attributes[i][0]):
            
            for unArgument in getattr(argumentsParser, attributes[i][0]):
                playList = ResearchBase(attributes, unArgument[0], attributes[i][0])
                final = filterList(filteredList, playList, unArgument[1] * argumentsParser.duration / 100 * 60)

                if (final is not None):
                    filteredList.append(final)
        i+=1
        
    if exist == False:
        try:
            playList = list(connexion.execute(sqlalchemy.select([mes_morceaux])))
            
            final = filterList(filteredList, playList, argumentsParser.duration * 60)
        except Exception:
            logging.error("The program could not retrieve a list of songs")

        if (final is not None):
            filteredList.append(final)

    return filteredList
Exemplo n.º 2
0
def ResearchBase(attributes, targetValue, arg):
    i = 0
    find = False
    
    while (i < len(attributes) and find == False):

        if attributes[i][0] == arg:
            nameColumn = attributes[i][1]
            try :
                playList = list(connexion.execute(sqlalchemy.select([mes_morceaux]).where(getattr(mes_morceaux.c, nameColumn) == targetValue)))
                find = True
                logging.info("Connect to the database ")
            except Exception:
                logging.error("Impossible to connect to the database")

        i += 1
    return playList