Skip to content

Commit

Permalink
Add a verbose flag, and only print web service results when it's set.
Browse files Browse the repository at this point in the history
  • Loading branch information
fmeppo committed Feb 6, 2017
1 parent f54d555 commit 3a31750
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion connect.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
help='IPv4 address to advertise (rather than autodetect)')
parser.add_argument('-6', '--ipv6', nargs=1, type=str,
help='IPv6 address to advertise (will not be autodetected)')
parser.add_argument('-v', '--verbose', action='store_true', dest='verbose',
help='Display verbose results from the server')

args = parser.parse_args()

Expand All @@ -25,7 +27,6 @@
try:
u = urllib2.urlopen(args.url[0] + '?' + qstring)
data = u.read()
print data
u.close()
except urllib2.HTTPError, e:
print "HTTP error: " + str(e)
Expand All @@ -37,6 +38,9 @@
print "Invalid URL: " + args.url[0]
sys.exit(3)

if args.verbose:
print data

if u.getcode() == 200:
# Success!
sys.exit(0)
Expand Down

0 comments on commit 3a31750

Please sign in to comment.