コード例 #1
0
def Meteo(conf, TextPAPIRUS, Units):  #Fonction Météo (OpenWeatherMap)
    SV.SVMeteo(conf)

    TextPAPIRUS.AddText("Météo:", 10, 10, size=20, fontPath="Ubuntu.ttf")
    TextPAPIRUS.AddText("Température: " + str(SV.DataMeteo["main"]["temp"]) +
                        "°C",
                        10,
                        40,
                        size=25,
                        fontPath="Ubuntu.ttf")
    TextPAPIRUS.AddText("Temp. Min: " + str(SV.DataMeteo["main"]["temp_min"]) +
                        "°C" + " Temp. Max: " +
                        str(SV.DataMeteo["main"]["temp_max"]) + Units,
                        10,
                        65,
                        size=12,
                        fontPath="Ubuntu.ttf")
    TextPAPIRUS.AddText("Temps: " +
                        SV.DataMeteo["weather"][0]["description"].capitalize(),
                        10,
                        85,
                        size=25,
                        fontPath="Ubuntu.ttf")

    TextPAPIRUS.AddText(time.strftime("%H:%M", time.localtime()),
                        200,
                        10,
                        size=20,
                        fontPath="Ubuntu.ttf")

    TextPAPIRUS.WriteAll(True)
    time.sleep(10)
    TextPAPIRUS.Clear()
コード例 #2
0
def AllInit(conf, TextPAPIRUS, BearerAUTH):
    TextPAPIRUS.AddText(time.strftime("%H:%M", time.localtime()),
                        200,
                        10,
                        size=20,
                        fontPath="Ubuntu.ttf")

    SV.SVCrypto(conf)
    TextTextPAPIRUS.AddText("Crypto:", 10, 10, size=15, fontPath="Ubuntu.ttf")

    PCTC1 = list(
        str(SV.DataCrypto["RAW"][conf["CRYPTO"]["Coin1"]][
            conf["CRYPTO"]["Currency"]]["CHANGEPCT24HOUR"]))
    del PCTC1[-14:-1]
    PCTC2 = list(
        str(SV.DataCrypto["RAW"][conf["CRYPTO"]["Coin2"]][
            conf["CRYPTO"]["Currency"]]["CHANGEPCT24HOUR"]))
    del PCTC2[-14:-1]

    TextPAPIRUS.AddText(conf["CRYPTO"]["Coin1"] + ": " +
                        conf["CRYPTO"]["Currency"] + " " +
                        str(SV.DataCrypto["RAW"][conf["CRYPTO"]["Coin1"]][
                            conf["CRYPTO"]["Currency"]]["PRICE"]),
                        10,
                        25,
                        size=15,
                        fontPath="Ubuntu.ttf",
                        Id="Coin1P")
    TextPAPIRUS.AddText(conf["CRYPTO"]["Coin2"] + ": " +
                        conf["CRYPTO"]["Currency"] + " " +
                        str(SV.DataCrypto["RAW"][conf["CRYPTO"]["Coin2"]][
                            conf["CRYPTO"]["Currency"]]["PRICE"]),
                        100,
                        25,
                        size=15,
                        fontPath="Ubuntu.ttf",
                        Id="Coin2P")
    TextPAPIRUS.AddText("".join(PCTC1) + "%",
                        10,
                        40,
                        size=10,
                        fontPath="Ubuntu.ttf",
                        Id="Coin1PCT")
    TextPAPIRUS.AddText("".join(PCTC2) + "%",
                        100,
                        40,
                        size=10,
                        fontPath="Ubuntu.ttf",
                        Id="Coin2PCT")

    SV.SVMeteo(conf)
    TextPAPIRUS.AddText("Météo:", 10, 10, size=20, fontPath="Ubuntu.ttf")
    TextPAPIRUS.AddText("Température: " + str(SV.DataMeteo["main"]["temp"]) +
                        "°C",
                        10,
                        40,
                        size=25,
                        fontPath="Ubuntu.ttf",
                        Id="Deg")
    TextPAPIRUS.AddText("Temps: " +
                        SV.DataMeteo["weather"][0]["description"].capitalize(),
                        10,
                        85,
                        size=25,
                        fontPath="Ubuntu.ttf",
                        Id="Temps")
