def printerror(): #Global Error message cwusage = "GET CURRENT WEATHER DETAILS\n This will output the current weather details (mainly temperature and weather condition) through the Raspberry Pi SenseHat module.\n\n\tUsage: python3 pwli.py current [location]\n\tExample: python3 pwli.py current kumamoto\n" fwusage = "GET FORECAST WEATHER DETAILS\n This will output the forecast weather details which the user can choose. Note that the forecast timing is 3-hourly so the program will only accept the time input in multiples of 3. The forecast details are also limited to 4 days in advance.\n\n\tUsage: python3 pwli.py 3hfc [location] [How many days from current date (0-4)] [time]\n\tExample: python3 pwli.py 3hfc kumamoto 2 6\n" jwusage = "GET FORECAST WEATHER WITH JOYSTICK\n This allows the user to select the day and time for the weather forecast using the joystick on the Sensehat of the Raspberry Pi.\n\n\tUsage: python3 pwli.py forecast [location]\n\tUp/Down -> Select Day\tLeft/Right -> Select Time\n\t2x Middle -> Show Weather\tLong Press Middle -> Stop" print(cwusage, fwusage, jwusage, sep='\n') senseLED.img_creeperSSS(2)
# Check whether parameters are input correctly if 5 >= len(sys.argv) >= 3: # Checking current weather if sys.argv[1] == "current": if len(sys.argv) == 3: print("Checking the current weather for '" + sys.argv[2] + "'\n") result = pyowmWeather.getcweather(sys.argv[2]) # SUCCESS if result: wID = result[1] wTemp = result[2] senseLED.finaloutput(wID, wTemp) # Location not found else: print("Location not found!") senseLED.img_creeperSSS(2) # 3-hourly forecast elif sys.argv[1] == "3hfc": if len(sys.argv) == 5: # Check that input 4 is int between 0-24 if checktimedinput(sys.argv[4]): # Check that input 3 is int in range 0-4 if 4 >= int(sys.argv[3]) >= 0: # If day is today, check time is not past if int(sys.argv[3]) == 0: if checkpasttime(int(sys.argv[4])): print("Checking the forecasted weather for '" + sys.argv[2] + "' " + "at " + sys.argv[4] + "00\n") result = pyowmWeather.get3hfweather(sys.argv[2], sys.argv[3], sys.argv[4]) # Location not found if result == False:
def printerror(): #Global Error message updateusage = "UPDATE WEATHER CACHE FOR LOCATION\n This will update the offline cache with the latest weather forecast for a given location.\n\n\tUsage: python3 pwli.py update [location]\n\tExample: python3 pwli.py update kumamoto\n" jwusage = "GET FORECAST WEATHER WITH JOYSTICK\n This allows the user to select the day and time for the weather forecast using the joystick on the Sensehat of the Raspberry Pi.\n\n\tUsage: python3 pwli.py forecast\n\tUp/Down -> Select Day\tLeft/Right -> Select Time\n\t2x Middle -> Show Weather\tLong Press Middle -> Stop" print(updateusage, jwusage, sep='\n') senseLED.img_creeperSSS(2)