Created
March 29, 2016 06:25
-
-
Save jainmickey/51893a94112154e4460c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Displays all current connections | |
def list_connections(): | |
db = sqlite3.connect(r'C:\Users\Administrator\Desktop\Raspi\mysite\newdb.db') | |
cursor = db.cursor() | |
results = '' | |
messages = [] | |
for i, conn in enumerate(all_connections): | |
try: | |
conn.send(str.encode(' ')) | |
conn.recv(4096) | |
except: | |
cursor.execute('UPDATE connhistory SET status = "{0}", end_time = "{1}" W HERE ip = "{2}";'.format('InActive', str(datetime.datetime.now()), all_addresses[i][0 ])) | |
cursor.execute('') | |
db.commit() | |
del all_connections[i] | |
del all_addresses[i] | |
del all_names[i] | |
continue | |
results += str(i + 1) + '\t' + str(all_addresses[i][0]) + '\t' + str(all_name s[i]) + '\n' | |
cursor.execute('SELECT * FROM connhistory') | |
data = cursor.fetchall() | |
db.commit() | |
cursor.close() | |
db.close() | |
messages.append('------- Clients -------: {}'.format(str(results))) | |
return messages |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment