public IronPythonScript(string path) : base(path) { Runtime = new IronPythonRuntime(Name); Runtime.ExecuteFile(path); SupportedEvents = GetSupportedEvents(); SupportedMenus = GetSupportedMenus(); }
internal void ExecuteScriptAction(ScriptLanguage language, string script, Game game) { if (language == ScriptLanguage.PowerShell && !Scripting.PowerShell.PowerShellRuntime.IsInstalled) { throw new Exception(resources.GetString("LOCErrorPowerShellNotInstalled")); } logger.Info($"Executing script action in {language} runtime."); IScriptRuntime runtime = null; switch (language) { case ScriptLanguage.PowerShell: runtime = new Scripting.PowerShell.PowerShellRuntime(); break; case ScriptLanguage.IronPython: runtime = new Scripting.IronPython.IronPythonRuntime(); break; case ScriptLanguage.Batch: runtime = new Scripting.Batch.BatchRuntime(); break; } using (runtime) { var dir = game.ExpandVariables(game.InstallDirectory, true); if (!dir.IsNullOrEmpty() && Directory.Exists(dir)) { runtime.Execute(script, dir); } else { runtime.Execute(script); } } }
public IronPythonScript(string path) : base(path, ScriptLanguage.IronPython) { Runtime = new IronPythonRuntime(); Runtime.ExecuteFile(path); var attributes = Runtime.GetVariable("__attributes"); if (attributes != null) { Attributes = ((PythonDictionary)attributes).Cast <KeyValuePair <object, object> >().ToDictionary(a => a.Key.ToString(), b => b.Value.ToString()); } var exports = Runtime.GetVariable("__exports"); if (exports != null) { FunctionExports = new List <ScriptFunctionExport>(); var funcs = (IEnumerable <object>)exports; foreach (PythonDictionary func in funcs) { FunctionExports.Add(new ScriptFunctionExport(func["Name"].ToString(), func["Function"].ToString(), this)); } } }
public IronPythonScript(string path) : base(path) { Runtime = new IronPythonRuntime(); Runtime.ExecuteFile(path); }