commit/galaxy-central: natefoo: Don't duplicate util.submodules in runner state handler factory.
1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/404fcf47260d/ Changeset: 404fcf47260d User: natefoo Date: 2014-06-18 22:41:53 Summary: Don't duplicate util.submodules in runner state handler factory. Affected #: 1 file diff -r 7b209e06ddb944e953d340754439f4e3e5dc339d -r 404fcf47260db528f04b2a6ce75ede9015f4228b lib/galaxy/jobs/runners/state_handler_factory.py --- a/lib/galaxy/jobs/runners/state_handler_factory.py +++ b/lib/galaxy/jobs/runners/state_handler_factory.py @@ -1,8 +1,8 @@ -# Shamelessly stolen from the LWR. - import os import logging +from galaxy.util.submodules import submodules + import galaxy.jobs.runners.state_handlers @@ -11,40 +11,9 @@ def build_state_handlers(): return _get_state_handlers_dict() -def _get_modules(): - """ - >>> 'galaxy.jobs.runners.state_handlers.resubmit' in _get_modules() - True - """ - state_handlers_dir = galaxy.jobs.runners.state_handlers.__path__[0] - module_names = [] - for fname in os.listdir(state_handlers_dir): - if not(fname.startswith("_")) and fname.endswith(".py"): - module_name = "galaxy.jobs.runners.state_handlers.%s" % fname[:-len(".py")] - module_names.append(module_name) - log.debug('module_names: %s', module_names) - return module_names - -def _load_modules(): - modules = [] - for module_name in _get_modules(): - try: - log.debug('Importing %s', module_name) - module = __import__(module_name) - for comp in module_name.split(".")[1:]: - module = getattr(module, comp) - modules.append(module) - except BaseException as exception: - exception_str = str(exception) - message = "%s module could not be loaded: %s" % (module_name, exception_str) - log.warn(message) - continue - - return modules - def _get_state_handlers_dict(): state_handlers = {} - for module in _load_modules(): + for module in submodules(galaxy.jobs.runners.state_handlers): for func in module.__all__: if func not in state_handlers: state_handlers[func] = [] Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.
participants (1)
-
commits-noreply@bitbucket.org