GetActiveGlobalProfile() public method

public GetActiveGlobalProfile ( ) : string
return string
示例#1
0
 public ReactiveScript(string file, string keyPath, Action<string> dispatch)
 {
     _file = file;
     _keyPath = keyPath;
     _dispatch = dispatch;
     var profiles = new ProfileLocator(_keyPath);
     _globalProfileName = profiles.GetActiveGlobalProfile();
     _localProfileName = profiles.GetActiveLocalProfile();
     getEvents();
 }
示例#2
0
文件: Script.cs 项目: acken/OpenIDE
 public Script(string token, string workingDirectory, string file)
 {
     _file = file;
     _token = token;
     Name = Path.GetFileNameWithoutExtension(file);
     Description = "";
     _workingDirectory = workingDirectory;
     var profiles = new ProfileLocator(_token);
     _globalProfileName = profiles.GetActiveGlobalProfile();
     _localProfileName = profiles.GetActiveLocalProfile();
 }
示例#3
0
 public ReactiveScriptReader(string path, Func<PluginLocator> locator, Action<string> dispatch)
 {
     _keyPath = path;
     _dispatch = dispatch;
     var profiles = new ProfileLocator(_keyPath);
     _localScriptsPathDefault = getPath(profiles.GetLocalProfilePath("default"));
     _localScriptsPath = getPath(profiles.GetLocalProfilePath(profiles.GetActiveLocalProfile()));
     _globalScriptsPathDefault = getPath(profiles.GetGlobalProfilePath("default"));
     _globalScriptsPath = getPath(profiles.GetGlobalProfilePath(profiles.GetActiveGlobalProfile()));
     _pluginLocator = locator;
 }
        public void Start(
			string path,
			ICacheBuilder cache,
			ICrawlResult crawlReader,
			PluginLocator pluginLocator,
			EventEndpoint eventDispatcher,
			string[] ignoreDirectories)
        {
            _cache = cache;
            _crawlReader = crawlReader;
            _eventDispatcher = eventDispatcher;
            Logger.Write("Setting up file trackers");
            Logger.Write("Setting up token file trackers");
            _tracker = new FileChangeTracker((x) => {
                    if (x.Path.StartsWith(Path.Combine(path, ".OpenIDE")))
                        return;
                    _eventDispatcher.Send(
                        "codemodel raw-filesystem-change-" +
                        x.Type.ToString().ToLower() +
                        " \"" + x.Path + "\"");
                });
            Logger.Write("Setting up local file trackers");
            _localTracker = new FileChangeTracker((x) => {
                    _eventDispatcher.Send(
                        "codemodel raw-filesystem-change-" +
                        x.Type.ToString().ToLower() +
                        " \"" + x.Path + "\"");
                });
            Logger.Write("Setting up global file trackers");
            _globalTracker = new FileChangeTracker((x) => {
                    _eventDispatcher.Send(
                        "codemodel raw-filesystem-change-" +
                        x.Type.ToString().ToLower() +
                        " \"" + x.Path + "\"");
                });
            Logger.Write("Adding plugins to cache");
            var plugins = pluginLocator.Locate().ToList();
            foreach (var x in plugins) {
                var plugin = new PluginPattern(x);
                _plugins.Add(plugin);
                _cache.Plugins.Add(
                    new CachedPlugin(x.GetLanguage(), plugin.Patterns));
                Logger.Write("Added plugin " + x.GetLanguage());
            }
            var locator = new ProfileLocator(path);
            var profilePath = locator.GetLocalProfilePath(locator.GetActiveLocalProfile());
            if (Directory.Exists(profilePath)) {
                Logger.Write("Starting tracker for {0}", path);
                _tracker.Start(path, getFilter(), handleChanges, ignoreDirectories);
            } else {
                Logger.Write("No local configuration point so not starting file tracker");
            }
            if (Environment.OSVersion.Platform == PlatformID.Unix || Environment.OSVersion.Platform == PlatformID.MacOSX) {
                if (Directory.Exists(profilePath)) {
                    Logger.Write("Starting tracker for {0}", profilePath);
                    _localTracker.Start(profilePath, getFilter(), handleChanges, ignoreDirectories);
                }
            }
            var globalPath = locator.GetGlobalProfilePath(locator.GetActiveGlobalProfile());
            if (Directory.Exists(globalPath)) {
                Logger.Write("Starting tracker for {0}", globalPath);
                _globalTracker.Start(globalPath, getFilter(), handleChanges, ignoreDirectories);
            }
        }
