Skip to content

Commit

Permalink
Improved display for showing blocked Devices
Browse files Browse the repository at this point in the history
  • Loading branch information
RafayGhafoor committed Sep 3, 2017
1 parent 9da036a commit c14c2d2
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 73 deletions.
2 changes: 1 addition & 1 deletion ptcl.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def show_blocked_dev():
for i in soup.findAll('td'):
if not i.find("input"):
if Router.mac_adr_regex.search(i.text):
print i.text + '\n'
print tabulate([[i.text]], headers=["BLOCKED-DEV"], tablefmt="fancy_grid")


def main():
Expand Down
72 changes: 0 additions & 72 deletions router.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import bs4
import re
import sys
from tabulate import tabulate

class Router(object):
'''
Expand Down Expand Up @@ -80,15 +79,6 @@ def get_dhcpinfo(self):
self.mac_address.append(i.text.encode('ascii'))


def show_dhcpinfo(self):
'''
Shows DHCP information.
'''
self.get_dhcpinfo()
print tabulate({"HOSTNAME": self.dev_hostname, "MAC-ADDRESSES": self.mac_address}, headers=['HOSTNAME', 'MAC-ADDRESSES'], tablefmt='fancy_grid')
print "\n\n\t\tTotal Devices Connected Today are: [%s].\n\n" % len(self.dev_hostname)


def get_stationinfo(self):
'''
Gets information about the connected devices.
Expand All @@ -99,26 +89,6 @@ def get_stationinfo(self):
if self.mac_adr_regex.search(i.text.strip()):
self.active_dev.append(i.text.strip().lower().encode('ascii'))

def show_active_dev(self):
'''
Shows active devices (Mac Addresses) and their hostnames.
'''
self.get_stationinfo()
self.get_dhcpinfo()
self.host_and_mac = tuple(zip(self.dev_hostname, self.mac_address))
hostnames = []
display_list = []
count = 1
print "\nShowing Currently Active Devices.\n"
for hostname, mac in self.host_and_mac:
for active_clients in self.active_dev:
if active_clients in mac:
display_list.append([count, hostname, active_clients])
hostnames.append(hostname)
count += 1
print tabulate(display_list, headers=["DEVICE-NO.", "HOSTNAME", "MAC"], tablefmt="fancy_grid")
return hostnames


def block_dev(self, devmac):
'''
Expand All @@ -134,18 +104,6 @@ def unblock_dev(self, udevmac):
r, soup = self.scrape_page(self.mask + "wlmacflt.cmd?action=remove&rmLst=%s&sessionKey=%s" % (udevmac, self.session_key))


def show_blocked_dev(self):
'''
Display blocked devices.
'''
r, soup = self.scrape_page(self.mask + "wlmacflt.cmd?action=view")
print "Showing blocked devices.\n"
for i in soup.findAll('td'):
if not i.find("input"):
if Router.mac_adr_regex.search(i.text):
print i.text + '\n'


def reboot_router(self):
'''
Reboots Router.
Expand Down Expand Up @@ -180,33 +138,3 @@ def change_passwd(self):
Change the password of the router.
'''
pass


class Monitor(Router):
'''
Monitor class derived from the router, which contains method for
monitoring users connected to router.
'''

def get_suspects(self):
'''
Searches suspected users who are currently connected
to the router.
'''
suspects = {"User 1": "Mac_Address"} # Sample


def monitor_dev(self): # Monitor Devices
'''
Monitor devices, when they connect to router and disconnect. Also
gets the time a device remains connected to the router.
'''
pass


def dev_conninfo(self): # Device Connection Info
'''
Analyzes how much time a device remains connected to the device throughout
the day.
'''
pass

0 comments on commit c14c2d2

Please sign in to comment.