Ejemplo n.º 1
0
 private void Start()
 {
     rs     = FindObjectOfType <RunScript>();
     anim   = GetComponent <Animator>();
     mv     = FindObjectOfType <MusicVolume>();
     mv.ded = false;
 }
Ejemplo n.º 2
0
 void MakeInstance()
 {
     if (instance == null)
     {
         instance = this;
     }
 }
Ejemplo n.º 3
0
 public Script(HotKey hotKey, RunScript run, string name, bool enabled, ScriptOrigins scriptOrigin)
 {
     HotKey       = hotKey;
     Run          = run;
     Name         = name;
     Enabled      = enabled;
     ScriptOrigin = scriptOrigin;
 }
        public async Task RunAsync()
        {
            RunScript scriptRunner = new RunScript();
            Dictionary <string, object> parameterList = new Dictionary <string, object>();

            parameterList.Add("UbuntuTestVm", "start");
            string scriptText = System.IO.File.ReadAllText(@"C:\Users\stian\Documents\Bachelor\. WEB PLATFORM\CyberRange\CyberRangeProject\Powershell\Start-Stop-Restart-SingleVm-using-args.ps1");
            await scriptRunner.Run(scriptText, parameterList);
        }
Ejemplo n.º 5
0
        public DelegateBrowserForm()
        {
            wb = new WebBrowser();

            CheckDelegate = new CheckValue(this.CheckValueMethod);
            SetDelegate = new SetValue(this.SetValueMethod);
            SubmitDelegate = new SubmitForm(this.SubmitFormMethod);
            ScriptDelegate = new RunScript(this.RunScriptMethod);
            UrlDelegate = new GetUrl(this.GetUrlMethod);
        }
Ejemplo n.º 6
0
 // Start is called before the first frame update
 void Start()
 {
     rb           = GetComponent <Rigidbody2D>();
     kitchenTable = FindObjectOfType <KitchenTableScript>();
     tableScript  = FindObjectOfType <TableScript>();
     runScript    = FindObjectOfType <RunScript>();
     source       = GetComponent <AudioSource>();
     source.clip  = throwSound;
     runScript.SetMaxRun(100f);
 }
Ejemplo n.º 7
0
        public DelegateBrowserForm()
        {
            wb = new WebBrowser();

            CheckDelegate  = new CheckValue(this.CheckValueMethod);
            SetDelegate    = new SetValue(this.SetValueMethod);
            SubmitDelegate = new SubmitForm(this.SubmitFormMethod);
            ScriptDelegate = new RunScript(this.RunScriptMethod);
            UrlDelegate    = new GetUrl(this.GetUrlMethod);
        }
        protected override void DoCommandAction()
        {
            string familyScript = Program.AssemblyDirectory + Path.DirectorySeparatorChar + FPGA.FPGA.Instance.Family + ".goa";

            if (File.Exists(familyScript))
            {
                OutputManager.WriteOutput("Reading hook script " + familyScript);
                RunScript runCmd = new RunScript();
                runCmd.FileName = familyScript;
                CommandExecuter.Instance.Execute(runCmd);
            }
        }
Ejemplo n.º 9
0
        public void Startup(ConfigurationLoader loader)
        {
            m_Loader = loader;
            loader.GetService(m_AssetServiceName, out m_AssetService);
            m_TestRunner = m_Loader.GetServicesByValue <TestRunner>()[0];
            List <RunScript> scriptrunners = m_Loader.GetServicesByValue <RunScript>();

            if (scriptrunners.Count > 0)
            {
                m_ScriptRunner = scriptrunners[0];
            }
        }
Ejemplo n.º 10
0
        private void ConfigureRunCommand()
        {
            RunScript = RunScriptCommand(deployer, filePicker);

            RunScript
            .OnSuccess(
                () => dialogService.Notice("Execution finished", "The script has been executed successfully"))
            .DisposeWith(disposables);

            dialogService.HandleExceptionsFromCommand(RunScript,
                                                      exception => ("Script execution failed", exception.Message));
        }
