コード例 #1
0
        /// <summary>
        /// Runs a dotnet process. On Windows, it just runs the executable. On non-Windows,
        /// it runs the executable using Unity's mono.
        /// </summary>
        /// <remarks>You don't need to call <see cref="ProcessManager.Configure{T}(T, string)"/> on this task,
        /// it already does it in the constructor.
        /// </remarks>
        protected BaseProcessTask(ITaskManager taskManager, IProcessManager processManager,
                                  IProcessEnvironment processEnvironment,
                                  IEnvironment environment,
                                  string executable, string arguments,
                                  string workingDirectory,
                                  bool alwaysUseMono, bool neverUseMono,
                                  CancellationToken token = default)
            : base(taskManager, processEnvironment, outputProcessor: new StringOutputProcessor(), token: token)
        {
            if (neverUseMono || !alwaysUseMono && environment.IsWindows)
            {
                ProcessName      = executable;
                ProcessArguments = arguments;
            }
            else
            {
                ProcessArguments = executable + " " + arguments;
                ProcessName      = environment.UnityApplicationContents.ToSPath()
                                   .Combine("MonoBleedingEdge", "bin", "mono" + environment.ExecutableExtension);
            }

            if (processManager != null)
            {
                processManager.Configure(this, workingDirectory);
            }
        }
コード例 #2
0
        public RpcServerTask(ITaskManager taskManager,
                             IProcessManager processManager,
                             IProcessEnvironment processEnvironment,
                             IEnvironment environment,
                             IRpcProcessConfiguration configuration,
                             string workingDir             = default,
                             ProcessOptions options        = default,
                             PortOutputProcessor processor = null,
                             List <Type> remoteRpcTargets  = null, List <object> localRpcTargets = null,
                             CancellationToken token       = default)
            : base(taskManager, token)
        {
            this.expectedPort       = configuration.Port;
            this.processManager     = processManager;
            this.configuration      = configuration;
            this.workingDir         = workingDir;
            this.options            = options;
            this.processEnvironment = processManager.DefaultProcessEnvironment;
            this.environment        = processEnvironment.Environment;
            this.remoteRpcTargets   = remoteRpcTargets ?? new List <Type>();
            this.localRpcTargets    = localRpcTargets ?? new List <object>();
            executable = configuration.ExecutablePath;
            arguments  = CreateArguments(environment, configuration);

            portProcessor = processor ?? new PortOutputProcessor();
        }
コード例 #3
0
        /// <summary>
        /// Runs a process.
        /// </summary>
        /// <remarks>You don't need to call <see cref="ProcessManager.Configure{T}(T, string)"/> on this task,
        /// it already does it in the constructor.
        /// </remarks>
        protected BaseProcessListTask(ITaskManager taskManager, IProcessManager processManager,
                                      IProcessEnvironment processEnvironment, IEnvironment environment,
                                      string executable, string arguments, string workingDirectory,
                                      Func <IProcessTask <T, List <T> >, string, bool> isMatch,
                                      Func <IProcessTask <T, List <T> >, string, T> processor,
                                      bool alwaysUseMono, bool neverUseMono,
                                      CancellationToken token = default)
            : base(taskManager, processEnvironment, token: token)
        {
            this.isMatch   = isMatch;
            this.processor = processor;

            if (neverUseMono || !alwaysUseMono && environment.IsWindows)
            {
                ProcessName      = executable;
                ProcessArguments = arguments;
            }
            else
            {
                ProcessArguments = executable + " " + arguments;
                ProcessName      = environment.UnityApplicationContents.Combine("MonoBleedingEdge", "bin", "mono" + environment.ExecutableExtension);
            }

            if (processManager != null)
            {
                processManager.Configure(this, workingDirectory);
            }
        }
コード例 #4
0
 public GitLfsVersionTask(ITaskManager taskManager, IProcessEnvironment processEnvironment,
                          string gitLfsExecutablePath, CancellationToken token = default)
     : base(taskManager, processEnvironment, gitLfsExecutablePath, "version",
            outputProcessor: new LfsVersionOutputProcessor(), token: token)
 {
     Name = TaskName;
 }
 public RemoteProcessManager(IProcessServer server, IProcessEnvironment environment, CancellationToken token)
 {
     cts         = CancellationTokenSource.CreateLinkedTokenSource(token);
     this.server = server;
     DefaultProcessEnvironment = environment;
     ProcessNotifications      = new Notifications(this);
 }
