GetLocalProfilePath() public method

public GetLocalProfilePath ( string name ) : string
name string
return string
Ejemplo n.º 1
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;
 }
Ejemplo n.º 2
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);
            }
        }
Ejemplo n.º 3
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);
 }
Ejemplo n.º 4
0
        public AppSettings(string path, Func<IEnumerable<ICommandHandler>> handlers, Func<IEnumerable<ICommandHandler>> pluginHandlers)
        {
            _path = path;
            var locator = new ProfileLocator(Environment.CurrentDirectory);
            RootPath = locator.GetLocalProfilePath("default");
            if (RootPath == null)
                RootPath = Directory.GetCurrentDirectory();
            else
                RootPath = System.IO.Path.GetDirectoryName(RootPath);

            var local = new Configuration(Directory.GetCurrentDirectory(), false);
            var global = new Configuration(_path, false);

            if (local.DefaultLanguage != null)
                DefaultLanguage = local.DefaultLanguage;
            else if (global.DefaultLanguage != null)
                DefaultLanguage = global.DefaultLanguage;

            if (local.EnabledLanguages != null)
                EnabledLanguages = local.EnabledLanguages;
            else if (global.EnabledLanguages != null)
                EnabledLanguages = global.EnabledLanguages;
        }
Ejemplo n.º 5
0
        public AppSettings(string path, Func<IEnumerable<ICommandHandler>> handlers, Func<IEnumerable<ICommandHandler>> pluginHandlers)
        {
            _path = path;
            SourcePrioritization = new string[] {};
            var locator = new ProfileLocator(fixPath(Environment.CurrentDirectory));
            RootPath = locator.GetLocalProfilePath("default");
            if (RootPath == null)
                RootPath = fixPath(Directory.GetCurrentDirectory());
            else
                RootPath = System.IO.Path.GetDirectoryName(RootPath);
            var reader = new ConfigReader(RootPath);

            var defaultLanguage = reader.Get("default.language");
            if (defaultLanguage != null)
                DefaultLanguage = defaultLanguage;

            var enabledLanguages = reader.Get("enabled.languages");
            if (enabledLanguages != null)
                EnabledLanguages = splitValue(enabledLanguages);

            var prioritizedSources = reader.Get("oi.source.prioritization");
            if (prioritizedSources != null)
                SourcePrioritization = splitValue(prioritizedSources);
        }
Ejemplo n.º 6
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");
 }
Ejemplo n.º 7
0
 private string getInstallPath(Package package, ProfileLocator profiles, string activeProfile)
 {
     string installPath;
     if (package.Target.StartsWith("language-")) {
         var path = getLanguageInstallPath(package, !_useGlobal);
         if (path == null) {
             _dispatch("error|could not find language to install language dependent package in");
             return null;
         }
         if (_useGlobal && !profiles.IsGlobal(path)) {
             _dispatch("error|cannot install language dependent package globally as language is installed locally.");
             return null;
         }
         return path;
     }
     if (_useGlobal)
         installPath = profiles.GetGlobalProfilePath(activeProfile);
     else
         installPath = profiles.GetLocalProfilePath(activeProfile);
     if (installPath == null) {
         _dispatch("error|the current location does not have an initialized config point");
         return null;
     }
     return Path.Combine(installPath, package.Target + "s");
 }
