Пример #1
0
def main():
    args = sys.argv[1:]

    # The only shared option is '--addons-path=' needed to discover additional
    # commands from modules
    print 'args = %s' % args
    if len(args) > 1 and args[0].startswith(
            '--addons-path=') and not args[1].startswith("-"):
        # parse only the addons-path, do not setup the logger...
        tools.config._parse_config([args[0]])
        args = args[1:]

    # Default legacy command
    command = "server"

    # Subcommand discovery
    if len(args) and not args[0].startswith("-"):
        logging.disable(logging.CRITICAL)
        for m in module.get_modules():
            m = 'openerp.addons.' + m
            __import__(m)
            #try:
            #except Exception, e:
            #    raise
            #    print e
        logging.disable(logging.NOTSET)
        command = args[0]
        args = args[1:]
    print 'command = %s' % command
    print module.get_modules()
    if command in commands:
        o = commands[command]()
        o.run(args)
Пример #2
0
def main():
    args = sys.argv[1:]

    # The only shared option is '--addons-path=' needed to discover additional
    # commands from modules
    if len(args) > 1 and args[0].startswith(
            '--addons-path=') and not args[1].startswith("-"):
        # parse only the addons-path, do not setup the logger...
        tools.config._parse_config([args[0]])
        args = args[1:]

    # Default legacy command
    command = "server"

    # Subcommand discovery
    if len(args) and not args[0].startswith("-"):
        logging.disable(logging.CRITICAL)
        for m in module.get_modules():
            m_path = module.get_module_path(m)
            if os.path.isdir(os.path.join(m_path, 'cli')):
                __import__('openerp.addons.' + m)
        logging.disable(logging.NOTSET)
        command = args[0]
        args = args[1:]

    if command in commands:
        o = commands[command]()
        o.run(args)
Пример #3
0
def main():
    args = sys.argv[1:]

    # The only shared option is '--addons-path=' needed to discover additional
    # commands from modules
    if len(args) > 1 and args[0].startswith('--addons-path=') and not args[1].startswith("-"):
        # parse only the addons-path, do not setup the logger...
        tools.config._parse_config([args[0]])
        args = args[1:]

    # Default legacy command
    command = "server"

    # Subcommand discovery
    if len(args) and not args[0].startswith("-"):
        logging.disable(logging.CRITICAL)
        for m in module.get_modules():
            m = 'openerp.addons.' + m
            __import__(m)
            #try:
            #except Exception, e:
            #    raise
            #    print e
        logging.disable(logging.NOTSET)
        command = args[0]
        args = args[1:]

    if command in commands:
        o = commands[command]()
        o.run(args)
Пример #4
0
def main():
    args = sys.argv[1:]

    # The only shared option is '--addons-path=' needed to discover additional
    # commands from modules
    if len(args) > 1 and args[0].startswith(
            '--addons-path=') and not args[1].startswith("-"):
        tools.config.parse_config([args[0]])
        args = args[1:]

    # Default legacy command
    command = "server"

    # Subcommand discovery
    if len(args) and not args[0].startswith("-"):
        for m in module.get_modules():
            m = 'openerp.addons.' + m
            __import__(m)
            #try:
            #except Exception, e:
            #    raise
            #    print e
        command = args[0]
        args = args[1:]

    if command in commands:
        o = commands[command]()
        o.run(args)
Пример #5
0
    def index(self, req, mod=None, **kwargs):
        ms = module.get_modules()
        manifests = dict(
            (name, desc)
            for name, desc in zip(ms, map(self.load_manifest, ms))
            if desc # remove not-actually-openerp-modules
        )

        if not mod:
            return NOMODULE_TEMPLATE.render(modules=(
                (manifest['name'], name)
                for name, manifest in manifests.iteritems()
                if any(testfile.endswith('.js')
                       for testfile in manifest['test'])
            ))
        sorted_mods = module_topological_sort(dict(
            (name, manifest.get('depends', []))
            for name, manifest in manifests.iteritems()
        ))
        # to_load and to_test should be zippable lists of the same length.
        # A falsy value in to_test indicate nothing to test at that index (just
        # load the corresponding part of to_load)
        to_test = sorted_mods
        if mod != '*':
            if mod not in manifests:
                return req.not_found(NOTFOUND.render(module=mod))
            idx = sorted_mods.index(mod)
            to_test = [None] * len(sorted_mods)
            to_test[idx] = mod

        tests_candicates = [
            filter(lambda path: path.endswith('.js'),
                   manifests[mod]['test'] if mod else [])
            for mod in to_test]
        # remove trailing test-less modules
        tests = reversed(list(
            itertools.dropwhile(
                operator.not_,
                reversed(tests_candicates))))

        files = [
            (mod, manifests[mod]['js'], tests, manifests[mod]['qweb'])
            for mod, tests in itertools.izip(sorted_mods, tests)
        ]

        # if all three db_info parameters are present, send them to the page
        db_info = dict((k, v) for k, v in kwargs.iteritems()
                       if k in ['source', 'supadmin', 'password'])
        if len(db_info) != 3:
            db_info = None

        return TESTING.render(files=files, dependencies=json.dumps(
            [name for name in sorted_mods
             if module.get_module_resource(name, 'static')
             if manifests[name]['js']]), db_info=json.dumps(db_info))
