Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F9311469
cli.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Subscribers
None
cli.py
View Options
# Copyright (C) 2018-2021 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
from
copy
import
deepcopy
import
logging
# WARNING: do not import unnecessary things here to keep cli startup time under
# control
import
os
import
click
from
swh.core.cli
import
CONTEXT_SETTINGS
from
swh.core.cli
import
swh
as
swh_cli_group
from
swh.lister
import
SUPPORTED_LISTERS
,
get_lister
logger
=
logging
.
getLogger
(
__name__
)
@swh_cli_group.group
(
name
=
"lister"
,
context_settings
=
CONTEXT_SETTINGS
)
@click.option
(
"--config-file"
,
"-C"
,
default
=
None
,
type
=
click
.
Path
(
exists
=
True
,
dir_okay
=
False
,),
help
=
"Configuration file."
,
)
@click.pass_context
def
lister
(
ctx
,
config_file
):
"""Software Heritage Lister tools."""
from
swh.core
import
config
ctx
.
ensure_object
(
dict
)
if
not
config_file
:
config_file
=
os
.
environ
.
get
(
"SWH_CONFIG_FILENAME"
)
conf
=
config
.
read
(
config_file
)
ctx
.
obj
[
"config"
]
=
conf
@lister.command
(
name
=
"run"
,
context_settings
=
CONTEXT_SETTINGS
,
help
=
"Trigger a full listing run for a particular forge "
"instance. The output of this listing results in "
'"oneshot" tasks in the scheduler db with a priority '
"defined by the user"
,
)
@click.option
(
"--lister"
,
"-l"
,
help
=
"Lister to run"
,
type
=
click
.
Choice
(
SUPPORTED_LISTERS
)
)
@click.argument
(
"options"
,
nargs
=-
1
)
@click.pass_context
def
run
(
ctx
,
lister
,
options
):
from
swh.scheduler.cli.utils
import
parse_options
config
=
deepcopy
(
ctx
.
obj
[
"config"
])
if
options
:
config
.
update
(
parse_options
(
options
)[
1
])
get_lister
(
lister
,
**
config
)
.
run
()
if
__name__
==
"__main__"
:
lister
()
File Metadata
Details
Attached
Mime Type
text/x-python
Expires
Thu, Jul 3, 10:17 AM (2 w, 5 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3240289
Attached To
rDLS Listers
Event Timeline
Log In to Comment