Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -30,8 +30,17 @@ async def rename_item(websocket, project_name, path,new_name, connected):
|
|
30 |
os.rename(old_path, new_path)
|
31 |
|
32 |
websockets.broadcast(connected,'success')
|
|
|
|
|
|
|
|
|
|
|
33 |
else:
|
34 |
-
|
|
|
|
|
|
|
|
|
35 |
except Exception as e:
|
36 |
websockets.broadcast(connected,str(e))
|
37 |
|
@@ -51,10 +60,13 @@ async def delete_item(websocket, project_name, path, connected):
|
|
51 |
"data": item_path,
|
52 |
}
|
53 |
websockets.broadcast(connected,json.dumps(event))
|
54 |
-
websockets.broadcast(connected,'success')
|
55 |
else:
|
56 |
-
|
57 |
-
|
|
|
|
|
|
|
58 |
except Exception as e:
|
59 |
# print(e)
|
60 |
websockets.broadcast(connected,str(e))
|
@@ -135,23 +147,20 @@ async def execute_command(websocket, project_name, command, connected):
|
|
135 |
print(f'error:{line.strip()}')
|
136 |
event = {
|
137 |
"type": "terminal-error",
|
138 |
-
"data": line.strip(),
|
139 |
}
|
140 |
await send_message(event)
|
141 |
|
142 |
return_code = await process.wait()
|
143 |
if return_code == 0:
|
144 |
-
await send_message('Code executed successfully')
|
145 |
-
|
146 |
else:
|
147 |
-
await send_message(f'error:Execution failed with return code {return_code}')
|
|
|
148 |
|
149 |
-
# Send the command output to the client
|
150 |
-
# output, error = process.communicate()
|
151 |
-
# response = f"Command executed:\n\nOutput:\n{output.decode('utf-8')}\nError:\n{error.decode('utf-8')}"
|
152 |
-
# await websocket.send(response)
|
153 |
except Exception as e:
|
154 |
-
await websocket
|
155 |
|
156 |
async def create_file_structure(websocket, data, base_path='.'):
|
157 |
if data['type'] == 'folder':
|
|
|
30 |
os.rename(old_path, new_path)
|
31 |
|
32 |
websockets.broadcast(connected,'success')
|
33 |
+
event = {
|
34 |
+
"type": "rename-success",
|
35 |
+
"data": f'{old_path}-->{new_path}',
|
36 |
+
}
|
37 |
+
websockets.broadcast(connected,json.dumps(event))
|
38 |
else:
|
39 |
+
event = {
|
40 |
+
"type": "rename-failed",
|
41 |
+
"data": f'{old_path}-->{new_path} failed Item not found',
|
42 |
+
}
|
43 |
+
websockets.broadcast(connected,json.dumps(event))
|
44 |
except Exception as e:
|
45 |
websockets.broadcast(connected,str(e))
|
46 |
|
|
|
60 |
"data": item_path,
|
61 |
}
|
62 |
websockets.broadcast(connected,json.dumps(event))
|
63 |
+
# websockets.broadcast(connected,'success')
|
64 |
else:
|
65 |
+
event = {
|
66 |
+
"type": "delete-failed",
|
67 |
+
"data": f'{item_path} Item not found',
|
68 |
+
}
|
69 |
+
websockets.broadcast(connected,json.dumps(event))
|
70 |
except Exception as e:
|
71 |
# print(e)
|
72 |
websockets.broadcast(connected,str(e))
|
|
|
147 |
print(f'error:{line.strip()}')
|
148 |
event = {
|
149 |
"type": "terminal-error",
|
150 |
+
"data": line.strip().decode('utf-8'),
|
151 |
}
|
152 |
await send_message(event)
|
153 |
|
154 |
return_code = await process.wait()
|
155 |
if return_code == 0:
|
156 |
+
# await send_message('Code executed successfully')
|
157 |
+
pass
|
158 |
else:
|
159 |
+
# await send_message(f'error:Execution failed with return code {return_code}')
|
160 |
+
pass
|
161 |
|
|
|
|
|
|
|
|
|
162 |
except Exception as e:
|
163 |
+
await error(websocket, str(e))
|
164 |
|
165 |
async def create_file_structure(websocket, data, base_path='.'):
|
166 |
if data['type'] == 'folder':
|