Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Paste
P346
(An Untitled Masterwork)
Active
Public
Actions
Authored by
vlorentz
on Jan 10 2019, 11:53 AM.
Edit Paste
Archive Paste
View Raw File
Subscribe
Mute Notifications
Award Token
Flag For Later
Tags
None
Subscribers
None
# Copyright (C) 2018 The Software Heritage developers
# See the AUTHORS file at the top-level directory of this distribution
# License: GNU General Public License version 3, or any later version
# See top-level LICENSE file for more information
import
logging
from
swh.journal.client
import
JournalClient
class
IndexerJournalClient
(
JournalClient
):
"""Client in charge of listing new received origins and origin_visits
in the swh journal.
"""
CONFIG_BASE_FILENAME
=
'indexer/journal_client'
def
__init__
(
self
):
super
()
.
__init__
(
extra_configuration
=
{
'object_types'
:
[
'origin_visit'
]})
def
process_objects
(
self
,
messages
):
print
(
'----'
*
100
)
print
(
'got messages:
%r
'
%
(
messages
,))
assert
set
(
messages
)
==
{
'origin_visit'
},
set
(
messages
)
for
origin_visit
in
messages
[
'origin_visit'
]:
self
.
process_origin_visit
(
origin_visit
)
def
process_origin_visit
(
self
,
origin_visit
):
print
(
repr
(
origin_visit
))
if
__name__
==
'__main__'
:
logging
.
basicConfig
(
level
=
logging
.
INFO
,
format
=
'
%(asctime)s
%(process)d
%(levelname)s
%(message)s
'
)
import
click
@click.command
()
def
main
():
"""Log the new received origin and origin_visits.
"""
IndexerJournalClient
()
.
process
()
main
()
Event Timeline
vlorentz
created this paste.
Jan 10 2019, 11:53 AM
2019-01-10 11:53:33 (UTC+1)
Log In to Comment