execute the pre script if it is defined
540210
def pre_script(self):
        
        if self['pre_script'] is None:
            return
        LOGGER.info("Executing pre script: {}".format(self['pre_script']))
        cmd = self['pre_script']
        execute_command(self.abs_input_dir(), cmd, self.env_dictionary())
        LOGGER.info("Pre Script completed")
1103477
def run_activate_this(self):
        """"""
        if self.is_venv:
            activate_this = os.path.join(self.scripts_dir, "activate_this.py")
            if not os.path.isfile(activate_this):
                raise OSError("No such file: {0!s}".format(activate_this))
            with open(activate_this, "r") as f:
                code = compile(f.read(), activate_this, "exec")
                exec(code, dict(__file__=activate_this))
808395
def execute_code(self, lines, current_client=True, clear_variables=False):
        """"""
        sw = self.get_current_shellwidget()
        if sw is not None:
            if sw._reading:
                pass
            else:
                if not current_client:
                    # Clear console and reset namespace for
                    # dedicated clients
                    # See issue 5748
                    try:
                        sw.sig_prompt_ready.disconnect()
                    except TypeError:
                        pass
                    sw.reset_namespace(warning=False)
                elif current_client and clear_variables:
                    sw.reset_namespace(warning=False)
                # Needed to handle an error when kernel_client is none
                # See issue 6308
                try:
                    sw.execute(to_text_string(lines))
                except AttributeError:
                    pass
            self.activateWindow()
            self.get_current_client().get_control().setFocus()
555204
def _script_reload(script, input, output):
    """"""
    input = [Path(entry).expand().abspath() for entry in input]
    output = Path(output).expand().abspath()
    cmd = 'python3 {0} {1} {2}'.format(script, ' '.join(input), output)
    event_handler = RunScriptChangeHandler(cmd)
    event_handler.run()  # run always once
    observer = Observer()
    path = script.dirname().expand().abspath()
    click.secho('watch: {0}'.format(path), fg='blue')
    observer.schedule(event_handler, path, recursive=True)
    for entry in input:
        entry = entry.dirname().expand().abspath()
        click.secho('watch: {0}'.format(entry), fg='blue')
        observer.schedule(event_handler, entry, recursive=True)
    path = Path(__file__).parent / 'qface'
    click.secho('watch: {0}'.format(path), fg='blue')
    observer.schedule(event_handler, path, recursive=True)
    observer.start()

    try:
        while True:
            time.sleep(1)
    except KeyboardInterrupt:
        observer.stop()
    observer.join()
510580
public function preRun()
    {
        
    	$this->options = array('verbose' => false,
        					   'action' => null,
    						   'extension' => null);
        
        $this->options = array_merge($this->options, $this->parameters);
        
        if ($this->options['verbose'] == true) {
        	$this->verbose = true;
        }
        
        // The 'action' parameter is always required.
        if ($this->options['action'] == null) {
        	$this->err("Please enter the 'action' parameter.", true);
        } else {
        	$this->options['action'] = strtolower($this->options['action']);
        	if (!in_array($this->options['action'], array_keys($this->getAllowedActions()))) {
        		$this->err("'" . $this->options['action'] . "' is not a valid action.", true);
        	} else {
        		// The 'action' parameter is ok.
        		// Let's check additional inputs depending on the value of the 'action' parameter.
        		$this->checkInput();	
        	}
        }
        
    }
684119
def handle(self, *args, **options):
        """"""

        # Already running, so quit
        if os.path.exists(self.lock_file):
            self.log(("This script is already running. "
                      "(If your are sure it's not please "
                      "delete the lock file in {}')").format(self.lock_file))
            sys.exit(0)

        if not os.path.exists(os.path.dirname(self.lock_file)):
            os.mkdir(os.path.dirname(self.lock_file), 0755)

        archives_path = options.get('archives_path')
        self.log('Using archives_path `%s`' % settings.SUPER_ARCHIVES_PATH)

        if not os.path.exists(archives_path):
            msg = 'archives_path ({}) does not exist'.format(archives_path)
            raise CommandError(msg)
        run_lock = file(self.lock_file, 'w')
        run_lock.close()

        try:
            self.import_emails(
                archives_path,
                options.get('all'),
                options.get('exclude_lists'),
            )
        except Exception as e:
            logging.exception(e)
            raise
        finally:
            os.remove(self.lock_file)

        for mlist in MailingList.objects.all():
            mlist.update_privacy()
            mlist.save()
1211265
def pre_run(self, outline=False, *args, **kwargs):
        """"""
        pre_destroy = self.context.config.pre_destroy
        if not outline and pre_destroy:
            handle_hooks(
                stage="pre_destroy",
                hooks=pre_destroy,
                provider=self.provider,
                context=self.context)
540130
def execute_javascript(self, *args, **kwargs):
		'''
		
		'''

		ret = self.__exec_js(*args, **kwargs)
		return ret
