GetActiveLocalProfile() public method

public GetActiveLocalProfile ( ) : string
return string
Exemplo n.º 1
0
        public void Start(
			string path,
			ICacheBuilder cache,
			ICrawlResult crawlReader,
			PluginLocator pluginLocator,
			EventEndpoint eventDispatcher)
        {
            _cache = cache;
            _crawlReader = crawlReader;
            _eventDispatcher = eventDispatcher;
            Logger.Write("Setting up file trackers");
            Logger.Write("Setting up token file trackers");
            _tracker = new FileChangeTracker((x) => {
                    _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());
            }
            Logger.Write("Starting tracker for {0}", path);
            _tracker.Start(path, getFilter(), handleChanges);
            var locator = new ProfileLocator(path);
            if (Environment.OSVersion.Platform == PlatformID.Unix || Environment.OSVersion.Platform == PlatformID.MacOSX) {
                var profilePath = locator.GetLocalProfilePath(locator.GetActiveLocalProfile());
                if (Directory.Exists(profilePath)) {
                    Logger.Write("Starting tracker for {0}", profilePath);
                    _localTracker.Start(profilePath, getFilter(), handleChanges);
                }
            }
            var globalPath = locator.GetGlobalProfilePath(locator.GetActiveGlobalProfile());
            if (Directory.Exists(globalPath)) {
                Logger.Write("Starting tracker for {0}", globalPath);
                _globalTracker.Start(globalPath, getFilter(), handleChanges);
            }
        }
Exemplo n.º 2
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();
 }
Exemplo n.º 3
0
 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();
 }
Exemplo n.º 4
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;
 }
Exemplo n.º 5
0
 public void Start(string token)
 {
     var appdir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
     Logger.Write("Initializing code engine");
     initCodeEngine(token, appdir);
     Logger.Write("Running init script for " + appdir);
     runInitScript(token, appdir);
     Logger.Write("Initalizing language plugins");
     _pluginLocator().Locate().ToList()
         .ForEach(plugin => {
             var language = plugin.GetLanguage();
             Logger.Write("Initializing " + language);
             runInitScript(token, Path.Combine(Path.GetDirectoryName(plugin.FullPath), language + "-files"));
         });
     var locator = new ProfileLocator(token);
     var profilePath = locator.GetLocalProfilePath(locator.GetActiveLocalProfile());
     Logger.Write("Running init script for " + profilePath);
     runInitScript(token, profilePath);
 }
Exemplo n.º 6
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;
        }
Exemplo n.º 7
0
 private string getLanguageInstallPath(Package package, bool forcelocal)
 {
     var language = _locator
         .Locate()
         .FirstOrDefault(x => x.GetLanguage() == package.Language);
     if (language == null) {
         Logger.Write("Failed to locate language " + package.Language);
         return null;
     }
     var basepath = Path.GetDirectoryName(language.FullPath);
     if (forcelocal) {
         var profiles = new ProfileLocator(_token);
         basepath = Path.Combine(profiles.GetLocalProfilePath(profiles.GetActiveLocalProfile()), "languages");
     }
     return
         Path.Combine(
             Path.Combine(
                 basepath,
                 language.GetLanguage() + "-files"),
             package.Target.Replace("language-", "") + "s");
 }
        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;
        }
Exemplo n.º 9
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();
 }
Exemplo n.º 10
0
 private static string getConfigPoint(string path)
 {
     var locator = new ProfileLocator(path);
     return locator.GetLocalProfilePath(locator.GetActiveLocalProfile());
 }
Exemplo n.º 11
0
 public string GetLocalPath()
 {
     var locator = new ProfileLocator(_keyPath);
     return GetLocalPath(locator.GetActiveLocalProfile());
 }
Exemplo n.º 12
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)));
            }
        }
Exemplo n.º 13
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();
        }
Exemplo n.º 14
0
 private string getActiveProfile(Args args)
 {
     var profileLocator = new ProfileLocator(Environment.CurrentDirectory);
     if (args.IsGlobal)
         return profileLocator.GetActiveGlobalProfile();
     else
         return profileLocator.GetActiveLocalProfile();
 }
Exemplo n.º 15
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;
        }