コード例 #6
0
        public ProcessEnvironment(IProcessEnvironment defaultEnvironment, IGitEnvironment environment)
        {
            this.defaultEnvironment = defaultEnvironment;
            GitEnvironment          = environment;

            Logger = LogHelper.GetLogger(GetType());
        }
コード例 #7
0
 public GitProcessListTask(ITaskManager taskManager, IProcessEnvironment processEnvironment,
                           string gitExecutablePath, string arguments,
                           IOutputProcessor <T, List <T> > outputProcessor, CancellationToken token = default)
     : base(taskManager, processEnvironment,
            gitExecutablePath, arguments, outputProcessor, token)
 {
 }
コード例 #8
0
 /// <summary>
 /// Runs a process.
 /// </summary>
 /// <remarks>You need to call <see cref="ProcessManager.Configure{T}(T, string)"/> on this task before running it.</remarks>
 public NativeProcessTask(ITaskManager taskManager,
                          IProcessEnvironment processEnvironment,
                          string executable, string arguments,
                          CancellationToken token = default)
     : base(taskManager, null, processEnvironment, null,
            executable, arguments, null, false, true, token)
 {
 }
コード例 #9
0
 /// <summary>
 /// Runs a dotnet process. On Windows, it just runs the executable. On non-Windows,
 /// it runs the executable using Unity's mono.
 /// </summary>
 /// <remarks>You don't need to call <see cref="ProcessManager.Configure{T}(T, string)"/> on this task,
 /// it already does it in the constructor.
 /// </remarks>
 public DotNetProcessTask(ITaskManager taskManager, IProcessManager processManager,
                          IEnvironment environment, IProcessEnvironment processEnvironment,
                          string executable, string arguments,
                          string workingDirectory = null,
                          CancellationToken token = default)
     : base(taskManager, processManager,
            processEnvironment, environment,
            executable, arguments, workingDirectory, false, false, token)
 {
 }
コード例 #10
0
 /// <summary>
 /// Runs a process.
 /// </summary>
 /// <remarks>You need to call <see cref="ProcessManager.Configure{T}(T, string)"/> on this task before running it.</remarks>
 public NativeProcessListTask(ITaskManager taskManager,
                              IProcessEnvironment processEnvironment,
                              string executable,
                              string arguments,
                              Func <IProcessTask <T, List <T> >, string, T> processor,
                              CancellationToken token = default)
     : base(taskManager, null,
            processEnvironment, null,
            executable, arguments, null, null, processor, false, true, token)
 {
 }
コード例 #11
0
 /// <summary>
 /// Runs a dotnet process. On Windows, it just runs the executable. On non-Windows,
 /// it runs the executable using Unity's mono.
 /// </summary>
 /// <remarks>You need to call <see cref="ProcessManager.Configure{T}(T, string)"/> on this task before running it.</remarks>
 public DotNetProcessListTask(ITaskManager taskManager,
                              IProcessEnvironment processEnvironment,
                              IEnvironment environment,
                              string executable,
                              string arguments,
                              IOutputProcessor <T, List <T> > outputProcessor,
                              CancellationToken token = default)
     : base(taskManager, null,
            processEnvironment, environment,
            executable, arguments, null, outputProcessor, false, false, token)
 {
 }
コード例 #12
0
 /// <summary>
 /// Runs a process.
 /// </summary>
 /// <remarks>You don't need to call <see cref="ProcessManager.Configure{T}(T, string)"/> on this task,
 /// it already does it in the constructor.
 /// </remarks>
 public NativeProcessListTask(ITaskManager taskManager,
                              IProcessManager processManager,
                              IProcessEnvironment processEnvironment,
                              string executable,
                              string arguments,
                              Func <IProcessTask <T, List <T> >, string, T> processor,
                              string workingDirectory = null,
                              CancellationToken token = default)
     : base(taskManager, processManager.EnsureNotNull(nameof(processManager)),
            processEnvironment ?? processManager.DefaultProcessEnvironment, null,
            executable, arguments, workingDirectory, null, processor, false, true, token)
 {
 }