1366074
function injectBefore(replServer, method, beforeFn) {
  var _orig = replServer[method];
  replServer[method] = function() {
    var args = Array.prototype.slice.call(arguments);
    var callback = args.pop();
    beforeFn.apply(null, args.concat(function(err, res) {
      if (err || res) {
        callback(err, res);
      } else {
        _orig.apply(replServer, args.concat(callback));
      }
    }));
  };
  return replServer;
}
747514
def pre(self, *args):
            
            if len(args):
                self.str_pre = args[0]
            else:
                return self.str_pre
387066
def run_triggers(step, pre_post, args=(), **kwargs):
    '''
    
    '''
    if not isinstance(step, str) or not isinstance(pre_post, str):
        return
    if trace_triggers:
        msg = 'Trigger for %s: %s' % (step, pre_post)
        sys.stderr.write(msg.center(80, '-') + '\n')
    if args is None:
        args = ()
    if not isinstance(args, tuple):
        return
    cfg = __get_config()
    if cfg is None:
        return
    if step not in cfg:
        return
    if not isinstance(cfg[step], dict):
        return
    if pre_post not in cfg[step]:
        return
    d = cfg[step][pre_post]
    l = d.get('cmdlist', [])
    if not l:
        return

    show_output = d.get('show_output', None)
    show_err = d.get('show_err', None)
    ignore_err = d.get('ignore_err', None)

    run_in_order(
        l,
        show_output=show_output,
        show_err=show_err,
        ignore_err=ignore_err,
        args=args,
        pre_post=pre_post,
        kwargs=kwargs
    )
158102
def eval(self, script, keys=[], args=[]):
        """"""
        return self.execute(b'EVAL', script, len(keys), *(keys + args))
1171075
function run(script, args) {

  var res, result, name;
  try {
    res = this.exec.apply(this, [script].concat(args));
    result = res.result;
    //console.dir(result);
    //console.dir(result instanceof Error);
    if(typeof result === 'function') return;
    if(result === undefined) {
      throw new Error('undefined return value is not allowed');
    }else if(
      result !== null
      && !(result instanceof String)
      && !(result instanceof Error)
      && typeof result === 'object'
      && !Array.isArray(result)) {
      throw new Error('object return value is not allowed');
    }
  }catch(e) {
    name = res && res.name ? res.name : 'user_script';
    result = new StoreError(
      null, 'error running script (call to %s): %s', name, e.message);
  }

  if(typeof result === 'boolean') {
    result = Number(result);
  }

  // TODO: check the return value is not an object!!!
  //
  var err = (result instanceof Error);
  if(err) result = result.message;

  process.send({err: err, data: result, str: (result instanceof String)});
}
708862
def write_pre_script(self,fh):
    
    if self.__pre_script:
      fh.write( 'SCRIPT PRE ' + str(self) + ' ' + self.__pre_script + ' ' +
        ' '.join(self.__pre_script_args) + '\n' )
664507
def safe_execute_script(driver, script):
    
    try:
        driver.execute_script(script)
    except Exception:
        # The likely reason this fails is because: "jQuery is not defined"
        activate_jquery(driver)  # It's a good thing we can define it here
        driver.execute_script(script)
985968
function runScript(script, context) {
    if (typeof script.useModuleLoader == 'undefined') {
        // if it is not explicitly defined whether we should use modeule loader or not
        // we assume we should use module loader for .js files
        script.useModuleLoader = path.extname(script.path).toLowerCase() == '.js';
    }

    var source;
    var relativePath;

    if (script.plugin) {
        source = 'plugin ' + script.plugin.id;
        relativePath = path.join('plugins', script.plugin.id, script.path);
    } else if (script.useModuleLoader) {
        source = 'config.xml';
        relativePath = path.normalize(script.path);
    } else {
        source = 'hooks directory';
        relativePath = path.join('hooks', context.hook, script.path);
    }

    events.emit('verbose', 'Executing script found in ' + source + ' for hook "' + context.hook + '": ' + relativePath);

    if(script.useModuleLoader) {
        return runScriptViaModuleLoader(script, context);
    } else {
        return runScriptViaChildProcessSpawn(script, context);
    }
}
817559
function execute() {

    if (dryRun) {
        console.log(`In ${destDir}, this script would...`);
    } else {
        console.log(`Generating API documentation using TypeDoc...`);
    }

    const packages = path.resolve(rootDir, srcDir);

    glob(packages, {realpath:true}, function(error, srcFiles) {
       
        srcFiles.forEach((srcPath) => {    
            
            var valid = true;

            var packageName = srcPath
                .split(path.sep)
                .pop();

            excludedPackages.forEach((excludedPackageName) => {
                if (packageName === excludedPackageName) {
                    console.log(chalk.yellow(`...skip generating TypeDoc API files for ${packageName}`));
                    valid = false;
                }
            });

            if(valid) {
                dryRun ? console.log(`...generate TypeDoc API files for ${packageName}`) : createAPIFiles(packageName, srcPath);
            }

        });

    });
}