Deploys a module
508245
private void doDeployModule(final Message<JsonObject> message) {
    String moduleName = message.body().getString("module");
    if (moduleName == null) {
      message.reply(new JsonObject().putString("status", "error").putString("message", "No module name specified."));
      return;
    }

    JsonObject config = message.body().getObject("config");
    if (config == null) {
      config = new JsonObject();
    }
    int instances = message.body().getInteger("instances", 1);
    platform.deployModule(moduleName, config, instances, createDeploymentHandler(message));
  }
585585
function runModule(module, str, replacements) {
    var pattern = module.pattern,
        replace = module.replace,
        match;

    // Reset the pattern so we can re-use it
    pattern.lastIndex = 0;

    while ((match = pattern.exec(str)) !== null) {
        replacements[match.index] = {
            oldStr: match[0],
            newStr: typeof replace === "function"? replace(match) : replace
        };
        if (pattern.global === false) {
            // if the search isn't global we need to break manually
            // because pattern.exec() will always return something
            break;
        }
    }
}
215459
function (name) {
    // initialize module instance with default module configuration
    _.merge(this, defaultModuleConfig)
    // set app name
    this.name = name
    // set absolute path of base directory for module
    this.base = getBase()
    // store reference to global app
    this.immutableApp = immutableApp
}
17207
public function publish($module)
    {
        with(new MigrationPublisher($module))
            ->setRepository($this->laravel['modules'])
            ->setConsole($this)
            ->publish();
    }
212907
def attach(self, module_factory, name=None, **kwargs):
        """"""
        if self.anybar: self.anybar.change("yellow")

        fac = module_factory

        if name is None:
            name = fac.__name__

        log.info("Attaching module '{0}'".format(name))

        if (inspect.isclass(fac) and issubclass(fac, Module)) or \
                name == 'GenericPump':
            log.debug("Attaching as regular module")
            if name in self.module_configuration:
                log.debug(
                    "Applying pipeline configuration file for module '%s'" %
                    name
                )
                for key, value in self.module_configuration[name].items():
                    if key in kwargs:
                        self.log.info(
                            "Overwriting parameter '%s' in module '%s' from "
                            "the pipeline configuration file." % (key, name)
                        )
                    kwargs[key] = value
            module = fac(name=name, **kwargs)
            if hasattr(module, "provided_services"):
                for service_name, obj in module.provided_services.items():
                    self.services.register(service_name, obj)
            if hasattr(module, "required_services"):
                updated_required_services = {}
                updated_required_services.update(self.required_services)
                updated_required_services.update(module.required_services)
                self.required_services = updated_required_services
            module.services = self.services
            module.pipeline = self
        else:
            if isinstance(fac, types.FunctionType):
                log.debug("Attaching as function module")
            else:
                log.critical(
                    "Don't know how to attach module '{0}'!\n"
                    "But I'll do my best".format(name)
                )
            module = fac
            module.name = name
            module.timeit = self.timeit

        # Special parameters
        if 'only_if' in kwargs:
            required_keys = kwargs['only_if']
            if isinstance(required_keys, basestring):
                required_keys = [required_keys]
            module.only_if = set(required_keys)
        else:
            module.only_if = set()

        if 'blob_keys' in kwargs:
            module.blob_keys = kwargs['blob_keys']
        else:
            module.blob_keys = None

        if 'every' in kwargs:
            module.every = kwargs['every']
        else:
            module.every = 1

        self._timeit[module] = {
            'process': deque(maxlen=STAT_LIMIT),
            'process_cpu': deque(maxlen=STAT_LIMIT),
            'finish': 0,
            'finish_cpu': 0
        }

        if hasattr(module, 'get_detector'):    # Calibration-like module
            self.log.deprecation(
                "Calibration-like modules will not be supported in future "
                "versions of KM3Pipe. Please use services instead.\n"
                "If you are attaching the `calib.Calibration` as a module, "
                "switch to `calib.CalibrationService` and use the "
                "`self.services['calibrate']()` method in your modules "
                "to apply calibration.\n\n"
                "This means:\n\n"
                "    pipe.attach(kp.calib.CalibrationService, ...)\n\n"
                "And inside the attached modules, you can apply the "
                "calibration with e.g.:\n\n"
                "    cal_hits = self.services['calibrate'](blob['Hits'])\n"
            )
            self.calibration = module
            if module._should_apply:
                self.modules.append(module)
        else:    # normal module
            module.calibration = self.calibration
            self.modules.append(module)
312433
def create_module(module, target):
    
    module_x = module.split('.')
    cur_path = ''
    for path in module_x:
        cur_path = os.path.join(cur_path, path)
        if not os.path.isdir(os.path.join(target, cur_path)):
            os.mkdir(os.path.join(target, cur_path))
        if not os.path.exists(os.path.join(target, cur_path, '__init__.py')):
            touch(os.path.join(target, cur_path, '__init__.py'))
    return cur_path
108271
public function runModule()
    {
        if ($this->status->run === true) {
            return;
        }
        
        $runnerFile   = $this->obtainRunnerFile();
        $initFunction = function() use ($runnerFile) {
            if (empty($runnerFile)) {
                return;
            }
            
            require(realpath($runnerFile));
        };

        $this->status->run = true;
        $initFunction();
    }
