Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
I
ipaaca
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Social Cognitive Systems
ipaaca
Commits
3fffe620
Commit
3fffe620
authored
11 years ago
by
Hendrik Buschmeier
Browse files
Options
Downloads
Plain Diff
Merge branch 'master' of
ssh://129.70.148.49/Users/hendrik/Dropbox/Projects/repo/ipaaca
parents
5cd9b202
07ebd969
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ipaacatools/scripts/ipaaca-iu-sniffer.py
+28
-5
28 additions, 5 deletions
ipaacatools/scripts/ipaaca-iu-sniffer.py
with
28 additions
and
5 deletions
ipaacatools/scripts/ipaaca-iu-sniffer.py
+
28
−
5
View file @
3fffe620
...
@@ -30,12 +30,17 @@
...
@@ -30,12 +30,17 @@
# Forschungsgemeinschaft (DFG) in the context of the German
# Forschungsgemeinschaft (DFG) in the context of the German
# Excellence Initiative.
# Excellence Initiative.
from
__future__
import
print_function
import
logging
import
logging
import
re
import
sys
import
sys
import
time
import
time
import
ipaaca
import
ipaaca
color
=
False
color
=
False
regex
=
False
max_size
=
2048
max_size
=
2048
def
highlight_if_color
(
s
,
c
=
'
1
'
):
def
highlight_if_color
(
s
,
c
=
'
1
'
):
...
@@ -62,11 +67,16 @@ def pretty_printed_iu_event(iu, event_type, local):
...
@@ -62,11 +67,16 @@ def pretty_printed_iu_event(iu, event_type, local):
return
s
return
s
def
my_update_handler
(
iu
,
event_type
,
local
):
def
my_update_handler
(
iu
,
event_type
,
local
):
if
regex
:
for
cat
in
cats
:
# actually now regexs, not cats
if
re
.
match
(
cat
,
iu
.
category
):
break
else
:
return
t
=
time
.
localtime
()
t
=
time
.
localtime
()
print
pretty_printed_iu_event
(
iu
,
event_type
,
local
)
print
(
pretty_printed_iu_event
(
iu
,
event_type
,
local
)
)
cats
=
[]
cats
=
[]
keep_going
=
True
keep_going
=
True
idx
=
1
idx
=
1
while
keep_going
:
while
keep_going
:
...
@@ -76,11 +86,15 @@ while keep_going:
...
@@ -76,11 +86,15 @@ while keep_going:
print
(
'
'
+
sys
.
argv
[
0
]
+
'
[--options] [<category1> [<category2 ...]]
'
)
print
(
'
'
+
sys
.
argv
[
0
]
+
'
[--options] [<category1> [<category2 ...]]
'
)
print
(
'
Listen to specified categories (default: all)
'
)
print
(
'
Listen to specified categories (default: all)
'
)
print
(
'
Option --color : colorize output
'
)
print
(
'
Option --color : colorize output
'
)
print
(
'
Option --regex : match categories by regular expressions
'
)
print
(
'
Option --size-limit <size> : limit payload display, chars (def: 2048)
'
)
print
(
'
Option --size-limit <size> : limit payload display, chars (def: 2048)
'
)
sys
.
exit
(
0
)
sys
.
exit
(
0
)
elif
opt
==
'
--color
'
:
elif
opt
==
'
--color
'
:
color
=
True
color
=
True
idx
+=
1
idx
+=
1
elif
opt
==
'
--regex
'
:
regex
=
True
idx
+=
1
elif
opt
==
'
--size-limit
'
:
elif
opt
==
'
--size-limit
'
:
if
len
(
sys
.
argv
)
<
idx
+
2
:
if
len
(
sys
.
argv
)
<
idx
+
2
:
print
(
'
Please specify a max size
'
)
print
(
'
Please specify a max size
'
)
...
@@ -91,13 +105,22 @@ while keep_going:
...
@@ -91,13 +105,22 @@ while keep_going:
cats
=
sys
.
argv
[
idx
:]
cats
=
sys
.
argv
[
idx
:]
keep_going
=
False
keep_going
=
False
ib
=
ipaaca
.
InputBuffer
(
'
SnifferIn
'
,
[
''
]
if
len
(
cats
)
==
0
else
cats
)
ib
=
ipaaca
.
InputBuffer
(
'
SnifferIn
'
,
[
''
]
if
(
len
(
cats
)
==
0
or
regex
)
else
cats
)
ib
.
register_handler
(
my_update_handler
)
ib
.
register_handler
(
my_update_handler
)
print
(
''
)
print
(
''
)
print
(
'
Ipaaca IU Sniffer - run with --help to see options
'
)
print
(
'
Ipaaca IU Sniffer - run with --help to see options
'
)
print
(
'
Listening for IU events of
'
+
(
'
any category...
'
if
len
(
cats
)
==
0
else
'
categories:
'
+
'
'
.
join
(
cats
)))
print
(
'
Listening for IU events of
'
,
end
=
''
)
if
len
(
cats
)
==
0
:
print
(
'
any category ...
'
)
else
:
if
regex
:
print
(
'
whose category matches one of the regexes:
'
)
else
:
print
(
'
categories:
'
)
for
cat
in
cats
:
print
(
'
\t
'
+
cat
)
print
(
''
)
print
(
''
)
while
True
:
while
True
:
time
.
sleep
(
1
)
time
.
sleep
(
1
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment