= {} def register_processes(): """This gets available processes, auto-imported by walking the processes package. We walk the user package beforehand to check for newly uploaded processes. """ global available_processes available_processes.clear() walk_packages() for p in Process.__subclasses__(): try: if getattr(p, 'name', None) is not None: available_processes[p.name] = p except TypeError: continue log.debug('Available processes: ' + repr(available_processes)) def walk_packages(pkg=sys.modules[__name__], comp_str='process_'): """Recursively auto-import all modules beginning with the comparison string.""" for importer, name, ispkg in pkgutil.walk_packages(pkg.__path__, prefix=pkg.__name__+'.'): if name.split('.')[-1].startswith(comp_str): __import__(name) log.info('Imported ' + name)