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
0568ed21
Commit
0568ed21
authored
10 years ago
by
Hendrik Buschmeier
Browse files
Options
Downloads
Patches
Plain Diff
ipaaca-iu-sniffer: show links, more colours, code easier to maintain.
parent
1eb05e36
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
+38
-17
38 additions, 17 deletions
ipaacatools/scripts/ipaaca-iu-sniffer
with
38 additions
and
17 deletions
ipaacatools/scripts/ipaaca-iu-sniffer
+
38
−
17
View file @
0568ed21
...
...
@@ -31,7 +31,7 @@
# Forschungsgemeinschaft (DFG) in the context of the German
# Excellence Initiative.
from
__future__
import
print_function
from
__future__
import
division
,
print_function
import
logging
import
re
...
...
@@ -44,27 +44,44 @@ import platform
import
ipaaca
def
event_type_color
(
typ
):
colors
=
{
'
ADDED
'
:
'
32;1
'
,
'
RETRACTED
'
:
'
31;1
'
,
'
UPDATED
'
:
'
33;1
'
,
'
MESSAGE
'
:
'
34;1
'
,
'
COMMITTED
'
:
'
35;1
'
,
'
LINKSUPDATED
'
:
'
36;1
'
,
'
RETRACTED
'
:
'
37;1
'
,
}
return
colors
.
get
(
typ
,
'
1
'
)
def
highlight_if_color
(
s
,
c
=
'
1
'
):
return
s
if
not
arguments
.
color
else
'
[
'
+
c
+
'
m
'
+
s
+
'
[m
'
def
pretty_printed_iu_payload
(
iu
):
s
=
'
{
'
for
k
,
v
in
iu
.
payload
.
items
():
v2
=
((
'
\'
'
+
v
+
'
\'
'
)
if
len
(
v
)
<=
arguments
.
max_size
else
(
'
\'
'
+
v
[:
arguments
.
max_size
]
+
'
\'
<excess length omitted>
'
)).
replace
(
'
\\
'
,
'
\\\\
'
).
replace
(
'
\n
'
,
highlight_if_color
(
'
\\
n
'
))
s
+=
'
\n
'
+
'
\t\t\'
'
+
highlight_if_color
(
unicode
(
k
),
'
1
'
)
+
'
\'
:
'
+
unicode
(
v2
)
+
'
,
'
s
+=
'
}
'
return
s
if
not
arguments
.
color
else
'
[
'
+
c
+
'
m
'
+
s
+
'
[m
'
def
pretty_printed_dict
(
d
):
s
=
'
{
\n
'
for
k
,
v
in
d
.
items
():
v
=
str
(
v
)
v2
=
v
if
len
(
v
)
<=
arguments
.
max_size
else
v
[:
arguments
.
max_size
]
+
'
<excess length omitted>
'
v2
.
replace
(
'
\\
'
,
'
\\\\
'
).
replace
(
'
\n
'
,
highlight_if_color
(
'
\\
n
'
))
s
+=
"
\t
'
%s
'
:
'
%s
'
,
"
%
(
highlight_if_color
(
unicode
(
k
),
'
1
'
),
unicode
(
v2
))
s
+=
'
\n
}
'
return
s
def
event_type_color
(
typ
):
colors
=
{
'
ADDED
'
:
'
32;1
'
,
'
RETRACTED
'
:
'
31;1
'
,
'
UPDATED
'
:
'
33;1
'
,
'
MESSAGE
'
:
'
34;1
'
}
return
'
1
'
if
typ
not
in
colors
else
colors
[
typ
]
def
pretty_printed_iu_event
(
iu
,
event_type
,
local
):
s
=
''
t
=
time
.
time
()
lt
=
time
.
localtime
(
t
)
s
+=
highlight_if_color
(
'
%.3f
'
%
t
,
'
1
'
)
+
'
'
+
"
%02d:%02d:%02d
"
%
(
lt
.
tm_hour
,
lt
.
tm_min
,
lt
.
tm_sec
)
s
+=
'
'
+
highlight_if_color
(
'
%-9s
'
%
event_type
,
event_type_color
(
event_type
))
+
'
category=
'
+
highlight_if_color
(
iu
.
category
,
event_type_color
(
event_type
))
+
'
uid=
'
+
iu
.
uid
+
'
owner=
'
+
iu
.
owner_name
+
'
payload=
'
+
pretty_printed_iu_payload
(
iu
)
s
+=
highlight_if_color
(
'
%.3f
'
%
t
,
'
1
'
)
s
+=
'
%02d:%02d:%02d
'
%
(
lt
.
tm_hour
,
lt
.
tm_min
,
lt
.
tm_sec
)
s
+=
'
'
+
highlight_if_color
(
'
%-9s
'
%
event_type
,
event_type_color
(
event_type
))
s
+=
'
category=
'
+
highlight_if_color
(
iu
.
category
,
event_type_color
(
event_type
))
s
+=
'
uid=
'
+
iu
.
uid
s
+=
'
owner=
'
+
iu
.
owner_name
if
event_type
is
not
'
MESSAGE
'
:
s
+=
'
\n
links=
'
+
pretty_printed_dict
(
iu
.
get_all_links
())
s
+=
'
\n
payload=
'
+
pretty_printed_dict
(
iu
.
payload
)
return
s
def
my_update_handler
(
iu
,
event_type
,
local
):
...
...
@@ -74,7 +91,7 @@ def my_update_handler(iu, event_type, local):
break
else
:
return
print
(
pretty_printed_iu_event
(
iu
,
event_type
,
local
))
print
(
pretty_printed_iu_event
(
iu
,
event_type
,
local
)
,
end
=
'
\n\n
'
)
...
...
@@ -117,7 +134,11 @@ if __name__ == '__main__':
buffers
=
{}
for
channel
in
arguments
.
channels
:
buffers
[
channel
]
=
ipaaca
.
InputBuffer
(
'
IpaacaIUSniffer
'
,
arguments
.
categories
if
not
arguments
.
regex
else
[
''
],
channel
)
buffers
[
channel
]
=
ipaaca
.
InputBuffer
(
'
IpaacaIUSniffer
'
,
category_interests
=
arguments
.
categories
if
not
arguments
.
regex
else
[
''
],
channel
=
channel
,
resend_active
=
True
)
buffers
[
channel
].
register_handler
(
my_update_handler
)
print
(
''
)
...
...
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