1329196
function preloadRequire (module) {
  if (loadedModules.has(module)) {
    return loadedModules.get(module)
  }
  throw new Error(`module not found: ${module}`)
}
987740
def setup(basepath=DEFAULT_BASEPATH):
    """"""

    module_version = os.environ.get('MODULE_VERSION', DEFAULT_VERSION)
    moduleshome = os.path.join(basepath, module_version)

    # Abort if MODULESHOME does not exist
    if not os.path.isdir(moduleshome):
        print('payu: warning: MODULESHOME does not exist; disabling '
              'environment modules.')
        os.environ['MODULESHOME'] = ''
        return

    os.environ['MODULE_VERSION'] = module_version
    os.environ['MODULE_VERSION_STACK'] = module_version
    os.environ['MODULESHOME'] = moduleshome

    if 'MODULEPATH' not in os.environ:
        module_initpath = os.path.join(moduleshome, 'init', '.modulespath')
        with open(module_initpath) as initpaths:
            modpaths = [
                line.partition('#')[0].strip()
                for line in initpaths.readlines() if not line.startswith('#')
            ]

        os.environ['MODULEPATH'] = ':'.join(modpaths)

    os.environ['LOADEDMODULES'] = os.environ.get('LOADEDMODULES', '')

    # Environment modules with certain characters will cause corruption
    # when MPI jobs get launched on other nodes (possibly a PBS issue).
    #
    # Bash processes obscure the issue on Raijin, since it occurs in an
    # environment module function, and bash moves those to the end of
    # the environment variable list.
    #
    # Raijin's mpirun wrapper is a bash script, and therefore "fixes" by doing
    # the shuffle and limiting the damage to other bash functions, but some
    # wrappers (e.g. OpenMPI 2.1.x) may not be present.  So we manually patch
    # the problematic variable here.  But a more general solution would be nice
    # someday.

    if 'BASH_FUNC_module()' in os.environ:
        bash_func_module = os.environ['BASH_FUNC_module()']
        os.environ['BASH_FUNC_module()'] = bash_func_module.replace('\n', ';')
1170895
function(exists, cb) {
          if(!exists) {
            fs.mkdir(rootDir + '/node_modules', function(error) {
              cb(error);
            });
          } else {
            cb(null);
          }
        }
221246
public function fire()
    {
        $name = studly_case(substr($this->argument('name'), strpos($this->argument('name'), '=') + 1));

        $modulePath = $this->modulesPath.'/'.$name;

        if (empty($name))
        {
            $this->error('Please write correct module name');
            exit;
        }

        $this->app['events']->fire('modules.install.'.$name, null);
        $this->error("This command just call event, do not any more.");
        $this->info("Install event for $name module called.");
    }
1061885
def deploy():
    """"""
    _require_root()

    if not confirm("This will apply any available migrations to the database. Has the database been backed up?"):
        abort("Aborted.")
    if not confirm("Are you sure you want to deploy?"):
        abort("Aborted.")

    with lcd(PRODUCTION_DOCUMENT_ROOT):
        with shell_env(PRODUCTION="TRUE"):
            local("git pull")
            with open("requirements.txt", "r") as req_file:
                requirements = req_file.read().strip().split()
                try:
                    pkg_resources.require(requirements)
                except pkg_resources.DistributionNotFound:
                    local("pip install -r requirements.txt")
                except Exception:
                    traceback.format_exc()
                    local("pip install -r requirements.txt")
                else:
                    puts("Python requirements already satisfied.")
            with prefix("source /usr/local/virtualenvs/ion/bin/activate"):
                local("./manage.py collectstatic --noinput", shell="/bin/bash")
                local("./manage.py migrate", shell="/bin/bash")
            restart_production_gunicorn(skip=True)

    puts("Deploy complete.")
1314476
def need_ext():
    '''
    
    '''
    sys.stdout.write("{0}\next_mods\n".format(OPTIONS.delimiter))
    sys.exit(EX_MOD_DEPLOY)
1336532
def deploy(self, package=None):
        
        if package is None:
            package = deployment_package.default()
        package.deploy()
        if self.proper_name in installed_functions():
            self.update(package)
        else:
            self.install(package)
177913
function( name, testEnvironment ) {
            config.currentModule = name;
            config.currentModuleTestEnvironment = testEnvironment;
            config.modules[ name ] = true;
        }
531227
def install_module(
    self, target=None, package_manager=None, 
    install_optional=False, production_only=False, force=False, 
    node_paths=None, frozen_lockfile=None, workunit_name=None, workunit_labels=None):
    """"""
    package_manager = package_manager or self.get_package_manager(target=target)
    command = package_manager.install_module(
      install_optional=install_optional,
      force=force,
      production_only=production_only,
      node_paths=node_paths,
      frozen_lockfile=frozen_lockfile
    )
    return self._execute_command(
      command, workunit_name=workunit_name, workunit_labels=workunit_labels)
481469
public function loadModule()
    {
        \BFW\Application::getInstance()
            ->getMonolog()
            ->getLogger()
            ->debug('Load module', ['name' => $this->name])
        ;
        
        $this->loadConfig();
        $this->obtainLoadInfos();

        $this->status->load = true;
    }