示例#5
0
        private bool install(string packageToken, string[] acceptedVersions)
        {
            var source = _packageFetcher.Fetch(packageToken);
            if (source == null || !File.Exists(source.Package)) {
                _dispatch("error|could not find package " + packageToken);
                return false;
            }

            if (isMetaPackage(source.Package)) {
                installMetaPackage(source);
                return true;
            }

            string activeProfile = null;
            var actionSucceeded = prepareForAction(
                source.Package,
                (package) => {
                    var profiles = new ProfileLocator(_token);
                    if (_useGlobal)
                        activeProfile = profiles.GetActiveGlobalProfile();
                    else
                        activeProfile = profiles.GetActiveLocalProfile();
                    var installPath = getInstallPath(package, profiles, activeProfile);
                    if (installPath == null)
                        return null;
                    Logger.Write("Installing the package in " + installPath);
                    return installPath;
                },
                (args) => {
                        if (args.Match != null) {
                            Logger.Write("found matching package " + args.Match);
                            var command = Path.GetFileNameWithoutExtension(args.Match);
                            var package = getPackage(command);
                            if (package != null) {
                                Logger.Write("loaded package " + package.ID);
                                if (acceptedVersions != null) {
                                    if (acceptedVersions.Length > 0 && !acceptedVersions.Any(x => x == package.Version)) {
                                        var versions = "";
                                        foreach (var version in acceptedVersions) {
                                            versions += version + ",";
                                        }
                                        versions = versions.Trim(new[] {','});
                                        _dispatch(string.Format("error|dependency {0} ({1}) is installed. Accepted versions are {2}", args.Package.ID, package.Version, versions));
                                        return false;
                                    }
                                }
                                Logger.Write(string.Format("skipping {0} ({1}) already installed", package.ID, package.Version));
                            } else {
                                _dispatch(string.Format("error|the package with the command {0} conflicts with the package you are trying to install", command));
                            }
                        } else if (acceptedVersions != null && !acceptedVersions.Any(x => x == args.Package.Version)) {
                            var versions = "";
                            foreach (var version in acceptedVersions) {
                                versions += version + ",";
                            }
                            versions = versions.Trim(new[] {','});
                            _dispatch(string.Format("error|dependency {0} of version {1} is not a valid. Accepted versions are {2}", args.Package.ID, args.Package.Version, versions));
                            return false;
                        } else
                            installPackage(source.Package, args.Package, args.TempPath, args.InstallPath, activeProfile);
                        return true;
                    });
            if (source.IsTemporaryPackage)
                File.Delete(source.Package);
            return actionSucceeded;
        }
        private List<string> getLanguagePaths()
        {
            var orderedProfilePaths = new List<string>();
            var profiles = new ProfileLocator(_keyPath);
            var profilePath = profiles.GetGlobalProfilePath("default");
            if (profilePath != null)
                orderedProfilePaths.Add(Path.Combine(profilePath, "languages"));
            profilePath = profiles.GetGlobalProfilePath(profiles.GetActiveGlobalProfile());
            if (profilePath != null)
                orderedProfilePaths.Add(Path.Combine(profilePath, "languages"));
            profilePath = profiles.GetLocalProfilePath("default");
            if (profilePath != null)
                orderedProfilePaths.Add(Path.Combine(profilePath, "languages"));
            profilePath = profiles.GetLocalProfilePath(profiles.GetActiveLocalProfile());
            if (profilePath != null)
                orderedProfilePaths.Add(Path.Combine(profilePath, "languages"));

            var paths = new List<string>();
            foreach (var plugin in _pluginLocator().Locate())
                addLanguagePath(plugin, orderedProfilePaths, ref paths);
            paths.Reverse();
            return paths;
        }
示例#7
0
 private void construct(string file, string keyPath, Action<string,string> outputDispatcher, Action<string> dispatch, bool dispatchErrors)
 {
     _file = file;
     _keyPath = keyPath;
     _outputDispatcher = outputDispatcher;
     _dispatch = dispatch;
     _dispatchErrors = dispatchErrors;
     var profiles = new ProfileLocator(_keyPath);
     _globalProfileName = profiles.GetActiveGlobalProfile();
     _localProfileName = profiles.GetActiveLocalProfile();
     getEvents();
 }