コード例 #3
0
	def APICheck(): #Fonction de test de chaque paramètre (sauf Twitch)
		Check = 0

		#Test des APIs
		try:
			if conf["WEATHER"]["MeteoAPI"] != "":
				SV.SVMeteo(conf)
				if 400 <= int(SV.DataMeteo["cod"]) <= 599: 
						ERROR = "Erreur dans la config Météo, veuillez vérifier votre saisie!"
						ErrorConfig(ERROR)
						return
				else:
					Check += 1
			else:
				Check += 1

			if conf["CRYPTO"]["CryptoAPI"] != "":
				SV.SVCrypto(conf)
				try:
					if SV.DataCrypto["Response"] == "Error":
						ERROR = "Erreur dans la config Crypto, veuillez vérifier votre saisie!"
						ErrorConfig(ERROR)
						return
				except KeyError:
					Check += 1
			else:
				Check += 1

			if conf["LASTFM"]["LastFmAPI"] != "":
				SV.SVMusique(conf)
				try:
					if 2 <= int(SV.DataLast["error"]) <= 29:
						ERROR = "Erreur dans la config LastFM, veuillez vérifier votre saisie!"
						ErrorConfig(ERROR)
						return
				except KeyError:
					Check += 1
			else:
				Check += 1

			if conf["TWITTER"]["TwitterAPI"] != "" and conf["TWITTER"]["twitterapisecret"] != "":
				try:
					BearerRAW = os.popen("curl -u '"+ conf["TWITTER"]["TwitterAPI"] + ":" + conf["TWITTER"]["TwitterAPISecret"] + "' --data 'grant_type=client_credentials' 'https://api.twitter.com/oauth2/token'").read()
					BearerJSON = json.loads(BearerRAW)
					BearerAUTH = BearerJSON["access_token"]
				except KeyError:
					ERROR = "Erreur dans la config Twitter, il faut 2 clés API! Veuillez vérifier votre saisie!"
					ErrorConfig(ERROR)
					return
				finally:
					try:
						SV.SVTwitter(conf, BearerAUTH)
						if 49 <= int(SV.DataTwitter["errors"][0]["code"]) <= 599:
							ERROR = "Erreur dans la config Twitter, veuillez vérifier votre saisie!"
							ErrorConfig(ERROR)
							return
					except KeyError:
						Check += 1
			else:
				Check += 1

			if conf["RATP"]["typetransA"] != "" and conf["RATP"]["lineA"] != "" and conf["RATP"]["stationA"] != "":
				try:
					SV.SVRATP(conf)
					if SV.OutputA["result"]["code"] == 404:
						ERROR = "Erreur dans la config RATP A, veuillez vérifier votre saisie!"
						ErrorConfig(ERROR)
						return
				except:
					if conf["RATP"]["typetransB"] != "" and conf["RATP"]["lineB"] != "" and conf["RATP"]["stationB"] != "":
						try:
							if SV.OutputB["result"]["code"] == 404:
								ERROR = "Erreur dans la config RATP B, veuillez vérifier votre saisie!"
								ErrorConfig(ERROR)
								return
						except:
							Check += 1
					else:
						Check += 1
			else:
				Check += 1

		except (ValueError, socket.error, socket.gaierror, socket.herror, socket.timeout): #Situation d'erreur de connexion
			TextPAPIRUS.Clear()
			TextPAPIRUS.AddText("Erreur de connexion, nouvelle tentative de connexion dans: T", 10, 48, size = 20, fontPath="Ubuntu.ttf", Id="TimerErr")
			for I in range(15):
				TextPAPIRUS.UpdateText("TimerErr", "Erreur de connexion, \nnouvelle tentative de connexion dans: " + str(15 - I), fontPath="Ubuntu.ttf")
				TextPAPIRUS.WriteAll(True)
				time.sleep(1)
			TextPAPIRUS.Clear()
			APICheck()

		finally: #Fin de la vérification des API
			if Check == 5:
				HashSave()