コード例 #13
0
 /// <summary>
 /// Runs a dotnet process. On Windows, it just runs the executable. On non-Windows,
 /// it runs the executable using Unity's mono.
 /// </summary>
 /// <remarks>You need to call <see cref="ProcessManager.Configure{T}(T, string)"/> on this task before running it.</remarks>
 public DotNetProcessListTask(ITaskManager taskManager,
                              IProcessEnvironment processEnvironment,
                              IEnvironment environment,
                              string executable,
                              string arguments,
                              Func <IProcessTask <T, List <T> >, string, bool> isMatch,
                              Func <IProcessTask <T, List <T> >, string, T> processor,
                              CancellationToken token = default)
     : base(taskManager, null,
            processEnvironment, environment,
            executable, arguments, null, isMatch, processor, false, false, token)
 {
 }
コード例 #14
0
        public static ITask <GitStatus> GetGitStatus(this IProcessManager processManager,
                                                     NPath workingDirectory,
                                                     IEnvironment environment, IProcessEnvironment gitEnvironment,
                                                     NPath?gitPath = null)
        {
            var gitStatusEntryFactory = new GitObjectFactory(environment);
            var processor             = new GitStatusOutputProcessor(gitStatusEntryFactory);

            NPath path = gitPath ?? defaultGitPath;

            return(new ProcessTask <GitStatus>(CancellationToken.None, processor)
                   .Configure(processManager, path, "status -b -u --porcelain", workingDirectory, false));
        }
コード例 #15
0
ファイル: ProcessTask.cs プロジェクト: spoiledcat/UnityTools
 /// <summary>
 /// Runs a Process with the passed arguments
 /// </summary>
 /// <param name="taskManager"></param>
 /// <param name="token"></param>
 /// <param name="processEnvironment"></param>
 /// <param name="executable"></param>
 /// <param name="arguments"></param>
 /// <param name="outputProcessor"></param>
 public ProcessTaskWithListOutput(
     ITaskManager taskManager,
     IProcessEnvironment processEnvironment,
     string executable = null,
     string arguments  = null,
     IOutputProcessor <T, List <T> > outputProcessor = null,
     CancellationToken token = default)
     : base(taskManager, token)
 {
     this.OutputProcessor = outputProcessor;
     ProcessEnvironment   = processEnvironment;
     ProcessArguments     = arguments;
     ProcessName          = executable;
 }
コード例 #16
0
 /// <summary>
 /// Runs a dotnet process. On Windows, it just runs the executable. On non-Windows,
 /// it runs the executable using Unity's mono.
 /// </summary>
 /// <remarks>You don't need to call <see cref="ProcessManager.Configure{T}(T, string)"/> on this task,
 /// it already does it in the constructor.
 /// </remarks>
 public DotNetProcessListTask(ITaskManager taskManager,
                              IProcessManager processManager,
                              IProcessEnvironment processEnvironment,
                              IEnvironment environment,
                              string executable,
                              string arguments,
                              IOutputProcessor <T, List <T> > outputProcessor,
                              string workingDirectory = null,
                              CancellationToken token = default)
     : base(taskManager, processManager.EnsureNotNull(nameof(processManager)),
            processEnvironment ?? processManager.DefaultProcessEnvironment, environment,
            executable, arguments, workingDirectory, outputProcessor, false, false, token)
 {
 }
コード例 #17
0
        public ProcessRunner(ITaskManager taskManager,
                             IProcessManager processManager,
                             IProcessEnvironment processEnvironment,
                             ServerConfiguration serverConfiguration,
                             ILogger <ProcessRunner> logger)
        {
            cts = CancellationTokenSource.CreateLinkedTokenSource(taskManager.Token);

            this.taskManager        = taskManager;
            this.processManager     = processManager;
            this.processEnvironment = processEnvironment;
            this.logger             = logger;
            this.accessToken        = serverConfiguration.AccessToken;
        }