Ejemplo n.º 11
0
    public void ProcessCommand(string val, IYnote ynote)
    {
        var edit = ynote.Panel.ActiveDocument as Editor;
        var item = RunScript.Get(GlobalSettings.SettingsDir + @"RunScripts\" + val + ".ynoterun");

        if (item == null)
        {
            return;
        }
        if (edit != null) // item.ProcessConfiguration(edit.Name);
        {
            item.Run();
        }
    }
Ejemplo n.º 12
0
        private void m_menuCommandsRunScript_Click(object sender, EventArgs e)
        {
            string caller = "m_menuCommandsRunScript_Click";

            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Title           = "Select a Script File";
            openFileDialog.Multiselect     = false;
            openFileDialog.CheckFileExists = true;
            openFileDialog.Filter          = "TCL Script File|*.tcl|GoAhead Script File|*.goa";

            if (StoredPreferences.Instance.FileDialogSettings.HasSetting(caller))
            {
                openFileDialog.InitialDirectory = StoredPreferences.Instance.FileDialogSettings.GetSetting(caller);
            }

            // cancel
            if (openFileDialog.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            if (string.IsNullOrEmpty(openFileDialog.FileName))
            {
                return;
            }

            // store last user path
            StoredPreferences.Instance.FileDialogSettings.AddOrUpdateSetting(caller, Path.GetDirectoryName(openFileDialog.FileName));

            if (openFileDialog.FileName.EndsWith(".goa"))
            {
                RunScript cmd = new RunScript();
                cmd.FileName = openFileDialog.FileName;

                CommandExecuter.Instance.Execute(cmd);
            }
            else
            {
                string script = File.ReadAllText(openFileDialog.FileName);
                int    r      = Program.mainInterpreter.EvalScript(script);
                if (r != 0)
                {
                    Console.WriteLine("Error while executing TCL script: " + Program.mainInterpreter.Result);
                }
            }

            Invalidate();
        }
        public ScriptRunService()
        {
            InitializeComponent();
            eventLog1 = new EventLog();
            if (!EventLog.SourceExists("MySource"))
            {
                EventLog.CreateEventSource(
                    "MySource", "MyNewLog");
            }
            eventLog1.Source = "MySource";
            eventLog1.Log    = "MyNewLog";
            var runMyScript = new RunScript();
            var output      = runMyScript.Start();

            eventLog1.WriteEntry(output.ToString(), EventLogEntryType.Information);
        }
Ejemplo n.º 14
0
        public ICommand ResolveCommand(JObject joCommand)
        {
            ICommand result = null;

            var commandName = JSONUtil.GetCommandName(joCommand);

            if (commandName == null)
            {
                return(null);
            }
            if (commandName == "load-json")
            {
                result = new LoadJSON();
            }
            else if (commandName == "save-json")
            {
                result = new SaveJSON();
            }
            else if (commandName == "prompt")
            {
                result = new PromptCommand();
            }
            else if (commandName == "run-script")
            {
                result = new RunScript();
            }
            else if (commandName == "communicate")
            {
                result = new Communicate();
            }
            else if (commandName == "say")
            {
                result = new Communicate();
            }
            //else if (commandName == "run-rules") { return new RunRules(); }
            else if (commandName == "assert")
            {
                return(new Assert());
            }
            else if (commandName == "store")
            {
                return(new Store());
            }

            return(result);
        }
Ejemplo n.º 15
0
        private void m_txtInput_DragDrop(object sender, DragEventArgs e)
        {
            if (e.Data.GetDataPresent(DataFormats.FileDrop))
            {
                string[] files = (string[])e.Data.GetData(DataFormats.FileDrop, false);

                foreach (string file in files)
                {
                    string extension = Path.GetExtension(file);
                    if (extension.Equals(".binFPGA"))
                    {
                        OpenBinFPGA openCmd = new OpenBinFPGA();
                        openCmd.FileName      = file;
                        openCmd.PrintProgress = true;
                        CommandExecuter.Instance.Execute(openCmd);
                    }
                    else if (extension.Equals(".goa"))
                    {
                        RunScript runCmd = new RunScript();
                        runCmd.FileName      = file;
                        runCmd.PrintProgress = true;
                        CommandExecuter.Instance.Execute(runCmd);
                    }
                    else if (extension.Equals(".xdl"))
                    {
                        ReadXDL readXDLCmd = new ReadXDL();
                        readXDLCmd.FileName      = file;
                        readXDLCmd.PrintProgress = true;
                        CommandExecuter.Instance.Execute(readXDLCmd);
                    }
                    else if (extension.Equals(".viv_rpt"))
                    {
                        ReadVivadoFPGA readVivadoReportCmd = new ReadVivadoFPGA();
                        readVivadoReportCmd.FileName      = file;
                        readVivadoReportCmd.PrintProgress = true;
                        CommandExecuter.Instance.Execute(readVivadoReportCmd);
                    }
                    else
                    {
                        MessageBox.Show("Unknown file extensions " + extension + " found. Other files are skipped. GoAhead suppors Drag&Drop of .binFPGA and .goa files", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                }
            }
        }
Ejemplo n.º 16
0
    // Start is called before the first frame update
    void Awake()
    {
        stamina             = GetComponent <IEstaminable>();
        adrenalina          = GetComponent <IAdrenalinable>();
        characterController = GetComponent <CharacterController>();
        startColor          = spriteRenderer.color;
        speed = normalSpeed;

        punch                = children.GetComponent <PunchScript>();
        punchFly             = children.GetComponent <PunchFly>();
        adrenalinaPunch      = children.GetComponent <AdrenalinaPunch>();
        aereoPunch           = children.GetComponent <AereoPunchScript>();
        adrenalinaAereoPunch = children.GetComponent <AdrenalinaAereoPunch>();

        punchScript        = punch.GetComponent <PunchScript>();
        moveScript         = moving.GetComponent <MoveScript>();
        runScript          = run.GetComponent <RunScript>();
        punchRunningScript = punchRunning.GetComponent <PunchRunning>();
        punchFlyScript     = punchFly.GetComponent <PunchFly>();

        adrenalinaRunScript = adrenalinaRun.GetComponent <AdrenalinaRun>();

        ChangeState(State.MOVING);
    }
Ejemplo n.º 17
0
 // Start is called before the first frame update
 void Awake()
 {
     characterController = GetComponent <CharacterController>();
     run = GetComponent <RunScript>();
 }
Ejemplo n.º 18
0
        static void Main(string[] args)
        {
            var runMyScript = new RunScript();

            Console.WriteLine(runMyScript.Start());
        }
Ejemplo n.º 19
0
        public object Any(RunScript request)
        {
            if (request.ScriptId == null)
            {
                throw new ArgumentException("ScriptId");
            }

            AppData.AssertNoIllegalTokens(request.MainSource);
            AppData.AssertNoIllegalTokens(request.Sources.ToArray());

            var result = new ScriptExecutionResult();

            var existingUserScripts = GetExistingActiveUserScripts();

            var runnerInfo = LocalCache.GetScriptRunnerInfo(request.ScriptId);

            //stop script if run
            if (runnerInfo?.ScriptDomain != null)
            {
                var scriptStatus = runnerInfo.DomainWrapper.GetScriptStatus();

                if (request.ForceRun || scriptStatus != ScriptStatus.PrepareToRun && scriptStatus != ScriptStatus.Running)
                {
                    Cancel(runnerInfo);
                }
                else
                {
                    result.Status = ScriptStatus.AnotherScriptExecuting;
                    return(new RunScriptResponse
                    {
                        Result = result
                    });
                }
            }

            List <AssemblyReference> normalizedReferences;
            var addedReferences = AddReferencesFromPackages(request.References, request.PackagesConfig, out normalizedReferences);

            var evidence = new Evidence(AppDomain.CurrentDomain.Evidence);
            var setup    = new AppDomainSetup
            {
                PrivateBinPath  = Path.Combine(VirtualFiles.RootDirectory.RealPath, "bin"),
                ApplicationBase = VirtualFiles.RootDirectory.RealPath
            };

            var domain = AppDomain.CreateDomain(Guid.NewGuid().ToString(), evidence, setup);

            var asm  = typeof(DomainWrapper).Assembly.FullName;
            var type = typeof(DomainWrapper).FullName;

            var wrapper = (DomainWrapper)domain.CreateInstanceAndUnwrap(asm, type);

            wrapper.ScriptId = request.ScriptId;
            var writerProxy = new NotifierProxy(ServerEvents, request.ScriptId);

            result = wrapper.RunAsync(request.MainSource, request.Sources, addedReferences.Select(r => r.Path).ToList(), writerProxy);

            LocalCache.SetScriptRunnerInfo(request.ScriptId, new ScriptRunnerInfo
            {
                ScriptId      = request.ScriptId,
                SessionId     = base.Request.GetPermanentSessionId(),
                CreatedDate   = DateTime.UtcNow,
                ScriptDomain  = domain,
                DomainWrapper = wrapper,
            });

            var unloadOldUserScripts = existingUserScripts
                                       .Where(x => x.ScriptId != request.ScriptId && DateTime.UtcNow - x.CreatedDate > TimeSpan.FromMinutes(1));

            var scriptsRemoved = UnloadExistingScripts(unloadOldUserScripts);

            return(new RunScriptResponse
            {
                Result = result,
                References = normalizedReferences,
                ScriptsRemoved = scriptsRemoved,
            });
        }
Ejemplo n.º 20
0
        public static void AddScript(string id, string name, HotKey key, bool enabled, ScriptOrigins origin, RunScript run)
        {
            Script s = new Script(key, run, name, enabled, origin);

            MainFormRef.OverviewContainer.SideBarContainer.AddScriptDescription(name + ": " + key.GetString());
            MainFormRef.ScriptContainer.AddScript(s);

            LoadedScripts.Add(id, s);
        }
Ejemplo n.º 21
0
 public RunScriptTests()
 {
     _loggingService = new FakeLoggingService();
     _runScript      = new RunScript(_loggingService);
 }
Ejemplo n.º 22
0
        static void Main(string[] args)
        {
            // TCL API init
            //TclAPI.Initialize();
            mainInterpreter = new TclInterpreter();
            unsafe
            {
                ExecuteGOAcmd = TclProcs.ExecuteGOACommand;
                TclDLL.Helper_RegisterProc(mainInterpreter.ptr, "cs", TclProcs.Cs);
                TclDLL.Helper_RegisterProc(mainInterpreter.ptr, "cshelp", TclProcs.CsHelp);
                TclDLL.Helper_RegisterProc(mainInterpreter.ptr, "cslist", TclProcs.CsList);
                TclDLL.Helper_RegisterProc(mainInterpreter.ptr, "clear", TclProcs.Clear);
                TclDLL.Helper_RegisterProc(mainInterpreter.ptr, "clearcontext", TclProcs.ClearContext);
                //TclDLL.Helper_RegisterProc(mainInterpreter.ptr, "test", TclProcs.Test);
            }
            //int rc = mainInterpreter.EvalScript("puts [testproc Tile]");
            //Console.WriteLine("rc=" + rc + " Interp.Result = " + mainInterpreter.Result);

            // restore settings
            StoredPreferences.LoadPrefernces();

            // check vars
            StringBuilder errorList;

            if (!EnvChecker.CheckEnv(out errorList))
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine(errorList.ToString());
                Console.ResetColor();
            }

            // detect commands without default constructor
            foreach (Type type in CommandStringParser.GetAllCommandTypes())
            {
                try
                {
                    Command cmd = (Command)Activator.CreateInstance(type);
                    TclDLL.Helper_RegisterProc(mainInterpreter.ptr, type.Name, ExecuteGOAcmd);
                    unsafe
                    {
                        //string[] parts = cmd.ToString().Split(' ');
                        //if (parts[0].EndsWith(";")) parts[0] = parts[0].Substring(0, parts[0].Length - 1);
                        TclDLL.Helper_RegisterProc(mainInterpreter.ptr, type.Name, ExecuteGOAcmd);
                    }
                }
                catch (Exception)
                {
                    Console.ForegroundColor = ConsoleColor.Yellow;
                    Console.WriteLine("Warning: No default constructor found for command " + type.Name);
                    Console.ResetColor();
                }
            }



            // register console hook
            // first hook print progress to clean the % output
            CommandExecuter.Instance.AddHook(new PrintProgressToConsoleHook());
            // the profiling hook must be added before the output hook hooks as it produces output
            CommandExecuter.Instance.AddHook(new ProfilingHook());
            CommandExecuter.Instance.AddHook(new ConsoleCommandHook());
            CommandExecuter.Instance.AddHook(new PrintOutputHook());

            // check if init.goa is found in binary of the current assembly
            string dir      = AssemblyDirectory;
            string initFile = dir + Path.DirectorySeparatorChar + "init.goa";

            // if so, execute init.goa
            if (File.Exists(initFile))
            {
                RunScript runInitCmd = new RunScript();
                runInitCmd.FileName = initFile;
                CommandExecuter.Instance.Execute(runInitCmd);
                //FileInfo fi = new FileInfo(initFile);
                //CommandExecuter.Instance.Execute(fi);
            }
            else
            {
                Console.WriteLine("GoAhead did not find the init file: " + initFile);
            }

            bool   showGUIOnly = false;
            bool   execScript  = false;
            string scriptFile  = "";
            bool   shellMode   = false;
            bool   serverMode  = false;
            int    portNumber  = 0;
            bool   commandMode = false;

            if (args.Length == 0)
            {
                showGUIOnly = true;
            }
            else
            {
                int i = 0;
                while (i < args.Length)
                {
                    switch (args[i])
                    {
                    case "-gui":
                        showGUIOnly = true;
                        break;

                    case "-exec":
                        execScript = true;
                        scriptFile = GetScriptFileName(args, i + 1);
                        i++;
                        break;

                    case "-shell":
                        shellMode = true;
                        break;

                    case "-command":
                    case "-commands":
                        commandMode = true;
                        break;

                    case "-server":
                        portNumber = int.Parse(args[i + 1]);
                        i++;
                        break;

                    default:
                        if (args[i].EndsWith(".goa") && File.Exists(args[i]))
                        {
                            execScript = true;
                            scriptFile = GetScriptFileName(args, i);
                        }
                        break;
                    }
                    i++;
                }
            }
            if (showGUIOnly)
            {
                // open gui
                CommandExecuter.Instance.Execute(new Commands.GUI.ShowGUI());
            }
            else if (execScript)
            {
                if (!File.Exists(scriptFile))
                {
                    string errorMessage = "Error: File " + scriptFile + " not found";
                    // allow the test scripts to catch this string (goahead -exec script.goa | tee.goa)
                    Console.WriteLine(errorMessage);
                    throw new ArgumentException(errorMessage);
                }

                // command file mode
                FileInfo fi = new FileInfo(scriptFile);
                CommandExecuter.Instance.Execute(fi);
            }
            else if (shellMode)
            {
                Objects.CommandShell shell = new Objects.CommandShell();
                shell.Run();
            }
            else if (serverMode)
            {
                Objects.CommandServer server = new Objects.CommandServer();
                server.Run(portNumber);
            }
            else if (commandMode)
            {
                string cmdString = "";
                if (args.Length > 1)
                {
                    for (int i = 1; i < args.Length; i++)
                    {
                        cmdString += args[i] + " ";
                    }
                }
                if (string.IsNullOrEmpty(cmdString))
                {
                    Console.WriteLine("GoAhead was started with -commands, but no command was given");
                }
                Command             cmd;
                string              errorDescr;
                CommandStringParser parser = new CommandStringParser(cmdString);
                foreach (string subCommandString in parser.Parse())
                {
                    bool valid = parser.ParseCommand(subCommandString, true, out cmd, out errorDescr);
                    if (!valid)
                    {
                        Console.WriteLine(errorDescr);
                    }
                    CommandExecuter.Instance.Execute(cmd);
                }
            }
            else
            {
                Console.WriteLine("No switch found. Start GoAhead with one of the following options:");
                Console.WriteLine("GoAhead -gui             : Open GoAhead in GUI-Mode");
                Console.WriteLine("GoAhead -exec script.goa : Execute script.goa");
                Console.WriteLine("GoAhead script.goa       : Execute script.goa");
                Console.WriteLine("GoAhead -shell           : Start GoAhead shell (interactive Command mode)");
                Console.WriteLine("GoAhead -command(s)      : Execute GoAhead commands (e.g GoAhead -command \"FixS6XDLBug XDLInFile=in.xdl XDLOutFile=out.xdl;\"");
            }

            // save settings
            StoredPreferences.SavePrefernces();
        }
Ejemplo n.º 23
0
 private void toolStripButtonRun_Click(object sender, EventArgs e)
 {
     RunScript?.Invoke(this, new RunScriptEventArgs(textEditorControl.Text));
 }
Ejemplo n.º 24
0
 private void CreateVirtualMachine(string vmName, string hardDiskPath, string isoPath) =>
 RunScript(
     CreateVm,
     ("vmName", vmName),
     ("hardDiskPath", hardDiskPath),