From 9d4b6038795d93d3ec33c4316812cce28c1d23bd Mon Sep 17 00:00:00 2001 From: Ad Schellevis Date: Sun, 6 Sep 2015 19:04:17 +0200 Subject: [PATCH] style fix pfinfo.py --- src/opnsense/scripts/filter/pfinfo.py | 29 ++++++++++++++------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/src/opnsense/scripts/filter/pfinfo.py b/src/opnsense/scripts/filter/pfinfo.py index 90212debc..a27e981c6 100755 --- a/src/opnsense/scripts/filter/pfinfo.py +++ b/src/opnsense/scripts/filter/pfinfo.py @@ -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() +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]) + # 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])