def main(): action = input('何をしますか?\n1: 読み込み\n2: 書き込み\n3: 削除\n') sock = Client(("localhost", 50000)) if action == Action.WRITE.value: handle_name = input('handle_name: ') content = input('content: ') password = getpass('password: '******'書き込みに失敗しました。') else: print('書き込みに成功しました。') elif action == Action.READ.value: body = Body(action=Action.READ.value) sock.send_body(body) response = sock.recv_response() if response.state == State.FAILED.value: print('受信に失敗しました。') for message in response.messages: print('--------------------') print(f"ID: {message.id}") print(f"TIME: {message.time}") print(f"HANDLE NAME: {message.handle_name}") print(f"CONTENT: {message.content}") elif action == Action.DELETE.value: identify = input('id: ') password = getpass('password: '******'IDもしくはPASSWORDが間違っています。') else: print('削除に成功しました。') else: pass
def main(): sock = Client(("localhost", 50000)) p_read = Process(target=read, args=(sock, )) p_read.daemon = True p_read.start() write(sock) print("通信を終了しました")
def on_auth(self, req, u_name): """Authentication routine""" url_to_redirect = self.app.url_for(req, '/main') response = self.app.redirect(url_to_redirect) session_token = derive_token() self.sessions.add(session_token) response.set_cookie('session', session_token) client = Client(u_name, self.server_dir) self.current_users[session_token] = client return response
import os from util import Client # when running the agent locally, assume that the environment is accesible at localhost:5000 # when running a containerised agent, assume that the environment is accesible at $RANGL_ENVIRONMENT_URL (typically http://environment:5000) remote_base = os.getenv("RANGL_ENVIRONMENT_URL", "http://localhost:5000/") client = Client(remote_base) env_id = "reference-environment-v0" seed = int(os.getenv("RANGL_SEED", 123456)) instance_id = client.env_create(env_id, seed) client.env_monitor_start( instance_id, directory=f"monitor/{instance_id}", force=True, resume=False, video_callable=False, ) client.env_reset(instance_id) while True: action = client.env_action_space_sample(instance_id) observation, reward, done, info = client.env_step(instance_id, action) print(instance_id, reward) if done: print(instance_id) break
import unittest import json import uuid from util import Client client = Client('localhost', '8080') class BaseTest(unittest.TestCase): GAME_NAME = 'test-game' PLAYER_USERNAME = '******' @property def client(self): return client def randomString(self): return str(uuid.uuid4()) def setUp(self): self.player_count = 0 self.delete_test_game() self.delete_test_players() def tearDown(self): self.player_count = 0 self.delete_test_game() self.delete_test_players()