Skip to content

Commit 2bf6e2c

Browse files
committed
Improved list_connections
1 parent 14198ad commit 2bf6e2c

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

server.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -160,23 +160,23 @@ def refresh_connections(): # used to remove any lost connections
160160
def list_connections():
161161
refresh_connections()
162162

163-
if len(arrConnections) > 0:
164-
strClients = ""
165-
166-
for intCounter, _ in enumerate(arrConnections):
167-
168-
strClients += str(intCounter) + 4*" " + str(arrAddresses[intCounter][0]) + 4*" " + \
169-
str(arrAddresses[intCounter][1]) + 4*" " + str(arrAddresses[intCounter][2]) + 4*" " + \
170-
str(arrAddresses[intCounter][3]) + "\n"
171-
172-
strInfo = f"\nID{3*' '}"
173-
for index, text in enumerate(["IP", "Port", "PC Name", "OS"]):
174-
strInfo += center(str(arrAddresses[0][index]), text) + 4*" "
175-
strInfo += f"\n{strClients}"
176-
print(strInfo, end='')
177-
else:
163+
if not len(arrConnections) > 0:
178164
print("No connections.")
165+
return
179166

167+
strClients = ""
168+
for intCounter, arrAddress in enumerate(arrAddresses):
169+
strClients += str(intCounter)
170+
for value in arrAddress:
171+
strClients += f"{4*' '}{str(value)}"
172+
strClients += "\n"
173+
174+
strInfo = f"\nID{3*' '}"
175+
for index, text in enumerate(["IP", "Port", "PC Name", "OS"]):
176+
strInfo += center(str(arrAddresses[0][index]), text) + 4*" "
177+
strInfo += f"\n{strClients}"
178+
print(strInfo, end='')
179+
180180

181181
def select_connection(connection_id, blnGetResponse):
182182
global conn, arrInfo

0 commit comments

Comments
 (0)