Ejemplo n.º 8
0
        public void Execute(string[] arguments)
        {
            _verbose = arguments.Contains("-v");
            _showoutputs = arguments.Contains("-o");
            _showevents = arguments.Contains("-e");
            _printOnlyErrorsAndInconclusives = arguments.Contains("--only-errors");
            _logging = arguments.Contains("-l");
            var profiles = new ProfileLocator(_token);

            var testFiles = new List<string>();
            if (arguments.Length > 0 && File.Exists(arguments[0])) {
                testFiles.Add(arguments[0]);
            } else {
                testFiles
                    .AddRange(
                        getTests(profiles.GetLocalProfilePath("default")));
                testFiles
                    .AddRange(
                        getTests(profiles.GetGlobalProfilePath("default")));
                testFiles
                    .AddRange(
                        getTests(
                            Path.GetDirectoryName(
                                Assembly.GetExecutingAssembly().Location)));
            }

            foreach (var testFile in testFiles) {

                _testRunLocation = Path.Combine(Path.GetTempPath(), DateTime.Now.Ticks.ToString());
                Console.WriteLine("Testing: {0}", testFile);
                var eventListenerStarted = false;
                var systemStarted = false;
                var runCompleted = false;
                var eventListener = new Thread(() => {
                            var eventSocketClient = new EventStuff.EventClient(
                                (line) => {
                                            if (line == "codeengine started") {
                                                log("Code engine started");
                                                systemStarted = true;
                                            } if (line == "codeengine stopped") {
                                                log("Code engine stopped");
                                                runCompleted = true;
                                            }
                                            _events.Add(line);
                                        });
                            while (true) {
                                eventSocketClient.Connect(_testRunLocation);
                                eventListenerStarted = true;
                                if (!eventSocketClient.IsConnected) {
                                    Thread.Sleep(10);
                                    if (runCompleted || systemStarted)
                                        break;
                                    continue;
                                }
                                log("Event listener connected");
                                while (eventSocketClient.IsConnected)
                                    Thread.Sleep(10);
                                break;
                            }
                            eventListenerStarted = false;
                        });
                var isQuerying = false;
                var useEditor = false;
                var tests = new List<string>();
                Process proc = null;
                try {
                    Directory.CreateDirectory(_testRunLocation);
                    _events = new List<string>();
                    _outputs = new List<string>();
                    _asserts = new List<string>();

                    log("Initializing test location");
                    runCommand("init");
                    // Make sure we run tests in default profile is
                    // this by any chance overloaded in init command
                    runCommand("profile load default");
                    eventListener.Start();

                    new Thread(() => {
                            log("Starting test process");
                            var testProc = new Process();
                            try {
                                testProc
                                    .Query(
                                        testFile,
                                        _testRunLocation,
                                        false,
                                        Environment.CurrentDirectory,
                                        (error, line) => {
                                                if (line == "initialized" || line.StartsWith("initialized|")) {
                                                    log("Test file initialized");
                                                    proc = testProc;
                                                    var chunks = line.Split(new[] {'|'});
                                                    if (chunks.Length > 1 && chunks[1] == "editor") {
                                                        while (!eventListenerStarted)
                                                            Thread.Sleep(10);
                                                        log("Starting editor");
                                                        new Process().Run("oi", "editor test", false, _testRunLocation);
                                                        log("Editor launched");
                                                        useEditor = true;
                                                    } else {
                                                        log("System started");
                                                        systemStarted = true;
                                                    }
                                                    return;
                                                }
                                                if (line == "end-of-conversation") {
                                                    isQuerying = false;
                                                    return;
                                                }
                                                handleFeedback(proc, error, line);
                                            });
                            } catch (Exception ex) {
                                handleFeedback(testProc, true, "A fatal error occured while running " + testFile + Environment.NewLine + ex.Message);
                            }
                            isQuerying = false;
                            runCompleted = true;
                        }).Start();
                } catch (Exception ex) {
                    Console.WriteLine(ex.ToString());
                }

                log("Waiting for system to complete loading");
                while (!systemStarted)
                    Thread.Sleep(10);

                log("Getting tests");
                isQuerying = ask(proc, "get-tests");
                while (isQuerying)
                    Thread.Sleep(10);
                tests.AddRange(
                    _summary.ToString()
                    .Replace("\t", "")
                    .Split(
                        new[] { Environment.NewLine },
                        StringSplitOptions.RemoveEmptyEntries));

                foreach (var test in tests) {
                    if (_currentTest != null)
                        writeInconclusive();
                    log("Running test: " + test);
                    _outputs.Clear();
                    _events.Clear();
                    _asserts.Clear();
                    _currentTest = test;
                    _summary = new StringBuilder();
                    if (_verbose)
                        Console.Write(_currentTest + "...");
                    isQuerying = ask(proc, "test|" + _currentTest);
                    while (isQuerying)
                        Thread.Sleep(10);
                }

                if (useEditor) {
                    log("Shuting down editor");
                    new Process().Run("oi", "editor command kill", false, _testRunLocation);
                }

                log("Shuting down system");
                ask(proc, "shutdown");
                while (!runCompleted)
                    Thread.Sleep(10);

                log("Waiting for event listener to stop");
                while (eventListenerStarted)
                    Thread.Sleep(10);

                if (Directory.Exists(_testRunLocation))
                    Directory.Delete(_testRunLocation, true);

                if (_currentTest != null)
                    writeInconclusive();
                _currentTest = null;
                log("Test run finished");
                Console.WriteLine();
            }
        }
        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;
        }
Ejemplo n.º 10
0
 private static string getConfigPoint(string path)
 {
     var locator = new ProfileLocator(path);
     return locator.GetLocalProfilePath(locator.GetActiveLocalProfile());
 }
Ejemplo n.º 11
0
 private string getInstallPath(Package package, ProfileLocator profiles, string activeProfile)
 {
     string installPath;
     if (package.Target.StartsWith("language-"))
         return getLanguageInstallPath(package);
     if (_useGlobal)
         installPath = profiles.GetGlobalProfilePath(activeProfile);
     else
         installPath = profiles.GetLocalProfilePath(activeProfile);
     if (installPath == null)
         return null;
     return Path.Combine(installPath, package.Target + "s");
 }
Ejemplo n.º 12
0
 public string GetLocalPath(string profile)
 {
     var locator = new ProfileLocator(_keyPath);
     var profilePath = locator.GetLocalProfilePath(profile);
     if (profilePath == null)
         return profilePath;
     return getPath(profilePath);
 }
Ejemplo n.º 13
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)));
            }
        }
Ejemplo n.º 14
0
 private string getProfilePath(Args args, string name)
 {
     var profileLocator = new ProfileLocator(Environment.CurrentDirectory);
     if (args.IsGlobal)
         return profileLocator.GetGlobalProfilePath(name);
     else
         return profileLocator.GetLocalProfilePath(name);
 }