示例#8
0
 public string GetGlobalPath()
 {
     var locator = new ProfileLocator(_keyPath);
     return GetGlobalPath(locator.GetActiveGlobalProfile());
 }
示例#9
0
        private void listProfilesRaw()
        {
            var profileLocator = new ProfileLocator(Environment.CurrentDirectory);
            Console.WriteLine("active-global|" + profileLocator.GetActiveGlobalProfile()+"|"+profileLocator.GetGlobalProfilePath(profileLocator.GetActiveGlobalProfile()));
            Console.WriteLine("active-local|" + profileLocator.GetActiveLocalProfile()+"|"+profileLocator.GetLocalProfilePath(profileLocator.GetActiveLocalProfile()));
            var globalProfiles =
                profileLocator.GetProfilesForPath(
                    profileLocator.GetGlobalProfilesRoot());
            globalProfiles.Insert(0, "default");
            globalProfiles.ForEach(x => Console.WriteLine("global|"+x+"|"+profileLocator.GetGlobalProfilePath(x)));

            if (Directory.Exists(profileLocator.GetLocalProfilesRoot())) {
                var localProfiles =
                profileLocator.GetProfilesForPath(
                    profileLocator.GetLocalProfilesRoot());
                localProfiles.Insert(0, "default");
                localProfiles.ForEach(x => Console.WriteLine("local|"+x+"|"+profileLocator.GetLocalProfilePath(x)));
            }
        }
示例#10
0
        private void listProfiles()
        {
            var profileLocator = new ProfileLocator(Environment.CurrentDirectory);
            Console.WriteLine("Active global profile: " + profileLocator.GetActiveGlobalProfile());
            Console.WriteLine("Active local profile:  " + profileLocator.GetActiveLocalProfile());
            var globalProfiles =
                profileLocator.GetProfilesForPath(
                    profileLocator.GetGlobalProfilesRoot());
            globalProfiles.Insert(0, "default");
            Console.WriteLine();
            Console.WriteLine("Global profiles:");
            globalProfiles.ForEach(x => Console.WriteLine("\t" + x));

            if (Directory.Exists(profileLocator.GetLocalProfilesRoot())) {
                var localProfiles =
                profileLocator.GetProfilesForPath(
                    profileLocator.GetLocalProfilesRoot());
                localProfiles.Insert(0, "default");
                Console.WriteLine();
                Console.WriteLine("Local profiles:");
                localProfiles.ForEach(x => Console.WriteLine("\t" + x));
            }

            Console.WriteLine();
        }
示例#11
0
 private string getActiveProfile(Args args)
 {
     var profileLocator = new ProfileLocator(Environment.CurrentDirectory);
     if (args.IsGlobal)
         return profileLocator.GetActiveGlobalProfile();
     else
         return profileLocator.GetActiveLocalProfile();
 }
示例#12
0
        private bool prepareForAction(string source, Func<ActionParameters,bool> actionHandler)
        {
            var profiles = new ProfileLocator(_token);
            string activeProfile;

            var actionSucceeded = false;
            var tempPath = Path.Combine(Path.GetTempPath(), DateTime.Now.Ticks.ToString());
            Directory.CreateDirectory(tempPath);
            try {
                var package = getInstallPackage(source, tempPath);
                if (package != null) {
                    // Force language to global as that is the only thing workin atm
                    if (package.Target == "language")
                        _useGlobal = true;
                    if (_useGlobal)
                        activeProfile = profiles.GetActiveGlobalProfile();
                    else
                        activeProfile = profiles.GetActiveLocalProfile();

                    var installPath = getInstallPath(package, profiles, activeProfile);
                    if (installPath == null) {
                        _dispatch("error|Config point is not initialized");
                        return false;
                    }
                    if (!Directory.Exists(installPath))
                        Directory.CreateDirectory(installPath);
                    var match =
                        Directory.GetFiles(installPath)
                            .FirstOrDefault(x => matchPackage(x, package.Command));
                    actionSucceeded = actionHandler(
                        new ActionParameters() {
                            Package = package,
                            TempPath = tempPath,
                            InstallPath = installPath,
                            ProfileName = activeProfile,
                            Match = match
                        });
                }
            } catch (Exception ex) {
                Console.WriteLine(ex.ToString());
            } finally {
                Directory.Delete(tempPath, true);
            }
            return actionSucceeded;
        }