Commit 9d4b6038 authored by Ad Schellevis's avatar Ad Schellevis

style fix pfinfo.py

parent c60b9873
......@@ -35,18 +35,19 @@ import os
import sys
import ujson
result=collections.OrderedDict()
for stattype in ['info', 'memory', 'timeouts', 'Interfaces']:
with tempfile.NamedTemporaryFile() as output_stream:
subprocess.call(['/sbin/pfctl','-vvs'+stattype], stdout=output_stream, stderr=open(os.devnull, 'wb'))
output_stream.seek(0)
result[stattype] = output_stream.read().strip()
# handle command line argument (type selection)
if len(sys.argv) > 1 and sys.argv[1] == 'json':
print(ujson.dumps(result))
else:
# output plain
for stattype in result:
print ('------------------------- %s -------------------------' % (stattype) )
print (result[stattype])
if __name__ == '__main__':
result = collections.OrderedDict()
for stattype in ['info', 'memory', 'timeouts', 'Interfaces']:
with tempfile.NamedTemporaryFile() as output_stream:
subprocess.call(['/sbin/pfctl', '-vvs'+stattype], stdout=output_stream, stderr=open(os.devnull, 'wb'))
output_stream.seek(0)
result[stattype] = output_stream.read().strip()
# handle command line argument (type selection)
if len(sys.argv) > 1 and sys.argv[1] == 'json':
print(ujson.dumps(result))
else:
# output plain
for stattype in result:
print ('------------------------- %s -------------------------' % stattype)
print (result[stattype])
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment