def refresh_firmware(request=None): # Before we load anything, check to make sure that the model version on fermentrack.com matches the model version # that we can support if get_model_version() != check_model_version(): if request is not None: messages.error(request, "The firmware information available at fermentrack.com isn't something this " + "version of Fermentrack can interpret. Please update and try again.") return False # First, load the device family list families_loaded = DeviceFamily.load_from_website() if families_loaded: # And if that worked, load the firmware list board_loaded = Board.load_from_website() if board_loaded: firmware_loaded = Firmware.load_from_website() else: if request is not None: messages.error(request, "Unable to load boards from fermentrack.com") return False else: # If it didn't work, return False if request is not None: messages.error(request, "Unable to load families from fermentrack.com") return False # if request is not None: # messages.success(request, "Firmware list was successfully refreshed from fermentrack.com") config.FIRMWARE_LIST_LAST_REFRESHED = timezone.now() # Update the "last refreshed" check return firmware_loaded
def refresh_firmware(request=None): # Before we load anything, check to make sure that the model version on fermentrack.com matches the model version # that we can support if get_model_version() != check_model_version(): if request is not None: messages.error( request, "The firmware information available at fermentrack.com isn't something this " + "version of Fermentrack can interpret. Please update Fermentrack and try again." ) return False # First, load the device family list families_loaded = DeviceFamily.load_from_website() if families_loaded: # This should be done automatically (via cascading deletes) but breaking it out explicitly here just in case Firmware.objects.all().delete() Project.objects.all().delete() Board.objects.all().delete() # And if that worked, load the firmware list board_loaded = Board.load_from_website() if board_loaded: projects_loaded = Project.load_from_website() if projects_loaded: firmware_loaded = Firmware.load_from_website() if firmware_loaded: # Success! Families, Boards, Projects, and Firmware are all loaded config.FIRMWARE_LIST_LAST_REFRESHED = timezone.now( ) # Update the "last refreshed" check return firmware_loaded else: if request is not None: messages.error( request, "Unable to load firmware from fermentrack.com") return False else: if request is not None: messages.error( request, "Unable to load projects from fermentrack.com") return False else: if request is not None: messages.error(request, "Unable to load boards from fermentrack.com") return False else: # If it didn't work, return False if request is not None: messages.error(request, "Unable to load families from fermentrack.com") return False