コード例 #18
0
        public static ITask <string> GetGitCreds(this IProcessManager processManager,
                                                 NPath workingDirectory,
                                                 IEnvironment environment, IProcessEnvironment gitEnvironment,
                                                 NPath?gitPath = null)
        {
            var processor = new FirstNonNullLineOutputProcessor();

            NPath path = gitPath ?? defaultGitPath;

            var task = new ProcessTask <string>(CancellationToken.None, processor)
                       .Configure(processManager, path, "credential-wincred get", workingDirectory, true);

            task.OnStartProcess += p =>
            {
                p.StandardInput.WriteLine("protocol=https");
                p.StandardInput.WriteLine("host=github.com");
                p.StandardInput.Close();
            };
            return(task);
        }
 public RemoteProcessEnvironment(IProcessEnvironment localProcessEnvironment)
 {
     this.localProcessEnvironment = localProcessEnvironment;
 }
コード例 #20
0
 public FindExecTask(ITaskManager taskManager, IProcessEnvironment processEnvironment, IEnvironment environment,
                     string executable, CancellationToken token = default)
     : base(taskManager, processEnvironment, environment.IsWindows ? "where" : "which", executable,
            new FirstLineIsPathOutputProcessor(), token)
 {
 }
コード例 #21
0
 protected BaseProcessListTask(ITaskManager taskManager, IProcessEnvironment processEnvironment, IOutputProcessor <T, List <T> > outputProcessor,
                               CancellationToken token = default)
     : base(taskManager, processEnvironment, outputProcessor: outputProcessor, token: token)
 {
 }
コード例 #22
0
 public ProcessManager(IEnvironment environment, IProcessEnvironment gitEnvironment, CancellationToken cancellationToken)
 {
     this.environment       = environment;
     this.gitEnvironment    = gitEnvironment;
     this.cancellationToken = cancellationToken;
 }
コード例 #23
0
 public ProcessManager(IEnvironment environment, IProcessEnvironment gitEnvironment)
     : this(environment, gitEnvironment, CancellationToken.None)
 {
 }
コード例 #24
0
        public static async Task <GitStatus> GetGitStatus(this ProcessManager processManager,
                                                          NPath workingDirectory,
                                                          IEnvironment environment, IFileSystem filesystem, IProcessEnvironment gitEnvironment,
                                                          NPath?gitPath = null)
        {
            var gitStatusEntryFactory = new GitObjectFactory(environment);
            var processor             = new GitStatusOutputProcessor(gitStatusEntryFactory);

            NPath path = gitPath ?? defaultGitPath;

            var results = await new ProcessTask <GitStatus>(CancellationToken.None, processor)
                          .Configure(processManager, path, "status -b -u --porcelain", workingDirectory, false)
                          .Start()
                          .Task;

            return(results);
        }
コード例 #25
0
        public static async Task <List <GitLogEntry> > GetGitLogEntries(this ProcessManager processManager,
                                                                        NPath workingDirectory,
                                                                        IEnvironment environment, IFileSystem filesystem, IProcessEnvironment gitEnvironment,
                                                                        int?logCount  = null,
                                                                        NPath?gitPath = null)
        {
            var gitStatusEntryFactory = new GitObjectFactory(environment);

            var processor = new LogEntryOutputProcessor(gitStatusEntryFactory);

            var logNameStatus = @"log --pretty=format:""%H%n%P%n%aN%n%aE%n%aI%n%cN%n%cE%n%cI%n%B---GHUBODYEND---"" --name-status";

            if (logCount.HasValue)
            {
                logNameStatus = logNameStatus + " -" + logCount.Value;
            }

            NPath path = gitPath ?? defaultGitPath;

            var results = await new ProcessTaskWithListOutput <GitLogEntry>(CancellationToken.None, processor)
                          .Configure(processManager, path, logNameStatus, workingDirectory, false)
                          .Start()
                          .Task;

            return(results);
        }
コード例 #26
0
 public void Initialize(IProcessEnvironment environment)
 {
     this.Environment = environment;
 }
コード例 #27
0
 public GitProcessEnvironment(IGitEnvironment environment, SPath repositoryRoot)
     : base(environment, FindRepositoryRoot(repositoryRoot))
 {
     Instance = this;
     Reset();
 }
コード例 #28
0
 public GitProcessTask(ITaskManager taskManager, IProcessEnvironment processEnvironment,
                       string gitExecutablePath, string arguments,
                       CancellationToken token = default)
     : base(taskManager, processEnvironment, gitExecutablePath, arguments, token)
 {
 }