def chutaai():

    if ((chuta.lineEdit_4.text()) in alfabeto):
        if ((chuta.lineEdit_4.text()) not in lista_chute):


            for row in (chutejog.select(chutejog.tentativa, fn.max(chutejog.id))):
                tentativas = (row.tentativa)



            if tentativas < 5:
                for row in (criapalavra.select(criapalavra.dica, fn.max(criapalavra.id))):
                    dica = (row.dica)

                update_acertos(lista_chute, acertos, tentativas)

            for row in (chutejog.select(chutejog.tentativa, fn.max(chutejog.id))):
                tentativas = (row.tentativa)

            layout_palavra(tentativas)

            lista_chutelabel = ((" - ".join(lista_chute)).upper())
            chuta.label_10.setText(lista_chutelabel)
            chuta.lineEdit_4.setText("")


        else:
            QMessageBox.about(chuta,"AVISO", "LETRA JÁ CITADA")
    else:
        QMessageBox.about(chuta, "AVISO", "Caractere inválido!")
Esempio n. 2
0
def update_last_term():
    query = Legislator.select(
        Legislator.name,
        fn.max(Legislator.term).alias("last_term")).group_by(Legislator.name)
    for legislator in query:
        Candidate.update(lastTerm=legislator.last_term).where(
            Candidate.name == legislator.name).execute()
def layout_palavra(tentativas): #puxar do banco de dados
    x = []

    for row in (criapalavra.select(criapalavra.palavrasecreta, fn.max(criapalavra.id))):
        palavra_secreta = (row.palavrasecreta)

    if tentativas == 1: #puxar tentativas da tabela chute
        chuta.label_12.setPixmap(QtGui.QPixmap('forca1.png'))
    elif tentativas == 2:
        chuta.label_12.setPixmap(QtGui.QPixmap('forca2.png'))
    elif tentativas == 3:
        chuta.label_12.setPixmap(QtGui.QPixmap('forca3.png'))
    elif tentativas == 4:
        chuta.label_12.setPixmap(QtGui.QPixmap('forca4.png'))
    elif tentativas == 5:
        chuta.label_12.setPixmap(QtGui.QPixmap('forca5.png'))
        time.sleep(5)
        chuta.label_12.setPixmap(QtGui.QPixmap('forca6.png'))
        chutejog.delete()


    for acerto, letra in zip(acertos, palavra_secreta):
        if acerto: # quer dizer que se o acerto for igual a True
            x.append(letra)
        else: #se o acerto for falso
            x.append("_")

    y = " ".join(x)

    chuta.label_6.setText(y.upper())
Esempio n. 4
0
 def customer_update(self, number):
     subscribed_brands = Subscription.select(
         Subscription.brand_id).where(Subscription.customer_id == number)
     prices = (PriceChange.select(PriceChange, Product).join(Product).where(
         PriceChange.product.brand.in_(subscribed_brands)).order_by(
             -PriceChange.updated_at).group_by(
                 PriceChange.product_id).having(
                     fn.max(PriceChange.updated_at)))
     return render_template('customer_update.html', prices=prices)
def kuehlvariante_holen_db(kuehlvariante):
    erg = Kuehlvarianten.select(
        Kuehlvarianten.id).where(Kuehlvarianten.variante == kuehlvariante)
    if erg.count() == 0:
        max_id = Kuehlvarianten.select(fn.max(Kuehlvarianten.id)).scalar()
        if max_id is None:
            max_id = 0
        Kuehlvarianten.insert(id=max_id + 1, variante=kuehlvariante).execute()
        erg = kuehlvariante_holen_db(kuehlvariante)
    return erg
def daten_vorheriger_stunden_laden(exportdaten):
    # Berechnung des Barometertrends 3h
    # Timestamp für vor 3 Stunden
    timestamp = datetime.datetime.fromtimestamp(
        exportdaten["timestamp"]) - datetime.timedelta(hours=3)
    timestamp = timestamp.timestamp()

    data = db_weewx.Archive.select().where(db_weewx.Archive.date_time <= timestamp)\
        .order_by(db_weewx.Archive.date_time.desc()).limit(1).execute()[0]

    if data.us_units == 1:
        barometer = mwu.druckumrechner(data.barometer)
    else:
        barometer = data.barometer
    exportdaten["luftdrucktrend"] = round(
        (exportdaten["luftdruck"] - barometer), 1)

    # Berechnung des Timestamp zum Begin des aktuellen Tages
    timestamp = datetime.datetime.fromtimestamp(exportdaten["timestamp"])
    timestamp = datetime.datetime(
        *timestamp.timetuple()
        [:3])  # Uhrzeit wird weggeschnitten >>Beginn 00:00Uhr
    timestamp = timestamp.timestamp()
    # Laden der Minimalen und Maximalen Temperatur und der Windspitzengeschwindigkeit des aktuellen Tages
    data = db_weewx.Archive.select(
        db_weewx.Archive.us_units,
        fn.min(db_weewx.Archive.out_temp).alias("mintemp"),
        fn.max(db_weewx.Archive.out_temp).alias("maxtemp"),
        fn.max(db_weewx.Archive.wind_gust).alias("windspitze")).where(
            db_weewx.Archive.date_time > timestamp).namedtuples()[0]
    if data.us_units == 1:
        mintemp = mwu.temperaturumrechner(data.mintemp)
        maxtemp = mwu.temperaturumrechner(data.maxtemp)
        windspitze = mwu.windumrechner(data.windspitze)
    else:
        mintemp = data.mintemp
        maxtemp = data.maxtemp
        windspitze = data.windspitze
    exportdaten["tempminheute"] = mintemp
    exportdaten["tempmaxheute"] = maxtemp
    exportdaten["windspitzetag"] = windspitze

    # Laden der Regenmenge des aktuellen Tages
    exportdaten["regenHeute"] = regenmenge_auslesen(timestamp)

    # Laden der Regenmenge der letzten Stunde
    timestamp = datetime.datetime.fromtimestamp(
        exportdaten["timestamp"]) - datetime.timedelta(hours=1)
    timestamp = timestamp.timestamp()
    exportdaten["regenlasth"] = regenmenge_auslesen(timestamp)

    # Laden der Regenmenge der letzten 24 Stunden
    timestamp = datetime.datetime.fromtimestamp(
        exportdaten["timestamp"]) - datetime.timedelta(hours=24)
    timestamp = timestamp.timestamp()
    exportdaten["regen24h"] = regenmenge_auslesen(timestamp)

    # Berechnung der Temperaturänderung der letzten Stunde
    # Timestamp für vor 1 Stunde
    timestamp = datetime.datetime.fromtimestamp(
        exportdaten["timestamp"]) - datetime.timedelta(hours=1)
    timestamp = timestamp.timestamp()
    data = db_weewx.Archive.select(
        db_weewx.Archive.us_units, db_weewx.Archive.out_temp).where(
            db_weewx.Archive.date_time <= timestamp).order_by(
                db_weewx.Archive.date_time.desc()).limit(1).namedtuples()[0]
    if data.us_units == 1:
        temperatur = mwu.temperaturumrechner(data.out_temp)
    else:
        temperatur = data.out_temp
    exportdaten["temperaturaenderung"] = round(
        (exportdaten["outTemp"] - temperatur), 1)
    return exportdaten