Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -413,35 +413,39 @@ async def join(websocket, key):
|
|
| 413 |
# Register to receive moves from this game.
|
| 414 |
connected.add(websocket)
|
| 415 |
try:
|
| 416 |
-
base_path = os.path.join(os.getcwd(), 'projects', key,'your_project_name')
|
| 417 |
-
mod_command = f'cd {base_path} && ls'
|
| 418 |
-
process = await asyncio.create_subprocess_shell(
|
| 419 |
-
|
| 420 |
-
|
| 421 |
-
|
| 422 |
-
|
| 423 |
-
|
| 424 |
-
|
| 425 |
-
)
|
| 426 |
-
project_name = []
|
| 427 |
-
async for line in process.stdout:
|
| 428 |
-
|
| 429 |
-
|
| 430 |
-
return_code = await process.wait()
|
| 431 |
|
| 432 |
-
current_directory = f'projects/{key}/your_project_name/{project_name[0]}'
|
| 433 |
-
print(current_directory)
|
| 434 |
-
print("printed") # Send the first move, in case the first player already played it.
|
| 435 |
-
file_structure = await generate_file_structure(current_directory)
|
| 436 |
-
# Receive and process moves from the second player.
|
| 437 |
-
event = {
|
| 438 |
-
|
| 439 |
-
|
| 440 |
|
| 441 |
-
}
|
| 442 |
-
print('in join')
|
| 443 |
-
print(event)
|
| 444 |
-
await websocket.send(json.dumps(event))
|
|
|
|
|
|
|
|
|
|
|
|
|
| 445 |
await exe(websocket,connected,key)
|
| 446 |
finally:
|
| 447 |
connected.remove(websocket)
|
|
|
|
| 413 |
# Register to receive moves from this game.
|
| 414 |
connected.add(websocket)
|
| 415 |
try:
|
| 416 |
+
# base_path = os.path.join(os.getcwd(), 'projects', key,'your_project_name')
|
| 417 |
+
# mod_command = f'cd {base_path} && ls'
|
| 418 |
+
# process = await asyncio.create_subprocess_shell(
|
| 419 |
+
# mod_command,
|
| 420 |
+
# # cwd=base_path,
|
| 421 |
+
# stdin=asyncio.subprocess.PIPE,
|
| 422 |
+
# stdout=asyncio.subprocess.PIPE,
|
| 423 |
+
# stderr=asyncio.subprocess.PIPE,
|
| 424 |
+
# # text=True,
|
| 425 |
+
# )
|
| 426 |
+
# project_name = []
|
| 427 |
+
# async for line in process.stdout:
|
| 428 |
+
# project_name.append(line.strip().decode('utf-8'))
|
| 429 |
+
|
| 430 |
+
# return_code = await process.wait()
|
| 431 |
|
| 432 |
+
# current_directory = f'projects/{key}/your_project_name/{project_name[0]}'
|
| 433 |
+
# print(current_directory)
|
| 434 |
+
# print("printed") # Send the first move, in case the first player already played it.
|
| 435 |
+
# file_structure = await generate_file_structure(current_directory)
|
| 436 |
+
# # Receive and process moves from the second player.
|
| 437 |
+
# event = {
|
| 438 |
+
# "type": "join",
|
| 439 |
+
# "file_structure": json.dumps(file_structure),
|
| 440 |
|
| 441 |
+
# }
|
| 442 |
+
# print('in join')
|
| 443 |
+
# print(event)
|
| 444 |
+
# await websocket.send(json.dumps(event))
|
| 445 |
+
event = {
|
| 446 |
+
"type": "sendDir",
|
| 447 |
+
}
|
| 448 |
+
websockets.broadcast(connected,json.dumps(event))
|
| 449 |
await exe(websocket,connected,key)
|
| 450 |
finally:
|
| 451 |
connected.remove(websocket)
|