Beispiel #1
0
        /// <summary>
        /// Executes an R script
        /// </summary>
        /// <param name="script">R script</param>
        /// <returns>Script results</returns>
        public object Execute(IRScript script)
        {
            RController.RequirePackages(_path, script.RequiredPackages);
            script.PreCompute();
            RScriptResult result = RController.RunScript(_path, script.BaseScript, script.Arguments);

            if (result.ExitCode != 0)
            {
                throw new RExecutionException(script.BaseScript, script.Arguments, result.Output, result.Error);
            }
            return(script.ImportResults(result));
        }
Beispiel #2
0
        /// <summary>
        /// Creates and opens a unique file in the cache.
        /// Do this if you plan on writing to the file immediately.
        /// </summary>
        /// <param name="name">Name</param>
        /// <returns>Pointer to file</returns>
        public static FileStream CreateCacheFile(string name)
        {
            FileStream info;

            lock (UniqueIDLock)
            {
                int index = 0;
                while (File.Exists(Path.Combine(RController.Cache, index.ToString() + "." + name)))
                {
                    index++;
                }
                info = RController.CreateCacheFile(index.ToString() + "." + name, false);
            }
            return(info);
        }
Beispiel #3
0
        /// <summary>
        /// Creates a unique directory in the cache.
        /// </summary>
        /// <param name="name">Name</param>
        /// <returns>Directory information</returns>
        public static DirectoryInfo CreateCacheDirectory(string name)
        {
            DirectoryInfo info;

            lock (UniqueIDLock)
            {
                int index = 0;
                while (Directory.Exists(Path.Combine(RController.Cache, index.ToString() + "." + name)))
                {
                    index++;
                }
                info = RController.CreateCacheDirectory(index.ToString() + "." + name, true);
            }
            return(info);
        }