Beispiel #1
0
def get_temperature(json, n=0, t="03:00:00"):
    now = datetime.datetime.now()
    date = now.day + n
    a = "2017-09-0" + str(date) + " " + t
    start = json.index(a)
    temperature = (json.find("temp", start)) + 6
    temp = json[temperature:(json.index(",", temperature))]
    temp = float(temp)
    #print temp
    return temp
Beispiel #2
0
def Callback_func(payload, responseStatus, token):
	msg = json.index(payload)
	illuminance = msg{'state'}{'illuminance'}
	print()
	print('UPDATE: $aws/things/' + Thing_Name + '/shadow/update/#')
	print("payload = " + payload)
	print("responseStatus = " + responseStatus)
	print("token = " + token)
Beispiel #3
0
def get_wind(json, n=0, t="03:00:00"):
    now = datetime.datetime.now()
    date = now.day + n
    a = "2017-09-0" + str(date) + " " + t
    start = json.index(a)
    wind = (json.find("speed", start)) + 7
    speed = float(json[wind:(json.find(",", wind))])
    #print speed
    return speed
Beispiel #4
0
def get_pressure(json, n=0, t="03:00:00"):
    now = datetime.datetime.now()
    date = now.day + n
    a = "2017-09-0" + str(date) + " " + t
    start = json.index(a)
    pressure = (json.find("pressure", start)) + 10
    pres = float(json[pressure:(json.find(",", pressure))])
    #print pres
    return pres
Beispiel #5
0
def get_humidity(json, n=0, t="03:00:00"):
    now = datetime.datetime.now()
    date = now.day + n
    a = "2017-09-0" + str(date) + " " + t
    start = json.index(a)
    humidity = (json.find("humid", start)) + 10
    humid = json[humidity:(json.find(",", humidity))]
    humid = float(humid)
    #print humid
    return humid
Beispiel #6
0
def has_error(loca, json):
    cityin = json.index("name") + 7
    city = json[cityin:((json.find(",", -57)) - 1)]
    #print city
    if (loca.lower() == city.lower()):
        #print False
        return False
    else:
        #print True
        return True
Beispiel #7
0
def strip_json(json):

    json = json.strip()

    if not json.startswith("{"):
        json = json[json.index("{"):]

    if not json.endswith("}"):
        json = json[:json.rindex("}") + 1]

    return json
Beispiel #8
0
def strip_json(json):

    json = json.strip()

    if not json.startswith("{"):
        json = json[json.index("{") :]

    if not json.endswith("}"):
        json = json[: json.rindex("}") + 1]

    return json
Beispiel #9
0
def get_champion_mastery_data(summoner_name):
    url = f"https://na1.api.riotgames.com/lol/champion-mastery/v4/champion-masteries/by-summoner/{get_summoner_id(summoner_name)}?api_key={riot_key}"
    json = requests.get(url).json()
    top_three_champs = []
    for champ in json:
        top_three_champs.append([
            champ['championId'], champ['championLevel'],
            champ['championPoints']
        ])
        if json.index(champ) == 2:
            break
    return top_three_champs
Beispiel #10
0
def get_sealevel(json, n=0, t="03:00:00"):
    now = datetime.datetime.now()
    date = now.day + n
    a = "2017-09-0" + str(date) + " " + t
    start = json.index(a)
    sea = (json.find("sea_level", start)) + 11
    seal = float(json[sea:(json.find(",", sea))])
    #print seal
    return seal


#get_sealevel(a,2,"09:00:00")
Beispiel #11
0
def emailCheck(email):
    apiKey = "XXXXXXXXXXXXXXXXXXXXXXX"
    response = requests.get("https://haveibeenpwned.com/api/v3/breachedaccount/"+email+"?truncateResponse=false", headers = {"hibp-api-key":apiKey})

    if(response.status_code == 400): # BAD REQUEST
        print("-" * 60 + "\n")
        print("No e-mails at the document || Reading Error")
    elif (response.status_code == 404): # Request not found. (Nenhum vazamento encontrado)
        print("-" * 60 + "\n")
        print("The email "+email+" has not been pwned!\n")
        print("-" * 60)
    elif (response.status_code == 200): # Request found.
        print("-" * 60 + "\n")
        print("The email "+email+" has been pwned! \n")
        print()
        
        json = str(response.json()).split()
        a = json[json.index("'AddedDate':")]
        d = []
        domain = json.index("'Description':") + 1
        logo = json.index("'LogoPath':")
        cont = 0
        while domain < logo:
            cont = cont + 1
            a = json[json.index("'Description':") + cont] + " "
            d.append(a)
            domain = domain + 1

        d = ''.join(d)

        print("{\n")
        print(json[json.index("'Title':")] + json[json.index("'Title':") + 1])
        print(json[json.index("'Domain':")] + json[json.index("'Domain':") + 1])
        print(json[json.index("'BreachDate':")] + json[json.index("'BreachDate':") + 1])
        pprint(json[json.index("'Description':")] + d)
        print(json[json.index("'IsRetired':")] + json[json.index("'IsRetired':") + 1])
        print(json[json.index("'IsSensitive':")] + json[json.index("'IsSensitive':") + 1])
        print(json[json.index("'IsVerified':")] + json[json.index("'IsVerified':") + 1])
        print(json[json.index("'LogoPath':")] + json[json.index("'LogoPath':") + 1])
        print("'Name':" + json[json.index("{'Name':") + 1])
        print(json[json.index("'PwnCount':")] + json[json.index("'PwnCount':") + 1])
        print("}")