def get_module_by_slug(slug): """ Searches for a module by slug """ for cls in get_module_classes(): if cls().get_slug() == slug: return cls
def get_overview_data(self): data = [] for cls in get_module_classes(): instance = cls() if instance.check_compatible(): data.append({'name': instance.name, 'value': instance.get_val(), 'text': instance.get_text(), 'warning': instance.check_warning(), 'link': instance.link_url}) return data
def get_overview_data(self): data = [] for cls in get_module_classes(self.get_group()): instance = cls() if instance.check_compatible(): data.append({'name': instance.name, 'value': instance.get_val(), 'text': instance.get_text(), 'warning': instance.check_warning(), 'link': instance.link_url, 'group': self.get_group}) return data
def update_modules(logger=None): """ Process all module updates """ now = datetime.datetime.utcnow() for cls in get_module_classes(): instance = cls() if not instance.check_compatible(): continue if instance.write_to_db: if logger: logger.debug('Saving %s - Value: %.2f' % (instance.name, instance.get_val())) try: module = ModuleStat.objects.get( modulename=instance.get_slug(), added__year=now.year, added__month=now.month, added__day=now.day) module.value=instance.get_val() module.save() except ModuleStat.DoesNotExist: ModuleStat.objects.create(modulename=instance.get_slug(), value=instance.get_val())