// Execute is invoked by Windows
358000
func (ws *windowsService) Execute(args []string, r <-chan wsvc.ChangeRequest, changes chan<- wsvc.Status) (bool, uint32) {
	const cmdsAccepted = wsvc.AcceptStop | wsvc.AcceptShutdown
	changes <- wsvc.Status{State: wsvc.StartPending}

	if err := ws.i.Start(); err != nil {
		ws.setError(err)
		return true, 1
	}

	changes <- wsvc.Status{State: wsvc.Running, Accepts: cmdsAccepted}
loop:
	for {
		c := <-r
		switch c.Cmd {
		case wsvc.Interrogate:
			changes <- c.CurrentStatus
		case wsvc.Stop, wsvc.Shutdown:
			changes <- wsvc.Status{State: wsvc.StopPending}
			err := ws.i.Stop()
			if err != nil {
				ws.setError(err)
				return true, 2
			}
			break loop
		default:
			continue loop
		}
	}

	return false, 0
}
619286
func (sq *Subquery) Execute(vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool) (*sqltypes.Result, error) {
	inner, err := sq.Subquery.Execute(vcursor, bindVars, wantfields)
	if err != nil {
		return nil, err
	}
	return sq.buildResult(inner), nil
}
1258735
func (p *ServerCmd) Execute(_ context.Context, f *flag.FlagSet, _ ...interface{}) subcommands.ExitStatus {
	c.Conf.Debug = p.debug
	c.Conf.Quiet = p.quiet
	log.SetLogger(p.logDir, c.Conf.Quiet, c.Conf.Debug, p.logJSON)

	c.Conf.DebugSQL = p.debugSQL
	c.Conf.Bind = p.bind
	c.Conf.Port = p.port
	c.Conf.DBPath = p.dbpath
	c.Conf.DBType = p.dbtype

	if !c.Conf.Validate() {
		return subcommands.ExitUsageError
	}

	driver, locked, err := db.NewDB(c.Conf.DBType, c.Conf.DBPath, c.Conf.DebugSQL)
	if err != nil {
		if locked {
			log.Errorf("Failed to Open DB. Close DB connection: %s", err)
			return subcommands.ExitFailure
		}
		log.Errorf("%s", err)
		return subcommands.ExitFailure
	}
	defer driver.CloseDB()

	var count int
	if count, err = driver.CountNvd(); err != nil {
		log.Errorf("Failed to count NVD table: %s", err)
		return subcommands.ExitFailure
	}

	if count == 0 {
		log.Infof("No Vulnerability data found. Run the below command to fetch data from NVD")
		log.Infof("")
		log.Infof(" for i in `seq 2002 $(date +\"%%Y\")`; do go-cve-dictionary fetchnvd -years $i ; done")
		log.Infof("")
		return subcommands.ExitSuccess
	}

	log.Infof("Starting HTTP Server...")
	if err = server.Start(p.logDir, driver); err != nil {
		log.Errorf("%s", err)
		return subcommands.ExitFailure
	}
	return subcommands.ExitSuccess
}
1238753
func (c *ScopeList) Execute(args []string) error {
	client, err := c.makeClient()
	if err != nil {
		return errors.Wrap(err, "could not make client")
	}
	defer shutdownMDClient(client)

	var scopes []string
	if scopes, err = c.getScopes(client); err == nil {
		return err
	}
	for _, sp := range scopes {
		fmt.Println(sp)
	}
	return nil
}
70669
func (w *ResourcesWriter) Execute(data *ResourceData) error {
	return w.ExecuteTemplate("resource", resourceT, nil, data)
}
1338069
func (pc *ConfigCmd) Execute(conf common.Config) error {
	if pc.server == nil || *pc.server == "" {
		return errors.New("no server specified")
	}
	if pc.channel == nil || *pc.channel == "" {
		return errors.New("no channel specified")
	}

	server := *pc.server
	channel := *pc.channel

	req := discovery.NewRequest().OfChannel(channel).AddConfigQuery()
	res, err := pc.stub.Send(server, conf, req)
	if err != nil {
		return err
	}
	return pc.parser.ParseResponse(channel, res)
}
740082
func (command *ServerCommand) Execute() error {
	var apiDocsDir string

	log.Infof("Generating a %v server", command.Language)

	if !command.NoAPIDocs {
		apiDocsDir = "apidocs"
	}

	cs := codegen.Server{
		RAMLFile:       command.RamlFile,
		Kind:           command.Kind,
		Dir:            command.Dir,
		PackageName:    command.PackageName,
		Lang:           command.Language,
		APIDocsDir:     apiDocsDir,
		RootImportPath: command.ImportPath,
		WithMain:       !command.NoMainGeneration,
		LibRootURLs:    strings.Split(command.LibRootURLs, ","),
	}
	return cs.Generate()
}
1198552
func (j *JSONPath) Execute(wr io.Writer, data interface{}) error {
	fullResults, err := j.FindResults(data)
	if err != nil {
		return err
	}
	for ix := range fullResults {
		if err := j.PrintResults(wr, fullResults[ix]); err != nil {
			return err
		}
	}
	return nil
}
1299435
func (c *controlBuffer) execute(f func(it interface{}) bool, it interface{}) (bool, error) {
	c.mu.Lock()
	if c.err != nil {
		c.mu.Unlock()
		return false, c.err
	}
	if !f(it) { // f wasn't successful
		c.mu.Unlock()
		return false, nil
	}
	c.mu.Unlock()
	return true, nil
}
1002921
func (e *Env) Execute(src string) (interface{}, error) {
	return e.ExecuteContext(context.Background(), src)
}
1362873
func (upd *Update) Execute(vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool) (*sqltypes.Result, error) {
	if upd.QueryTimeout != 0 {
		cancel := vcursor.SetContextTimeout(time.Duration(upd.QueryTimeout) * time.Millisecond)
		defer cancel()
	}

	switch upd.Opcode {
	case UpdateUnsharded:
		return upd.execUpdateUnsharded(vcursor, bindVars)
	case UpdateEqual:
		return upd.execUpdateEqual(vcursor, bindVars)
	case UpdateScatter:
		return upd.execUpdateByDestination(vcursor, bindVars, key.DestinationAllShards{})
	case UpdateByDestination:
		return upd.execUpdateByDestination(vcursor, bindVars, upd.TargetDestination)
	default:
		// Unreachable.
		return nil, fmt.Errorf("unsupported opcode: %v", upd)
	}
}
410317
func (rc *runCommands) Execute(state State) (*State, error) {
	logger.Tracef("run commands: %s", rc)
	if err := rc.callbacks.SetExecutingStatus("running commands"); err != nil {
		return nil, errors.Trace(err)
	}

	response, err := rc.runner.RunCommands(rc.args.Commands)
	switch err {
	case context.ErrRequeueAndReboot:
		logger.Warningf("cannot requeue external commands")
		fallthrough
	case context.ErrReboot:
		rc.sendResponse(response, nil)
		err = ErrNeedsReboot
	default:
		rc.sendResponse(response, err)
	}
	return nil, err
}
151444
func (t *Template) Execute(w io.Writer, variables VarMap, data interface{}) error {
	return t.ExecuteI18N(nil, w, variables, data)
}
558957
func (itc *internalTabletConn) Execute(ctx context.Context, target *querypb.Target, query string, bindVars map[string]*querypb.BindVariable, transactionID int64, options *querypb.ExecuteOptions) (*sqltypes.Result, error) {
	bindVars = sqltypes.CopyBindVariables(bindVars)
	reply, err := itc.tablet.qsc.QueryService().Execute(ctx, target, query, bindVars, transactionID, options)
	if err != nil {
		return nil, tabletconn.ErrorFromGRPC(vterrors.ToGRPC(err))
	}
	return reply, nil
}
602901
func (e *ClientExecutor) Execute(b *imagebuilder.Builder, node *parser.Node) error {
	for i, child := range node.Children {
		step := b.Step()
		if err := step.Resolve(child); err != nil {
			return err
		}
		glog.V(4).Infof("step: %s", step.Original)
		if e.LogFn != nil {
			// original may have unescaped %, so perform fmt escaping
			e.LogFn(strings.Replace(step.Original, "%", "%%", -1))
		}
		noRunsRemaining := !b.RequiresStart(&parser.Node{Children: node.Children[i+1:]})

		if err := b.Run(step, e, noRunsRemaining); err != nil {
			return err
		}
	}

	return nil
}
222138
func (hook *Hook) Execute() (result *HookResult) {
	result = &HookResult{}

	// Find the hook.
	cmd, status, err := hook.findHook()
	if err != nil {
		result.ExitStatus = status
		result.Stderr = err.Error() + "\n"
		return result
	}

	// Run it.
	var stdout, stderr bytes.Buffer
	cmd.Stdout = &stdout
	cmd.Stderr = &stderr
	err = cmd.Run()
	result.Stdout = stdout.String()
	result.Stderr = stderr.String()
	if err == nil {
		result.ExitStatus = HOOK_SUCCESS
	} else {
		if cmd.ProcessState != nil && cmd.ProcessState.Sys() != nil {
			result.ExitStatus = cmd.ProcessState.Sys().(syscall.WaitStatus).ExitStatus()
		} else {
			result.ExitStatus = HOOK_CANNOT_GET_EXIT_STATUS
		}
		result.Stderr += "ERROR: " + err.Error() + "\n"
	}

	log.Infof("hook: result is %v", result.String())

	return result
}
732899
func (ps *PulloutSubquery) Execute(vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool) (*sqltypes.Result, error) {
	combinedVars, err := ps.execSubquery(vcursor, bindVars)
	if err != nil {
		return nil, err
	}
	return ps.Underlying.Execute(vcursor, combinedVars, wantfields)
}