def kill_process(self): """ Verifica si existe una simulacion corriendo y termina el proceso """ if self.thread_runSimulation: self.current_pid = self.thread_runSimulation.get_pid() + 2 if self.current_pid != -1: self.process_killed = True errorlog_path = os.path.join(SIMULATOR_PATH,"error.log") if 'linux' in platform: command = "kill -KILL %s 2> %s"%(self.current_pid,errorlog_path) elif 'win' in platform: command_kill = "taskkill /F /IM exec.exe" execwfile = os.path.join(SIMULATOR_PATH,"execw_k.bat") command = "echo %s > %s"%(command_kill,execwfile) os.system(command) command = os.path.join(SIMULATOR_PATH,"execw_k.bat") p = subprocess.Popen([command],shell=True) p.wait() if not show_errors(SIMULATOR_PATH): show_message('Process Killed', 1) QtWidgets.QApplication.processEvents() self.reset_pid() else: show_message('Cannot find the pid simulation. Please report this bug to the developer.') else: show_message('There is no simulation running now') return
def success_simulation(self): if not show_errors(SIMULATOR_PATH) and not self.process_killed: show_message('Simulation Finished', 1) msg = "Do you want to generate the default Post Process?" reply = show_message(msg,4,QtWidgets.QMessageBox.Yes|QtWidgets.QMessageBox.No) if reply == QtWidgets.QMessageBox.Yes: self.plot_defaultPostProcess_after_run_f() self.process_killed = False return
def submit(user): try: score_ = submit_score(request.form.to_dict()) except MultipleInvalid as e: return show_errors(e) score = Score(value=score_['score'], user=user) score.save() return {"success": True}
def authenticate(): common_error = { "non_field_errors": ["Pair user-password doesn't exist"] } data = request.form.to_dict() try: _user = user_auth(data) except MultipleInvalid as e: return show_errors(e) try: user = User.objects.get(username=_user['username']) except User.DoesNotExist: return common_error, 400 if not user.check_password(_user['password']): return common_error, 400 if user.auth_token is None: user.bind_token() return { "token": user.auth_token }
def create(): data = request.form.to_dict() try: _user = user_creation(data) if _user['password1'] != _user['password2']: raise MultipleInvalid(errors=[ Invalid( message="Passwords doesn't match", path=["password1", "password2"]) ]) except MultipleInvalid as e: return show_errors(e) User.ensure_indexes() user = User(username=_user['username']) user.set_password(_user['password1']) try: user.save() except NotUniqueError as e: return { "path": ["username"], "errors": "user with same name exist" }, 400 return {"success": True}