def update_sites(self, minutes=20, limit=None): """ Updates all feeds from all sites. 'minutes' is for checking sites which were last checked before that number of minutes. E.g: if you set it to 20, then the site will only be checked if last check was more than 20 minutes ago. Set 0 for checking always. 'limit' reduces the number of updated sites. Leave blank to check all. """ if not isinstance(minutes, int): s = "update_sites: not a valid 'minutes' argument, must be int." self.logger.error(s) raise TypeError(s) elif minutes < 0: s = "update_sites: 'minutes' must be less or equal than 0." self.logger.error(s) raise ValueError(s) if limit is None: pass elif not isinstance(limit, int): s = "update_sites: not a valid 'limit' argument, must be int." self.logger.error(s) raise TypeError(s) elif limit <= 0: s = "update_sites: 'limit' must be more than 0." self.logger.error(s) raise ValueError(s) l = [] for site in self.sites: if not site.inactive: l.append(site.feed) fm = FeedManager(l) fm.update_feeds(minutes, limit) # Save changes to site and dependent objects self.session.commit() return self