Пример #6
0
    def index(self, req, mod=None, **kwargs):
        ms = module.get_modules()
        manifests = dict((name, desc)
                         for name, desc in zip(ms, map(self.load_manifest, ms))
                         if desc  # remove not-actually-openerp-modules
                         )

        if not mod:
            return NOMODULE_TEMPLATE.render(
                modules=((manifest['name'], name)
                         for name, manifest in manifests.iteritems() if any(
                             testfile.endswith('.js')
                             for testfile in manifest['test'])))
        sorted_mods = module_topological_sort(
            dict((name, manifest.get('depends', []))
                 for name, manifest in manifests.iteritems()))
        # to_load and to_test should be zippable lists of the same length.
        # A falsy value in to_test indicate nothing to test at that index (just
        # load the corresponding part of to_load)
        to_test = sorted_mods
        if mod != '*':
            if mod not in manifests:
                return req.not_found(NOTFOUND.render(module=mod))
            idx = sorted_mods.index(mod)
            to_test = [None] * len(sorted_mods)
            to_test[idx] = mod

        tests_candicates = [
            filter(lambda path: path.endswith('.js'),
                   manifests[mod]['test'] if mod else []) for mod in to_test
        ]
        # remove trailing test-less modules
        tests = reversed(
            list(itertools.dropwhile(operator.not_,
                                     reversed(tests_candicates))))

        files = [(mod, manifests[mod]['js'], tests, manifests[mod]['qweb'])
                 for mod, tests in itertools.izip(sorted_mods, tests)]

        # if all three db_info parameters are present, send them to the page
        db_info = dict((k, v) for k, v in kwargs.iteritems()
                       if k in ['source', 'supadmin', 'password'])
        if len(db_info) != 3:
            db_info = None

        return TESTING.render(
            files=files,
            dependencies=json.dumps([
                name for name in sorted_mods
                if module.get_module_resource(name, 'static')
                if manifests[name]['js']
            ]),
            db_info=json.dumps(db_info))
Пример #7
0
    def get_module(self, module, env_root, exclude=None,
                   verbose=False, quiet=False):
        """ Download and activate module and dependencies """
        # Modules already visited are skipped
        if exclude and module in exclude:
            return True
        exclude = exclude if exclude is not None else ['base']
        exclude.append(module)
        # Modules already in the path are skipped
        if module in get_modules():
            print_if(verbose, '. %s is available from addons path.' % module)
            return True
        if module in os.listdir(env_root):
            # Modules in the env root are already active
            module_path = os.path.join(env_root, module)
            print_if(verbose, '. %s already active (at %s)' %
                     (module, module_path))

        else:
            # Modules in the local cache are available to activate
            path = os.path.join(env_root, utils.LOCAL_CACHE)
            module_path = utils.crawl_modules(path).get(module)
            if not module_path:
                # Modules not in the local cache are downloaded
                index = utils.indexed_modules(path)
                if module not in index:
                    print_if(not quiet, '! %s was not found in the index!' %
                             module)
                    return False
                utils.download_repo(path, index[module])
                module_path = utils.crawl_modules(path).get(module)
                if not module_path:
                    print('! ERROR: %s not found on the repo!' % module)
                    return False

        # Symlink module into current environment
        if module not in os.listdir(env_root):
            target_path = os.path.join(env_root, module)
            os.symlink(module_path, target_path)
            print_if(not quiet, '+ %s activated (from %s)' %
                     (module, module_path))

        # Get dependencies
        try:
            manifest = utils.load_manifest(module_path)
        except IOError:
            manifest = {}
        depends = manifest.get('depends', [])
        for m in depends:
            if not self.get_module(m, env_root, exclude=exclude,
                                   verbose=verbose, quiet=quiet):
                return False
        return True
Пример #8
0
 def do_find(self, env_root, text):
     path = os.path.join(env_root, utils.LOCAL_CACHE)
     print("Using %s" % os.path.realpath(path))
     print('\nModules available from addons path:')
     for k in sorted(get_modules()):
         if not text or text.lower() in k:
             print(k)
     print('\nDownloaded modules:')
     for k, v in sorted(utils.crawl_modules(path).items()):
         if not text or text.lower() in k:
             print("%s: %s" % (k, v))
     print('\nIndexed modules:')
     for k, v in sorted(utils.indexed_modules(path).items()):
         if not text or text.lower() in k:
             print("  %s: %s" % (k, v))