Esempio n. 1
0
def init():
    global ip
    global address
    global weather

    sys.stdout.write("Initalizing")
    sys.stdout.flush()

    ip = info.getIp()
    if ip == -1:
        ip = "Error"
    sys.stdout.write("..")
    sys.stdout.flush()

    address = info.ipToAddress(ip)
    if address == -1:
        address = "Error"
    sys.stdout.write("..")
    sys.stdout.flush()

    weather = info.addressToWeather(address)
    if weather == -1 or weather == -2:
        weather = "Error"
    sys.stdout.write("..\n")
    sys.stdout.flush()
Esempio n. 2
0
def init():
    global ip
    global address
    global weather

    sys.stdout.write("Initalizing")
    sys.stdout.flush()

    ip = info.getIp()
    if (ip == -1):
        ip = "Error"
    sys.stdout.write("..")
    sys.stdout.flush()

    address = info.ipToAddress(ip)
    if (address == -1):
        address = "Error"
    sys.stdout.write("..")
    sys.stdout.flush()

    weather = info.addressToWeather(address)
    if (weather == -1 or weather == -2):
        weather = "Error"
    sys.stdout.write("..\n")
    sys.stdout.flush()
Esempio n. 3
0
            if address != "Error":
                address = colored(address, "green", "on_blue")
            else:
                address = info.ipToAddress(info.getIp())
                if address != -1:
                    address = colored(address, "green", "on_blue")
                else:
                    address = colored("Error", "red", "on_blue")
            print address

        # weather
        m = re.match(r"^weather(|\s(\w*))$", command)
        if m:
            if m.group() == "weather":
                cityname = info.ipToAddress(info.getIp())

                if weather == "Error":
                    weather = info.addressToWeather(info.ipToAddress(info.getIp()))
                    if weather == -1:
                        weather = colored("Error", "red", "on_blue")
                else:
                    print_weather()

            elif m.group(2) != "":
                cityname = m.group(2)
                weather = info.addressToWeather(cityname)
                if weather == -1:
                    weather = colored("Error", "red", "on_blue")
                else:
                    print_weather()
Esempio n. 4
0
                address = colored(address, 'green', 'on_blue')
            else:
                address = info.ipToAddress(info.getIp())
                if (address != -1):
                    address = colored(address, 'green', 'on_blue')
                else:
                    address = colored("Error", 'red', 'on_blue')
            print address

        #weather
        m = re.match(r"^weather(|\s(\w*))$", command)
        if (m):
            if (m.group() == "weather"):
                cityname = info.ipToAddress(info.getIp())

                if (weather == "Error"):
                    weather = info.addressToWeather(
                        info.ipToAddress(info.getIp()))
                    if (weather == -1):
                        weather = colored("Error", 'red', 'on_blue')
                else:
                    print_weather()

            elif (m.group(2) != ''):
                cityname = m.group(2)
                weather = info.addressToWeather(cityname)
                if (weather == -1):
                    weather = colored("Error", 'red', 'on_blue')
                else:
                    print_weather()