Exemplo n.º 1
0
 def find_app(self, app):
     try:
         sym = self.symbol_by_name(app)
     except AttributeError:
         # last part was not an attribute, but a module
         sym = import_from_cwd(app)
     if isinstance(sym, ModuleType):
         try:
             return sym.app
         except AttributeError:
             try:
                 return sym.celery
             except AttributeError:
                 if getattr(sym, '__path__', None):
                     try:
                         return self.find_app(
                             '{0}.celery:'.format(app.replace(':', '')),
                         )
                     except ImportError:
                         pass
                 for suspect in values(vars(sym)):
                     if isinstance(suspect, Celery):
                         return suspect
                 raise
     return sym
Exemplo n.º 2
0
 def find_app(self, app):
     try:
         sym = self.symbol_by_name(app)
     except AttributeError:
         # last part was not an attribute, but a module
         sym = import_from_cwd(app)
     if isinstance(sym, ModuleType):
         if getattr(sym, '__path__', None):
             return self.find_app('%s.celery:' % (app.replace(':', ''), ))
         return sym.celery
     return sym
Exemplo n.º 3
0
 def find_app(self, app):
     try:
         sym = self.symbol_by_name(app)
     except AttributeError:
         # last part was not an attribute, but a module
         sym = import_from_cwd(app)
     if isinstance(sym, ModuleType):
         if getattr(sym, '__path__', None):
             return self.find_app('%s.celery:' % (app.replace(':', ''), ))
         return sym.celery
     return sym
Exemplo n.º 4
0
 def find_app(self, app):
     try:
         sym = self.symbol_by_name(app)
     except AttributeError:
         # last part was not an attribute, but a module
         sym = import_from_cwd(app)
     if isinstance(sym, ModuleType):
         try:
             return sym.celery
         except AttributeError:
             if getattr(sym, "__path__", None):
                 return self.find_app("{0}.celery:".format(app.replace(":", "")))
             raise
     return sym
Exemplo n.º 5
0
    def _load_object(self, path):
        # imp = import_from_cwd
        if ':' in path:
            # Path includes attribute so can just jump
            # here (e.g., ``os.path:abspath``).
            return symbol_by_name(path, imp=import_from_cwd)

        # Not sure if path is just a module name or if it includes an
        # attribute name (e.g., ``os.path``, vs, ``os.path.abspath``).
        try:
            return import_from_cwd(path)
        except ImportError:
            # Not a module name, so try module + attribute.
            return symbol_by_name(path, imp=import_from_cwd)
Exemplo n.º 6
0
def load_confmod(parser, confmod):
    # import here so we can fix the sys.path when running the script directly
    from openkongqi.conf import config_from_object

    if confmod is None:
        parser.print_help()
        sys.exit(1)

    try:
        find_module(confmod)
    except (ImportError, NotAPackage):
        sys.stderr.write("configuration parameter is not a module"
                         "({})\n".format(confmod))
        parser.print_help()
        sys.exit(1)

    mod = import_from_cwd(confmod)
    config_from_object(mod)
Exemplo n.º 7
0
def load_confmod(parser, confmod):
    # import here so we can fix the sys.path when running the script directly
    from openkongqi.conf import config_from_object

    if confmod is None:
        parser.print_help()
        sys.exit(1)

    try:
        find_module(confmod)
    except (ImportError, NotAPackage):
        sys.stderr.write("configuration parameter is not a module"
                "({})\n".format(confmod))
        parser.print_help()
        sys.exit(1)

    mod = import_from_cwd(confmod)
    config_from_object(mod)
Exemplo n.º 8
0
    def find_app(self, app):
        try:
            sym = self.symbol_by_name(app)
        except AttributeError:
            # last part was not an attribute, but a module
            sym = import_from_cwd(app)
        if isinstance(sym, ModuleType):
            try:
                return sym.celery
            except AttributeError:
                if getattr(sym, "__path__", None):
                    try:
                        return self.find_app("{0}.celery:".format(app.replace(":", "")))
                    except ImportError:
                        pass
                from celery.app.base import Celery

                for suspect in values(vars(sym)):
                    if isinstance(suspect, Celery):
                        return suspect
                raise
        return sym
Exemplo n.º 9
0
 def import_from_cwd(self, module, imp=None, package=None):
     return import_from_cwd(
         module,
         self.import_module if imp is None else imp,
         package=package,
     )
Exemplo n.º 10
0
 def import_from_cwd(self, module, imp=None, package=None):
     return import_from_cwd(module,
                            self.import_module if imp is None else imp,
                            package=package)