Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- import urllib2
- #Last address in address_list should be +1, to cover all needed diapasone
- #Variables define begins
- address_list = ["192.168.1.%d"%x for x in range(101,104)]
- address_list2 = ["192.168.1.%d"%x for x in range(101,104)]
- login = 'admin'
- password = 'admin'
- login2 = 'user'
- password2 = ['user0',
- 'user1',
- 'user2']
- name = ['TM_TMN_00',
- 'TM_TMN_01',
- 'TM_TMN_02']
- GW = '192.168.1.1'
- SM = '255.255.255.0'
- ip_count = 0
- #Variables define ends
- for address, address2 in zip(address_list, address_list2):
- print "______________________________"
- print address, address2
- print "Working with ", address
- f = urllib2.urlopen('http://%s/'%address)
- #print f.read(100)
- #Authorization begins
- auth_handler = urllib2.HTTPBasicAuthHandler()
- auth_handler.add_password(realm='Device_CGI',
- uri='http://%s'%address,
- user=login,
- passwd=password)
- opener = urllib2.build_opener(auth_handler)
- urllib2.install_opener(opener)
- print "Authorization at", address, "is OK"
- #Authorization ends
- #Add new user begins
- print ""
- print "Setting up new login/pass at", address
- s = 'http://' + address + '/cgi-bin/userManager.cgi?action=addUser&user.Name=' + login2 + '&user.Password=' + password2[ip_count] + '&user.Group=admin&user.Sharable=true&user.Reserved=false&user.AuthList=CtrlPanel,ShutDown,Record,Backup'
- print "New password set is", password2[ip_count]
- print s
- p = urllib2.urlopen(s)
- text = p.read()
- print text.splitlines()
- #Add new user ends
- #Setting up encoder begins
- print ""
- print "Setting up encoder settings at", address
- v = 'http://' + address + '/cgi-bin/configManager.cgi?action=setConfig&Encode[0].MainFormat[0].Video.BitRate=2048&Encode[0].MainFormat[0].Video.Width=1280&Encode[0].MainFormat[0].Video.Height=720&Encode[0].MainFormat[0].Video.FPS=25&Encode[0].MainFormat[0].Video.GOP=50&Encode[0].ExtraFormat[0].VideoEnable=false&Encode[0].MainFormat[0].AudioEnable=false'
- print v
- p = urllib2.urlopen(v)
- text = p.read()
- print text.splitlines()
- # Setting up encoder ends
- # Setting up OSD begins
- print ""
- print "Setting up OSD settings at", address
- o = 'http://' + address + '/cgi-bin/configManager.cgi?action=setConfig&ChannelTitle[0].Name=' + name[ip_count] + '&VideoWidget[0].TimeTitle.ShowWeek=true'
- print o
- p = urllib2.urlopen(o)
- text = p.read()
- print text.splitlines()
- # Setting up OSD ends
- # Setting up NTP begins
- print ""
- print "Setting up NTP settings at", address
- q = 'http://' + address + '/cgi-bin/configManager.cgi?action=setConfig&NTP.Address=10.6.36.49&NTP.Enable=true&NTP.TimeZone=7'
- print q
- p = urllib2.urlopen(o)
- text = p.read()
- print text.splitlines()
- # Setting up NTP ends
- # Setting up IP begins
- print ""
- print "Setting up IP settings at", address
- w = 'http://' + address + '/cgi-bin/configManager.cgi?action=setConfig&Network.eth0.DefaultGateway=' + GW + '&Network.eth0.IPAddress=' + address2 + '&Network.eth0.SubnetMask=' + SM
- print w
- p = urllib2.urlopen(w)
- #text = p.read()
- #print text.splitlines()
- print 'Connetion will be loss'
- # Setting up IP ends
- ip_count += 1
- # f = urllib2.urlopen('http://%s/%s'%(address,"cgi-bin/configManager.cgi?action=getConfig&name=VideoColor"))
- #text = f.read()
- # print text.splitlines()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement