Commit 2bcdebee authored by Ad Schellevis's avatar Ad Schellevis Committed by Franco Fichtner

style fix list_table.py

parent b5f59fbd
...@@ -35,19 +35,21 @@ import os ...@@ -35,19 +35,21 @@ import os
import sys import sys
import ujson import ujson
result = [] if __name__ == '__main__':
if len(sys.argv) > 1: result = []
if len(sys.argv) > 1:
with tempfile.NamedTemporaryFile() as output_stream: with tempfile.NamedTemporaryFile() as output_stream:
subprocess.call(['/sbin/pfctl', '-t', sys.argv[1], '-T', 'show'], stdout=output_stream, stderr=open(os.devnull, 'wb')) subprocess.call(['/sbin/pfctl', '-t', sys.argv[1], '-T', 'show'],
stdout=output_stream, stderr=open(os.devnull, 'wb'))
output_stream.seek(0) output_stream.seek(0)
for line in output_stream.read().strip().split('\n'): for line in output_stream.read().strip().split('\n'):
if line.strip() != "": if line.strip() != "":
result.append(line.strip()) result.append(line.strip())
# handle command line argument (type selection) # handle command line argument (type selection)
if len(sys.argv) > 2 and sys.argv[2] == 'json': if len(sys.argv) > 2 and sys.argv[2] == 'json':
print(ujson.dumps(result)) print(ujson.dumps(result))
else: else:
# output plain # output plain
for table in result: for table in result:
print (table) print (table)
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