Commit 986a7d36 authored by Ad Schellevis's avatar Ad Schellevis

style fix list_table.py

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