public override void SetupOptionsForRun(ref string AppName, ref CommandUtils.ERunOptions Options, ref string CommandLine)
 {
     if (AppName == "sh" || AppName == "xbuild" || AppName == "codesign")
     {
         Options &= ~CommandUtils.ERunOptions.AppMustExist;
     }
     if (AppName == "xbuild")
     {
         AppName     = "sh";
         CommandLine = "-c 'xbuild " + (String.IsNullOrEmpty(CommandLine) ? "" : CommandLine) + " /p:DefineConstants=MONO /verbosity:quiet /nologo |grep -i error; if [ $? -ne 1 ]; then exit 1; else exit 0; fi'";
     }
     if (AppName.EndsWith(".exe") || ((AppName.Contains("/Binaries/Win64/") || AppName.Contains("/Binaries/Mac/")) && string.IsNullOrEmpty(Path.GetExtension(AppName))))
     {
         if (AppName.Contains("/Binaries/Win64/") || AppName.Contains("/Binaries/Mac/"))
         {
             AppName = AppName.Replace("/Binaries/Win64/", "/Binaries/Mac/");
             AppName = AppName.Replace("-cmd.exe", "");
             AppName = AppName.Replace("-Cmd.exe", "");
             AppName = AppName.Replace(".exe", "");
             string AppFilename = Path.GetFileName(AppName);
             if (!CommandUtils.FileExists(AppName))
             {
                 AppName = AppName + ".app/Contents/MacOS/" + AppFilename;
             }
         }
         else
         {
             // It's a C# app, so run it with Mono
             CommandLine = "\"" + AppName + "\" " + (String.IsNullOrEmpty(CommandLine) ? "" : CommandLine);
             AppName     = "mono";
             Options    &= ~CommandUtils.ERunOptions.AppMustExist;
         }
     }
 }
        /// <summary>
        /// Runs an ADB command at the global scope
        /// </summary>
        /// <param name="Args"></param>
        /// <param name="Wait"></param>
        /// <returns></returns>
        public static IProcessResult RunAdbGlobalCommand(string Args, bool Wait = true, bool bShouldLogCommand = false)
        {
            CommandUtils.ERunOptions RunOptions = CommandUtils.ERunOptions.AppMustExist | CommandUtils.ERunOptions.NoWaitForExit;

            if (Log.IsVeryVerbose)
            {
                RunOptions |= CommandUtils.ERunOptions.AllowSpew;
            }
            else
            {
                RunOptions |= CommandUtils.ERunOptions.NoLoggingOfRunCommand;
            }

            if (bShouldLogCommand)
            {
                Log.Verbose("Running ADB Command: adb {0}", Args);
            }

            IProcessResult Process = AndroidPlatform.RunAdbCommand(null, null, Args, null, RunOptions);

            if (Wait)
            {
                Process.WaitForExit();
            }

            return(Process);
        }
 public MacAppInstall(string InName, TargetDeviceMac InDevice)
 {
     Name             = InName;
     Device           = InDevice;
     CommandArguments = "";
     this.RunOptions  = CommandUtils.ERunOptions.NoWaitForExit;
 }
 public override void SetupOptionsForRun(ref string AppName, ref CommandUtils.ERunOptions Options, ref string CommandLine)
 {
     if (AppName == "sh" || AppName == "xbuild" || AppName == "codesign")
     {
         Options &= ~CommandUtils.ERunOptions.AppMustExist;
     }
     if (AppName == "xbuild")
     {
         AppName     = "xbuild";
         CommandLine = (String.IsNullOrEmpty(CommandLine) ? "" : CommandLine) + " /verbosity:quiet /nologo";
         // Pass #define MONO to all the automation scripts (see XboxOne)
         CommandLine += " /p:DefineConstants=MONO";
         // Some projects have TargetFrameworkProfile=Client which causes warnings on Linux
         // so force it to empty.
         CommandLine += " /p:TargetFrameworkProfile=";
     }
     if (AppName.EndsWith(".exe") || ((AppName.Contains("/Binaries/Win64/") || AppName.Contains("/Binaries/Linux/")) && string.IsNullOrEmpty(Path.GetExtension(AppName))))
     {
         if (AppName.Contains("/Binaries/Win64/") || AppName.Contains("/Binaries/Linux/"))
         {
             AppName = AppName.Replace("/Binaries/Win64/", "/Binaries/Linux/");
             AppName = AppName.Replace("-cmd.exe", "");
             AppName = AppName.Replace("-Cmd.exe", "");
             AppName = AppName.Replace(".exe", "");
         }
         else
         {
             // It's a C# app, so run it with Mono
             CommandLine = "\"" + AppName + "\" " + (String.IsNullOrEmpty(CommandLine) ? "" : CommandLine);
             AppName     = "mono";
             Options    &= ~CommandUtils.ERunOptions.AppMustExist;
         }
     }
 }
        public IProcessResult ExecuteIOSDeployCommand(String CommandLine, int WaitTime = 60, bool WarnOnTimeout = true, bool UseDeviceID = true)
        {
            if (UseDeviceID && !IsDefaultDevice)
            {
                CommandLine = String.Format("--id {0} {1}", DeviceName, CommandLine);
            }

            String IOSDeployPath = Path.Combine(Globals.UE4RootDir, "Engine/Extras/ThirdPartyNotUE/ios-deploy/bin/ios-deploy");

            if (!File.Exists(IOSDeployPath))
            {
                throw new AutomationException("Unable to run ios-deploy binary at {0}", IOSDeployPath);
            }

            CommandUtils.ERunOptions RunOptions = CommandUtils.ERunOptions.NoWaitForExit;

            if (Log.IsVeryVerbose)
            {
                RunOptions |= CommandUtils.ERunOptions.AllowSpew;
            }
            else
            {
                RunOptions |= CommandUtils.ERunOptions.NoLoggingOfRunCommand;
            }

            Log.Verbose("ios-deploy executing '{0}'", CommandLine);

            IProcessResult Result = CommandUtils.Run(IOSDeployPath, CommandLine, Options: RunOptions);

            if (WaitTime > 0)
            {
                DateTime StartTime = DateTime.Now;

                Result.ProcessObject.WaitForExit(WaitTime * 1000);

                if (Result.HasExited == false)
                {
                    if ((DateTime.Now - StartTime).TotalSeconds >= WaitTime)
                    {
                        string Message = String.Format("IOSDeployPath timeout after {0} secs: {1}, killing process", WaitTime, CommandLine);

                        if (WarnOnTimeout)
                        {
                            Log.Warning(Message);
                        }
                        else
                        {
                            Log.Info(Message);
                        }

                        Result.ProcessObject.Kill();
                        // wait up to 15 seconds for process exit
                        Result.ProcessObject.WaitForExit(15000);
                    }
                }
            }

            return(Result);
        }
 public WindowsAppInstall(string InName, string InProjectName, TargetDeviceWindows InDevice)
 {
     Name             = InName;
     ProjectName      = InProjectName;
     WinDevice        = InDevice;
     CommandArguments = "";
     this.RunOptions  = CommandUtils.ERunOptions.NoWaitForExit;
 }
 public string RunECTool(string Args, bool bQuiet = false)
 {
     if (Command.ParseParam("FakeEC"))
     {
         CommandUtils.LogWarning("***** Would have ran ectool {0}", Args);
         return("We didn't actually run ectool");
     }
     else
     {
         CommandUtils.ERunOptions Opts = CommandUtils.ERunOptions.Default;
         if (bQuiet)
         {
             Opts = (Opts & ~CommandUtils.ERunOptions.AllowSpew) | CommandUtils.ERunOptions.NoLoggingOfRunCommand;
         }
         return(CommandUtils.RunAndLog("ectool", "--timeout 900 " + Args, Options: Opts));
     }
 }
        internal static IProcessResult ExecuteCommand(String Command, String Arguments)
        {
            CommandUtils.ERunOptions RunOptions = CommandUtils.ERunOptions.AppMustExist;

            if (Log.IsVeryVerbose)
            {
                RunOptions |= CommandUtils.ERunOptions.AllowSpew;
            }
            else
            {
                RunOptions |= CommandUtils.ERunOptions.NoLoggingOfRunCommand;
            }

            Log.Verbose("Executing '{0} {1}'", Command, Arguments);

            IProcessResult Result = CommandUtils.Run(Command, Arguments, Options: RunOptions);

            return(Result);
        }
		/// <summary>
		/// Runs an MLDB command at the global scope
		/// </summary>
		/// <param name="Args"></param>
		/// <param name="Wait"></param>
		/// <returns></returns>
		public static IProcessResult RunMldbGlobalCommand(string Args, bool Wait = true, bool bShouldLogCommand = true, bool bPauseErrorParsing = false, bool bNoStdOutRedirect = false)
		{
			CommandUtils.ERunOptions RunOptions = CommandUtils.ERunOptions.AppMustExist;
			if (!Wait)
			{
				RunOptions |= CommandUtils.ERunOptions.NoWaitForExit;
			}

			if (Log.IsVeryVerbose)
			{
				RunOptions |= CommandUtils.ERunOptions.AllowSpew;
			}
			else
			{
				RunOptions |= CommandUtils.ERunOptions.NoLoggingOfRunCommand;
			}

			if (bNoStdOutRedirect)
			{
				RunOptions |= CommandUtils.ERunOptions.NoStdOutRedirect;
			}
	
			if (bShouldLogCommand)
			{
				Log.Info("Running MLDB Command: mldb {0}", Args);
			}

			IProcessResult Process;

			using (bPauseErrorParsing ? new ScopedSuspendECErrorParsing() : null)
			{
				Process = LuminPlatform.RunDeviceCommand(null, null, Args, null, RunOptions);

				if (Wait)
				{
					Process.WaitForExit();
				}
			}
			
			return Process;
		}
