Skip to content
Snippets Groups Projects
Commit 76e7dd04 authored by Hendrik Buschmeier's avatar Hendrik Buschmeier
Browse files

ipaaca-iu-sniffer: Now defaults to colored output; -c as short form of --categories.

parent 62b2a69f
No related branches found
No related tags found
No related merge requests found
......@@ -56,7 +56,7 @@ def event_type_color(typ):
return colors.get(typ, '1')
def highlight_if_color(s, c='1'):
return s if not arguments.color else '[' + c + 'm' + s +''
return s if arguments.color else '[' + c + 'm' + s +''
def pretty_printed_dict(d):
s='{\n'
......@@ -99,16 +99,6 @@ def my_update_handler(iu, event_type, local):
parser = ipaaca.IpaacaArgumentParser(description='Ipaaca IU Sniffer -- Selectively listen to IPAACA traffic')
parser.add_argument(
'-r', '--regex',
action='store_true',
dest='regex',
help='match categories by regular expressions')
parser.add_argument(
'-c', '--color',
action='store_true',
dest='color',
help='colorize output')
parser.add_argument(
'--channels',
dest='channels',
......@@ -117,12 +107,22 @@ parser.add_argument(
nargs='+',
help="set the channels to listen on (otherwise 'default')")
parser.add_argument(
'--categories',
'-c', '--categories',
default=[''],
dest='categories',
metavar='CATEGORY',
nargs='+',
help='set categories (or regex patterns) to be matched')
parser.add_argument(
'-r', '--regex',
action='store_true',
dest='regex',
help='match categories by regular expressions')
parser.add_argument(
'--no-color',
action='store_true',
dest='color',
help='do not colorize output')
parser.add_argument(
'--size-limit',
default=2048,
......@@ -146,7 +146,7 @@ if __name__ == '__main__':
channellist = 's ' if len(arguments.channels) > 1 else ' '
channellist += ', '.join(arguments.channels)
print('Listening on channel' + channellist + ' for IU events of ', end='')
if arguments.categories == ['']:
print('any category ...')
......@@ -162,9 +162,9 @@ if __name__ == '__main__':
time.sleep(1)
except KeyboardInterrupt:
pass
if platform.system() == 'Windows':
os._exit(0)
else:
sys.exit(0)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment