Skip to content

Commit

Permalink
Argsparse, Added Some test print statements
Browse files Browse the repository at this point in the history
  • Loading branch information
RafayGhafoor committed Jul 27, 2017
1 parent 10a22e9 commit 8359e13
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
7 changes: 4 additions & 3 deletions ptcl.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,19 @@
}

ptcl = Router()
# ptcl = Router(mask='192.168.10.1', password='bec10')


def main():
parser = argparse.ArgumentParser(description="Control PTCL router from command-line.")
parser.add_argument('-b', '--block', help="Block device.", default='.')
parser.add_argument('-b', '--block', help="Block device.", nargs='?')
parser.add_argument('-u', '--unblock', help="Unblock device.", nargs='?')
parser.add_argument('-a', '--active-devices', help="Gets active devices number.", action='store_true')
parser.add_argument('-r', '--restart', help="Restart Router.", action='store_true')
parser.add_argument('-sd', '--show-dhcp', help='Show DHCP Info.', action='store_true')
parser.add_argument('-s', '--show-active', help='Show Active Devices.', default='.')
parser.add_argument('-c', '--configure', help='Configure router settings.')
args = parser.parse_args()
print args
if args.block:
print "Calling blocker Function"
ptcl.get_sessionkey()
Expand Down Expand Up @@ -66,7 +67,7 @@ def main():

elif args.show_dhcp:
print "Calling DHCP_info Function"
ptcl.get_sessionkey()
# ptcl.get_sessionkey()
ptcl.show_dhcpinfo()

elif args.show_active == '.':
Expand Down
4 changes: 2 additions & 2 deletions router.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ class Router(object):
mac_adr_regex = re.compile(r'^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$')


def __init__(self, mask="http://192.168.1.1", username="admin", password="admin"):
self.mask = mask + '/'
def __init__(self, mask="192.168.1.1", username="admin", password="admin"):
self.mask = "http://" + mask + '/'
self.username = username
self.password = password
self.dev_hostname = [] # Devices Hostname
Expand Down

0 comments on commit 8359e13

Please sign in to comment.