//Loads the plugins at the given path
//Returns a valid plugin or a non-nil error
499743
func Load(path string) (Plugin, error) {
	cmd := exec.Command(path)
	stdin, err := cmd.StdinPipe()
	if err != nil {
		return nil, err
	}
	stdout, err := cmd.StdoutPipe()
	if err != nil {
		return nil, err
	}

	stderr, err := cmd.StderrPipe()
	if err == nil {
		go io.Copy(os.Stderr, stderr)
	}

	go cmd.Start()

	return NewRemotePlugin(stdout, stdin)

}
510889
func (config *Config) PluginHome() string {
	if config.ENV.CFPluginHome != "" {
		return filepath.Join(config.ENV.CFPluginHome, ".cf", "plugins")
	}

	return filepath.Join(homeDirectory(), ".cf", "plugins")
}
549929
func Load(qw graph.QuadWriter, batch int, path, typ string) error {
	return DecompressAndLoad(qw, batch, path, typ, nil)
}
1330934
func loadMessages(path string) {
	messages = make(map[string]*config.Config)

	// Read in messages from the modules. Load the module messges first,
	// so that it can be override in parent application
	for _, module := range Modules {
		i18nLog.Debug("Importing messages from module:", "importpath", module.ImportPath)
		if err := Walk(filepath.Join(module.Path, messageFilesDirectory), loadMessageFile); err != nil &&
			!os.IsNotExist(err) {
			i18nLog.Error("Error reading messages files from module:", "error", err)
		}
	}

	if err := Walk(path, loadMessageFile); err != nil && !os.IsNotExist(err) {
		i18nLog.Error("Error reading messages files:", "error", err)
	}
}
1166995
func (ed *EtcdDriver) Load(configStorePath string) int {
	var err error
	ed.path = configStorePath
	ed.response, err = ed.client.Get(configStorePath, true, true)
	if err != nil {
		if etcderr, ok := err.(*etcd.EtcdError); ok {
			return etcderr.ErrorCode
		} else {
			panic(fmt.Sprintf("Error retrieving data from etcd:  %s", err.Error()))
		}
	}
	return gostrufig.CONFIGFOUND
}
167044
func (c *Config) Load(path string) error {
	md, err := toml.DecodeFile(path, c)
	if err != nil {
		return err
	}
	if len(md.Undecoded()) > 0 {
		return errors.New("Unknown config keys in " + path)
	}

	if len(c.Incoming.AllowFrom) > 0 {
		subnets := make([]*net.IPNet, 0, len(c.Incoming.AllowFrom))
		for _, s := range c.Incoming.AllowFrom {
			if strings.IndexByte(s, '/') == -1 {
				s = s + "/32"
			}
			_, n, err := net.ParseCIDR(s)
			if err != nil {
				return errors.New("Invalid network or IP address: " + s)
			}
			subnets = append(subnets, n)
		}
		c.Incoming.allowSubnets = subnets
	}

	c.Outgoing.AllowSites = toLowerStrings(c.Outgoing.AllowSites)
	c.Outgoing.DenySites = toLowerStrings(c.Outgoing.DenySites)

	return nil
}
153608
func Load(file string) (*List, error) {
	rawdat := make(map[string]string)
	input, err := ioutil.ReadFile(file)
	if err != nil {
		return nil, err
	}

	err = yaml.Unmarshal(input, &rawdat)
	if err != nil {
		return nil, fmt.Errorf("could not parse yaml: %s", err)
	}

	list := &List{Plugins: []*Plugin{}}
	for k, v := range rawdat {
		list.Plugins = append(list.Plugins, &Plugin{Name: k, Repo: v})
	}

	return list, err
}
1354885
func (f *Folder) Load() error {
	if err := f.comp.loadPack(f.uuid, "-trees"); err != nil {
		return err
	}
	if err := f.comp.loadPack(f.uuid, "-blobs"); err != nil {
		return err
	}
	return nil
}
841121
func (p *plugin) Load() {
	dir, file := filepath.Split(p.Path())
	p.name = file
	name := filepath.Base(dir) + "." + file[:len(file)-3]
	s, err := py.NewUnicode(name)
	if err != nil {
		log.Warn(err)
		return
	}
	defer s.Decref()

	log.Debug("Loading plugin %s", name)
	l := py.NewLock()
	defer l.Unlock()
	if r, err := module.Base().CallMethodObjArgs("reload_plugin", s); err != nil {
		log.Warn(err)
		return
	} else if r != nil {
		r.Decref()
	}
}
1269118
func Load(path string, spec *vpython.Spec) error {
	content, err := ioutil.ReadFile(path)
	if err != nil {
		return errors.Annotate(err, "failed to load file from: %s", path).Err()
	}

	return Parse(string(content), spec)
}
497993
func (ns *Nstat) loadPaths() {
	if ns.ProcNetNetstat == "" {
		ns.ProcNetNetstat = proc(ENV_NETSTAT, NET_NETSTAT)
	}
	if ns.ProcNetSNMP == "" {
		ns.ProcNetSNMP = proc(ENV_SNMP, NET_SNMP)
	}
	if ns.ProcNetSNMP6 == "" {
		ns.ProcNetSNMP6 = proc(ENV_SNMP6, NET_SNMP6)
	}
}
590058
func PluginLoader(opts map[string]string) (map[string]interface{}, error) {
	conf := map[string]interface{}{}
	if v, err := strconv.ParseBool(opts["driver.rkt.volumes.enabled"]); err == nil {
		conf["volumes_enabled"] = v
	}
	return conf, nil
}
1317081
func (p *Project) LoadFunctions(patterns ...string) error {
	dir := filepath.Join(p.Path, functionsDir)
	p.Log.Debugf("loading functions in %s", dir)

	names, err := p.FunctionDirNames()
	if err != nil {
		return err
	}

	for _, name := range names {
		match, err := matches(name, patterns)
		if err != nil {
			return errors.Wrapf(err, "matching %s", name)
		}

		if !match {
			continue
		}

		fn, err := p.LoadFunction(name)
		if err != nil {
			return errors.Wrapf(err, "loading %s", name)
		}

		p.Functions = append(p.Functions, fn)
	}

	if len(p.Functions) == 0 {
		return errors.New("no function loaded")
	}

	return nil
}
615220
func LoadPlugins(ctx context.Context, config *srvconfig.Config) ([]*plugin.Registration, error) {
	// load all plugins into containerd
	path := config.PluginDir
	if path == "" {
		path = filepath.Join(config.Root, "plugins")
	}
	if err := plugin.Load(path); err != nil {
		return nil, err
	}
	// load additional plugins that don't automatically register themselves
	plugin.Register(&plugin.Registration{
		Type: plugin.ContentPlugin,
		ID:   "content",
		InitFn: func(ic *plugin.InitContext) (interface{}, error) {
			ic.Meta.Exports["root"] = ic.Root
			return local.NewStore(ic.Root)
		},
	})
	plugin.Register(&plugin.Registration{
		Type: plugin.MetadataPlugin,
		ID:   "bolt",
		Requires: []plugin.Type{
			plugin.ContentPlugin,
			plugin.SnapshotPlugin,
		},
		Config: &srvconfig.BoltConfig{
			ContentSharingPolicy: srvconfig.SharingPolicyShared,
		},
		InitFn: func(ic *plugin.InitContext) (interface{}, error) {
			if err := os.MkdirAll(ic.Root, 0711); err != nil {
				return nil, err
			}
			cs, err := ic.Get(plugin.ContentPlugin)
			if err != nil {
				return nil, err
			}

			snapshottersRaw, err := ic.GetByType(plugin.SnapshotPlugin)
			if err != nil {
				return nil, err
			}

			snapshotters := make(map[string]snapshots.Snapshotter)
			for name, sn := range snapshottersRaw {
				sn, err := sn.Instance()
				if err != nil {
					if !plugin.IsSkipPlugin(err) {
						log.G(ic.Context).WithError(err).
							Warnf("could not use snapshotter %v in metadata plugin", name)
					}
					continue
				}
				snapshotters[name] = sn.(snapshots.Snapshotter)
			}

			shared := true
			ic.Meta.Exports["policy"] = srvconfig.SharingPolicyShared
			if cfg, ok := ic.Config.(*srvconfig.BoltConfig); ok {
				if cfg.ContentSharingPolicy != "" {
					if err := cfg.Validate(); err != nil {
						return nil, err
					}
					if cfg.ContentSharingPolicy == srvconfig.SharingPolicyIsolated {
						ic.Meta.Exports["policy"] = srvconfig.SharingPolicyIsolated
						shared = false
					}

					log.L.WithField("policy", cfg.ContentSharingPolicy).Info("metadata content store policy set")
				}
			}

			path := filepath.Join(ic.Root, "meta.db")
			ic.Meta.Exports["path"] = path

			db, err := bolt.Open(path, 0644, nil)
			if err != nil {
				return nil, err
			}

			var dbopts []metadata.DBOpt
			if !shared {
				dbopts = append(dbopts, metadata.WithPolicyIsolated)
			}
			mdb := metadata.NewDB(db, cs.(content.Store), snapshotters, dbopts...)
			if err := mdb.Init(ic.Context); err != nil {
				return nil, err
			}
			return mdb, nil
		},
	})

	clients := &proxyClients{}
	for name, pp := range config.ProxyPlugins {
		var (
			t plugin.Type
			f func(*grpc.ClientConn) interface{}

			address = pp.Address
		)

		switch pp.Type {
		case string(plugin.SnapshotPlugin), "snapshot":
			t = plugin.SnapshotPlugin
			ssname := name
			f = func(conn *grpc.ClientConn) interface{} {
				return ssproxy.NewSnapshotter(ssapi.NewSnapshotsClient(conn), ssname)
			}

		case string(plugin.ContentPlugin), "content":
			t = plugin.ContentPlugin
			f = func(conn *grpc.ClientConn) interface{} {
				return csproxy.NewContentStore(csapi.NewContentClient(conn))
			}
		default:
			log.G(ctx).WithField("type", pp.Type).Warn("unknown proxy plugin type")
		}

		plugin.Register(&plugin.Registration{
			Type: t,
			ID:   name,
			InitFn: func(ic *plugin.InitContext) (interface{}, error) {
				ic.Meta.Exports["address"] = address
				conn, err := clients.getClient(address)
				if err != nil {
					return nil, err
				}
				return f(conn), nil
			},
		})

	}

	// return the ordered graph for plugins
	return plugin.Graph(config.DisabledPlugins), nil
}
226008
func (model Model) LoadModel(path string) {
	cfg, err := config.NewConfig(path)
	if err != nil {
		panic(err)
	}

	loadSection(model, cfg, "r")
	loadSection(model, cfg, "p")
	loadSection(model, cfg, "e")
	loadSection(model, cfg, "m")

	loadSection(model, cfg, "g")
}
494690
func (w *Wireless) loadPath() {
	if w.HostProc == "" {
		w.HostProc = proc(envProc, defaultHostProc)
	}
}
5674
func LoadPluginsGo() error {
	p := filepath.Join("plugins.go")
	okVal := fmt.Sprintf("open %s: no such file or directory", p)
	contents, err := ioutil.ReadFile(p)
	if err != nil && err.Error() != okVal {
		return err
	}
	var val []byte
	var foundStart bool
	var nestLvl int
	for _, b := range contents {
		switch b {
		case '{':
			nestLvl++
			if nestLvl == 1 {
				foundStart = true
			}
		case '}':
			nestLvl--
			if nestLvl == 0 {
				val = append(val, b)
				val = append(val, []byte(",")...)
				foundStart = false
			}
		}
		if !foundStart {
			continue
		}
		val = append(val, b)
	}
	if len(val) == 0 {
		return nil
	}
	val = append([]byte("["), val...)
	val = append(val[:len(val)-1], []byte("]")...)
	return json.Unmarshal(val, &PluginsGo)
}