def __shutdown_server(): print_.info('INFO', 'Shutting Down Server') response = requests.get(f'{ENDPOINT}/shutdown').json() if response['code'] == 200: return 1, 1 else: return 0, 1
def change_state(self, change_to): ''' Changes the state of the observation based on the approved parameter\n approved=True => approved \n approved=False => denyed ''' if self.state != change_to: self.state = change_to colored_state = f'{Fore.CYAN}\'{self.state.value}\'{Fore.RESET}' info(f'OBSER', f'{self._id} state changed to {colored_state}')
def stop_timer(time_start, description=None): ''' Calculates the elapsed time between the actual time and the passed time, prints the information, and returns the elapsed time ''' time_stop = __get_time_in_ns() elapsed = round(time_stop - time_start) if description: print_.info('INFO', f'{elapsed} ns in {description}') return elapsed
def start_server(app, no_stdout, condition=None, host='localhost', port=5000): ''' Starts the application passed as parameter ''' __custom_configuration(app, no_stdout) print_.title("Launching Modules") for module in karmaserver.modules.get_all_modules(): app.register_blueprint(module) print_.title("Starting Server") print_.info('INFO', f'Starting Server at {host}:{port}') if condition: condition.notify() condition.release() app.run(host=host, port=port)
def runtests(): ''' Runs all the configured tests ''' if check_if_server_up('localhost', 5000): print_.info('INFO', 'Server Already Up') result = karmaserver.tests.run_all_tests() else: # condition = threading.Condition() thread = ThreadWithReturnValue(target=__call_tests, args=(None, )) thread.start() # condition.acquire() runserver(no_stdout=True, condition=None) result = thread.join() if result: sys.exit(0) else: sys.exit(-1)
def initdb(): """Initializes the database.""" db.create_all() print_.info('INFO', 'Database Created')