Commit 198d5414 authored by Ad Schellevis's avatar Ad Schellevis Committed by Franco Fichtner

style fix list_tables.py

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