Example #10
0
 public override void SetupOptionsForRun(ref string AppName, ref CommandUtils.ERunOptions Options, ref string CommandLine)
 {
 }
Example #11
0
 /// <summary>
 /// Sets any additional options for running an executable.
 /// </summary>
 /// <param name="AppName"></param>
 /// <param name="Options"></param>
 /// <param name="CommandLine"></param>
 abstract public void SetupOptionsForRun(ref string AppName, ref CommandUtils.ERunOptions Options, ref string CommandLine);
    public override void ExecuteBuild()
    {
        string   DayParam = ParseParamValue("Day");
        DateTime Day;
        string   FileName = ParseParamValue("FileName");

        // delete anything older than two weeks
        DateTime TwoWeeksAgo = DateTime.UtcNow.Subtract(new TimeSpan(14, 0, 0, 0));

        // The day we're passing in is running at midnight+ for the daily, so we actually want to label this as yesterday's report as far as the graph
        // since the utilization capture is actually getting from 12am the previous day to 12am today.
        // All builds run in that timeframe will be technically yesterday's builds.
        if (string.IsNullOrEmpty(DayParam))
        {
            Day = DateTime.Today.Add(new TimeSpan(1, 0, 0, 0));
            Log("Day parameter not specified, defaulting to today's report: " + Day.Date.ToString("MM-dd-yyyy"));
        }
        else
        {
            if (!DateTime.TryParse(DayParam, out Day))
            {
                throw new AutomationException("Day was passed in an incorrect format. Format <mm/dd/yy>");
            }
            if (Day < TwoWeeksAgo)
            {
                throw new AutomationException("The day passed is more than two weeks in the past. The report would be deleted tomorrow. Not running.");
            }
        }
        if (string.IsNullOrEmpty(FileName))
        {
            throw new AutomationException("FileName not Specified!");
        }

        if (!File.Exists(FileName))
        {
            throw new AutomationException("Could not find file at path: " + FileName);
        }



        CommandUtils.ERunOptions Opts = CommandUtils.ERunOptions.Default | CommandUtils.ERunOptions.SpewIsVerbose;
        XmlDocument Reader            = new XmlDocument();

        // get all of the existing properties
        Reader.LoadXml(CommandUtils.RunAndLog("ectool", "--timeout 900 getProperties --path \"/projects/GUBP_V5/Generated/Utilization\"", Options: Opts));
        // grab just the prop names
        XmlNodeList ExistingProps = Reader.GetElementsByTagName("propertyName");

        foreach (XmlNode prop in ExistingProps)
        {
            string   date = prop.InnerText.Replace("Report_", string.Empty);
            DateTime ExistingDate;
            if (!DateTime.TryParse(date, out ExistingDate))
            {
                LogWarning("Found property in Utilization properties that had a malformed name: " + prop.InnerText + ", remove this manually ASAP.");
                continue;
            }
            // delete anything older than two weeks
            if (ExistingDate < TwoWeeksAgo)
            {
                Log("Deleting out-of-date property: " + prop.InnerText);
                CommandUtils.RunAndLog("ectool", string.Format("--timeout 900 deleteProperty --propertyName \"/projects/GUBP_V5/Generated/Utilization/{0}\"", prop.InnerText), Options: Opts);
            }
        }
        // add today's
        Log("Adding report: " + Day.Subtract(new TimeSpan(1, 0, 0, 0)).ToString("yyyy-MM-dd") + "->" + Day.ToString("yyyy-MM-dd"));
        CommandUtils.RunAndLog("ectool", string.Format("--timeout 900 setProperty \"/projects/GUBP_V5/Generated/Utilization/Report_{0}\" --valueFile {1}", Day.Subtract(new TimeSpan(1, 0, 0, 0)).ToString("yyyy-MM-dd"), FileName), Options: Opts);
    }