void Worker_DoWork(object sender, DoWorkEventArgs e) { PythonInterface pi = new PythonInterface(); pi.GenerateNonUserData(ConstantValues.KEYBOARD_DATA_FILEPATH); pi.ProcessUserAndGeneratedData(ConstantValues.KEYBOARD_DATA_FILEPATH); pi.TeachModel("KNN", ConstantValues.KEYBOARD_DATA_FILEPATH); }
/// <summary> /// Handles when the user exits to the main menu (escape). /// </summary> private void HandleExit() { this.SetTimeScale(1.0f); this.UpdateBestTimes(); this.pythonInterface.HandleExit(); LevelManager.cachedPythonInterface = null; AutograderManager.ResetAutograder(); SceneManager.LoadScene(LevelCollection.MainMenuBuildIndex, LoadSceneMode.Single); }
int RunCommandHandler(string input) { /* * if (args.Length != 1) * { * return -1; * } */ PythonInterface.RunScript(input); return(0); }
//Load IO settings public void InitSettings() { this._ioManager = new IOManager(); //this._ioManager.ReInitSettings(); this._log = new Utils.Logger(); //Load sim settings this.simulationSettings = new SimulationSettings(); _log.PrintInit(simulationSettings.ToString()); Console.WriteLine("Loading settings"); this.simulationSettings = new SimulationSettings(this._ioManager.GetSettings()); //Load of python files _interfacePython = this._ioManager.LoadPythonModules(); }
private void Awake() { this.isValidRun = false; this.curCamera = 0; this.pythonInterface = new PythonInterface(this); this.Hud = this.transform.parent.GetComponentInChildren <Hud>(); // Find submodules this.Camera = this.GetComponent <CameraModule>(); this.Controller = this.GetComponent <Controller>(); this.Drive = this.GetComponent <Drive>(); this.Lidar = this.GetComponentInChildren <Lidar>(); this.Physics = this.GetComponent <PhysicsModule>(); }
private void Start() { this.FindKeyPoints(); this.SpawnPlayers(); // Depends on FindKeyPoints to find the start keypoint this.SetTimeScale(1.0f); // Depends on SpawnPlayers to create the screen manager switch (LevelManager.LevelManagerMode) { case LevelManagerMode.Exploration: if (LevelManager.LevelInfo.HelpMessage != null) { this.screenManager.ShowMessage(LevelManager.LevelInfo.HelpMessage, Color.white); } break; case LevelManagerMode.Autograder: this.autograderManager = GetComponentInChildren <AutograderManager>(); // First autograder trial for level: set build index, wait for user to start if (LevelManager.cachedPythonInterface == null) { LevelManager.autograderBuildIndex = LevelManager.LevelInfo.AutograderBuildIndex; AutograderManager.ResetAutograder(); this.screenManager.ShowMessage("To begin the autograder, connect a Python program and press START (or enter).", Color.white); } // Not the first autograder trial for level: load python interface from cache, automatically start else { this.pythonInterface = LevelManager.cachedPythonInterface; this.screenManager.UpdateConnectedPrograms(this.pythonInterface.ConnectedPrograms); this.HandleStart(); } break; case LevelManagerMode.Race: this.keyPointDurations = new float[this.keyPoints.Length]; this.screenManager.UpdateTime(0.0f, this.keyPointDurations); break; } if (this.pythonInterface == null) { this.pythonInterface = new PythonInterface(); this.screenManager.UpdateConnectedPrograms(this.pythonInterface.ConnectedPrograms); } }
private void TimerCountdown(object sender, EventArgs e) { string filepath = Path.Combine(ConstantValues.KEYBOARD_DATA_FILEPATH, ConstantValues.KEYBOARD_FILE_NAME); dataFormatter.RemoveLastDataItem(); List <KeysData> dataToWriteToFile = dataFormatter.DataRecorded; if (dataToWriteToFile.Count != 0) { PythonInterface pi = new PythonInterface(); List <string> formattedData = new List <string>(); foreach (KeysData keysData in dataToWriteToFile) { formattedData.Add(DataFormatter.GetFormattedDataLine(keysData)); } if (ModelFileExists()) { pi.TestUserInput(formattedData, health, ConstantValues.KEYBOARD_DATA_FILEPATH); } if (recordingEnabled.Checked) { WriteEncryptedDataToFile(filepath, dataToWriteToFile); } } PossiblyShuffleLines(filepath); if (health.GetValue() < ConstantValues.HEALTH_VALUE_THRESHOLD) { // Uncomment to lock user out of computer //Process.Start(@"C:\WINDOWS\system32\rundll32.exe", "user32.dll,LockWorkStation"); health.SetValue(ConstantValues.DEFAULT_HEALTH_VALUE); } dataFormatter.End(); }
public void GenerateNumber() { var rootPythonDir = Server.MapPath("../PyFiles/"); var pathToLib = Server.MapPath("../PyFiles/Lib"); var pathToPyFile = Server.MapPath("../PyFiles/twelve_version_for_iron_python.py"); DataAccess.PythonInterface IPyInterface = new PythonInterface(pathToLib, pathToPyFile); var lottery = "ozlotto"; var userid = 98765; var numberOfOdds = 3; var flag_for_odds = 0; var nb_less_15 = 0; var flag_for_15 = 0; var nb_middle = 0; var flag_middle = 0; var nb_bigger_30 = 0; var flag_for_30 = 0; List <double> score_range = new List <double> { 0.01, 0.03 }; var flag_for_score_range = 0; var prev_rep_numb = 0; var flag_for_prev_num = 0; var nb_to_inc = "45"; var nb_to_excl = "1"; var nb_of_games = 20; try { var result = IPyInterface.CallFunction("get_set", lottery, userid, numberOfOdds, flag_for_odds , nb_less_15, flag_for_15, nb_middle, flag_middle, nb_bigger_30, flag_for_30 , score_range, flag_for_score_range, prev_rep_numb, flag_for_prev_num , nb_to_inc, nb_to_excl, nb_of_games); } catch (Exception ex) { } }
public void Initialize(string[] args) { if (args.Length == 1 && args[0] == "/reset") { Properties.Settings.Default.Reset(); } m_baseServicesDispatcher = new BaseServicesDispatcher(); // Init mainwindow and display m_mainWindow = new MainWindow(this); m_paragraphContainer = new ParagraphContainer(); m_mainWindow.TextView.ParagraphContainer = m_paragraphContainer; ChiConsole.SetChiConsole(this); // Initialize ironpython IronPython.Compiler.Options.GenerateModulesAsSnippets = true; /* IronPython.Compiler.Options.GenerateDynamicMethods = false; * IronPython.Compiler.Options.DebugMode = true; * IronPython.Compiler.Options.EngineDebug = true; * IronPython.Compiler.Options.ILDebug = true; * IronPython.Compiler.Options.Frames = true; */ m_pythonEngine = new PythonEngine(); //m_pythonEngine.CreateModule("globals", true); ChiPythonStream s = new ChiPythonStream(); m_pythonEngine.SetStandardOutput(s); m_pythonEngine.SetStandardError(s); m_pythonEngine.SetStandardInput(s); m_pythonEngine.AddToPath(Application.StartupPath + "/lib"); #if DEBUG m_pythonEngine.AddToPath(@"../../../scripts/lib"); #endif m_pythonEngine.LoadAssembly(typeof(TriggerManager).Assembly); // load ChiropteraBase m_pythonEngine.LoadAssembly(typeof(System.Drawing.Bitmap).Assembly); // load System.Drawing m_pythonEngine.LoadAssembly(typeof(System.Windows.Forms.Keys).Assembly); // load System.Windows.Forms // Network m_telnet = new Telnet(); m_telnet.connectEvent += new Telnet.ConnectDelegate(_ConnectEvent); m_telnet.disconnectEvent += new Telnet.DisconnectDelegate(_DisconnectEvent); m_telnet.receiveEvent += new Telnet.ReceiveDelegate(_ReceiveEvent); m_telnet.promptEvent += new Telnet.PromptDelegate(_PromptEvent); m_telnet.telnetEvent += new Telnet.TelnetDelegate(_TelnetEvent); m_commandManager = new CommandManager(m_baseServicesDispatcher); AddBuiltinCommands(); m_triggerManager = new TriggerManager(m_baseServicesDispatcher); m_triggerManager.SetTriggers(Properties.Settings.Default.Triggers); m_hiliteManager = new HiliteManager(m_triggerManager); m_keyManager = new KeyManager(m_baseServicesDispatcher); m_keyManager.SetKeyBindings(Properties.Settings.Default.KeyBindings); PythonInterface.Initialize(m_baseServicesDispatcher, m_triggerManager, m_commandManager, this, this, m_pythonEngine, m_keyManager, m_hiliteManager); try { #if DEBUG PythonInterface.RunScript(Path.GetFullPath("../../../scripts/std/init_std.bc")); #else PythonInterface.RunScript(Path.Combine(Environment.CurrentDirectory, "std/init_std.bc")); #endif } catch (Exception e) { ChiConsole.WriteError("Error running init_std.bc", e); } try { string userScript = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "Chiroptera/init.bc"); if (File.Exists(userScript)) { PythonInterface.RunScript(userScript); } } catch (Exception e) { ChiConsole.WriteError("Error running init.bc", e); } Version currentVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version; Version baseVersion = System.Reflection.Assembly.GetAssembly(typeof(Telnet)).GetName().Version; ChiConsole.WriteLine("Chiroptera version {0} (base {1})", currentVersion.ToString(2), baseVersion.ToString(2)); ChiConsole.WriteLine("Using {0}", PythonEngine.VersionString); CheckClientVersion(); }
public ClientCore() { s_clientCore = this; //Ansi.SendAnsiInit(); m_synchronizedInvoke = new SynchronizedInvoke(); // Services m_baseServicesDispatcher = new BaseServicesDispatcher(); // Init console m_textConsole = new TextConsole(); ChiConsole.SetChiConsole(m_textConsole); // Initialize ironpython IronPython.Compiler.Options.GenerateModulesAsSnippets = true; m_pythonEngine = new PythonEngine(); ChiPythonStream s = new ChiPythonStream(); m_pythonEngine.SetStandardOutput(s); m_pythonEngine.SetStandardError(s); m_pythonEngine.SetStandardInput(s); //m_pythonEngine.AddToPath(Environment.CurrentDirectory); //m_pythonEngine.AddToPath(Application.StartupPath + "/lib"); #if DEBUG m_pythonEngine.AddToPath(@"../../../scripts/lib"); #endif m_pythonEngine.LoadAssembly(typeof(TriggerManager).Assembly); // load BatClientBase m_pythonEngine.LoadAssembly(typeof(System.Drawing.Bitmap).Assembly); // load System.Drawing m_pythonEngine.LoadAssembly(typeof(System.Windows.Forms.Keys).Assembly); // load System.Windows.Forms // Network m_telnet = new Telnet(); m_telnet.connectEvent += new Telnet.ConnectDelegate(_ConnectEvent); m_telnet.disconnectEvent += new Telnet.DisconnectDelegate(_DisconnectEvent); m_telnet.receiveEvent += new Telnet.ReceiveDelegate(_ReceiveEvent); m_telnet.promptEvent += new Telnet.PromptDelegate(_PromptEvent); m_telnet.telnetEvent += new Telnet.TelnetDelegate(_TelnetEvent); m_netPipe = UnixPipes.CreatePipes(); m_commandManager = new CommandManager(m_baseServicesDispatcher); AddBuiltinCommands(); m_triggerManager = new TriggerManager(m_baseServicesDispatcher); m_keyManager = new KeyManager(m_baseServicesDispatcher); m_hiliteManager = new HiliteManager(m_triggerManager); PythonInterface.Initialize(m_baseServicesDispatcher, m_triggerManager, m_commandManager, this, m_textConsole, m_pythonEngine, m_keyManager, m_hiliteManager); // run init script Version currentVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version; Version baseVersion = System.Reflection.Assembly.GetAssembly(typeof(Telnet)).GetName().Version; ChiConsole.WriteLine("Chiroptera version {0} (base {1})", currentVersion.ToString(2), baseVersion.ToString(2)); ChiConsole.WriteLine("Using {0}", PythonEngine.VersionString); try { #if DEBUG PythonInterface.RunScript(Path.GetFullPath("../../../scripts/std/init_std.bc")); #else PythonInterface.RunScript(Path.Combine(Environment.CurrentDirectory, "std/init_std.bc")); #endif } catch (Exception e) { ChiConsole.WriteError("Error running init_std.bc", e); } /* * m_pythonEngine.Import("site"); * * try * { * m_pythonEngine.ExecuteFile("init.py"); * } * catch (Exception e) * { * ChiConsole.WriteError("Eval failed", e); * } */ }