bsc_control.py: style corrections
* replace some tabs indent with spaces * add comment to make sure no new tabs are used for indentation by emacs * remove unnecessary parenthesis Change-Id: Ib79fd4317d40ee4fd87b090b9faf8ebaf4bfca64
This commit is contained in:
parent
688231331b
commit
82caa3e9b7
|
@ -1,4 +1,5 @@
|
||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
|
# -*- mode: python-mode; py-indent-tabs-mode: nil -*-
|
||||||
|
|
||||||
import sys,os, random
|
import sys,os, random
|
||||||
from optparse import OptionParser
|
from optparse import OptionParser
|
||||||
|
@ -25,13 +26,13 @@ def remove_ipa_ctrl_header(data):
|
||||||
return data[4:plen+3], data[plen+3:]
|
return data[4:plen+3], data[plen+3:]
|
||||||
|
|
||||||
def connect(host, port):
|
def connect(host, port):
|
||||||
if verbose:
|
if verbose:
|
||||||
print "Connecting to host %s:%i" % (host, port)
|
print "Connecting to host %s:%i" % (host, port)
|
||||||
|
|
||||||
sck = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
sck = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||||
sck.setblocking(1)
|
sck.setblocking(1)
|
||||||
sck.connect((host, port))
|
sck.connect((host, port))
|
||||||
return sck
|
return sck
|
||||||
|
|
||||||
def send(sck, data):
|
def send(sck, data):
|
||||||
if verbose:
|
if verbose:
|
||||||
|
@ -91,24 +92,24 @@ if __name__ == '__main__':
|
||||||
verbose = options.verbose
|
verbose = options.verbose
|
||||||
|
|
||||||
if options.cmd_set and options.cmd_get:
|
if options.cmd_set and options.cmd_get:
|
||||||
parser.error("Get and set options are mutually exclusive!")
|
parser.error("Get and set options are mutually exclusive!")
|
||||||
|
|
||||||
if not (options.cmd_get or options.cmd_set or options.monitor):
|
if not (options.cmd_get or options.cmd_set or options.monitor):
|
||||||
parser.error("One of -m, -g, or -s must be set")
|
parser.error("One of -m, -g, or -s must be set")
|
||||||
|
|
||||||
if not (options.host):
|
if not (options.host):
|
||||||
parser.error("Destination host and port required!")
|
parser.error("Destination host and port required!")
|
||||||
|
|
||||||
sock = connect(options.host, options.port)
|
sock = connect(options.host, options.port)
|
||||||
|
|
||||||
if options.cmd_set:
|
if options.cmd_set:
|
||||||
if len(args) < 2:
|
if len(args) < 2:
|
||||||
parser.error("Set requires var and value arguments")
|
parser.error("Set requires var and value arguments")
|
||||||
do_set(args[0], ' '.join(args[1:]), options.op_id, sock)
|
do_set(args[0], ' '.join(args[1:]), options.op_id, sock)
|
||||||
|
|
||||||
if options.cmd_get:
|
if options.cmd_get:
|
||||||
if len(args) != 1:
|
if len(args) != 1:
|
||||||
parser.error("Get requires the var argument")
|
parser.error("Get requires the var argument")
|
||||||
do_get(args[0], options.op_id, sock)
|
do_get(args[0], options.op_id, sock)
|
||||||
|
|
||||||
data = sock.recv(1024)
|
data = sock.recv(1024)
|
||||||
|
@ -117,14 +118,14 @@ if __name__ == '__main__':
|
||||||
print "Got message:", answer
|
print "Got message:", answer
|
||||||
|
|
||||||
if options.monitor:
|
if options.monitor:
|
||||||
while (True):
|
while True:
|
||||||
data = sock.recv(1024)
|
data = sock.recv(1024)
|
||||||
if len(data) == 0:
|
if len(data) == 0:
|
||||||
print "Connection is gone."
|
print "Connection is gone."
|
||||||
break
|
break
|
||||||
|
|
||||||
while (len(data)>0):
|
while len(data) > 0:
|
||||||
(answer, data) = remove_ipa_ctrl_header(data)
|
(answer, data) = remove_ipa_ctrl_header(data)
|
||||||
print "Got message:", answer
|
print "Got message:", answer
|
||||||
|
|
||||||
sock.close()
|
sock.close()
|
||||||
|
|
Loading…
Reference in New Issue