def parseAnswerServer(self, updateInfo): updateDict = parse_qs(updateInfo, strict_parsing=True) # updateDict has: mustUpdate, urlUser, newVersionUser, urlAdmin, # newVersionAdmin updates = dict() # updates has: mustUpdate, userFile, adminFile mustUpdate = int(updateDict['mustUpdate'][0]) updates['mustUpdate'] = mustUpdate downloader = Downloader() location = "../../persistent/downloads" if mustUpdate == 0: logger.info('No update available') elif (mustUpdate & UPDATE_ADMIN_MODE): adminURL = updateDict['urlAdmin'][0] logger.info('Downloading Admin update: %s' % adminURL) adminFile = downloader.downloadUpdate(location, adminURL) updates['adminFile'] = adminFile logger.info('Administrator update is available called: %s' % adminFile) if DISPLAY_GUI_MESSAGES and not(checkFiles.checkIfAdmin()): root = Tk() root.title('HiSPARC') Message(root, anchor='s', text="Update is available requiring " "administrator rights!\nPlease ask your administrator " "to reboot and install it!").pack(padx=150, pady=100) root.mainloop() elif (mustUpdate & UPDATE_USER_MODE): userURL = updateDict['urlUser'][0] logger.info('Downloading User update: %s' % userURL) userFile = downloader.downloadUpdate(location, userURL) updates['userFile'] = userFile logger.info('User update is available called: %s' % userFile) # Run the update to install it. # First call a batch file so that Python can be closed. os.system(".\\runUserUpdate.bat %s" % userFile) return updates
def checkIfUpdateToInstall(self): """Check if there is already an admin update to install Also check if you are currently in user or admin mode """ is_admin = checkFiles.checkIfAdmin() currentAdmin = self.config.ifgetint("Version", "CurrentAdmin", 0) currentUser = self.config.ifgetint("Version", "CurrentUser", 0) logger.info("You are Administrator: %s" % is_admin) logger.info("Current Admin Version: %s" % currentAdmin) logger.info("Current User Version: %s" % currentUser) if is_admin: location = "../../persistent/downloads" found, file_found = checkFiles.checkIfNewerFileExists( location, ADMINUPDATE_NAME, int(currentAdmin)) if found: logger.info("Found: %s" % file_found) os.system(".\\runAdminUpdate.bat " "../../persistent/downloads/%s" % file_found)