Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Dynamic Exposure
rabotnik
rcom
Commits
08401e16
Commit
08401e16
authored
Apr 09, 2021
by
Felix Delattre
Browse files
Added argument handler for building_id file
parent
7067f170
Pipeline
#21795
passed with stage
in 1 minute and 24 seconds
Changes
3
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
rcli/argument_factory.py
View file @
08401e16
...
...
@@ -21,6 +21,7 @@ from argparse import ArgumentParser
from
.argument_base
import
ArgumentBase
from
.arguments.building_id
import
ArgumentBuildingId
from
.arguments.building_ids_file
import
ArgumentBuildingIdsFile
logger
=
logging
.
getLogger
(
__name__
)
...
...
@@ -35,6 +36,7 @@ class ArgumentFactory:
self
.
arguments
=
{}
self
.
add_argument
(
ArgumentBuildingId
())
self
.
add_argument
(
ArgumentBuildingIdsFile
())
def
add_to_parser
(
self
,
parser
:
ArgumentParser
):
...
...
rcli/arguments/building_id.py
View file @
08401e16
...
...
@@ -30,6 +30,7 @@ class ArgumentBuildingId(ArgumentBase):
async
def
execute
(
self
,
message_bus
,
argument
,
value
):
logger
.
info
(
f
"Dispatching `
{
argument
}
` with `
{
value
}
` on `
{
self
.
rabotnik_message
}
`."
)
logger
.
info
(
"Dispatching `%s` with `%s` on `%s`."
,
argument
,
value
,
self
.
rabotnik_message
)
await
message_bus
.
send
(
message
=
self
.
rabotnik_message
,
payload
=
{
argument
:
value
})
rcli/arguments/building_ids_file.py
0 → 100644
View file @
08401e16
#!/usr/bin/env python3
# Copyright (C) 2020-2021:
# Helmholtz-Zentrum Potsdam Deutsches GeoForschungsZentrum GFZ
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at
# your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero
# General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see http://www.gnu.org/licenses/.
import
logging
from
..argument_base
import
ArgumentBase
logger
=
logging
.
getLogger
(
__name__
)
class
ArgumentBuildingIdsFile
(
ArgumentBase
):
def
__init__
(
self
):
self
.
argument
=
"--building-ids-file"
self
.
rabotnik_message
=
"building"
self
.
help_text
=
"File with many `building_id` in every new line"
async
def
execute
(
self
,
message_bus
,
argument
,
filename
):
with
open
(
filename
)
as
f
:
data
=
f
.
read
()
for
line
in
data
:
value
=
line
.
strip
()
logger
.
info
(
"Dispatching `%s` with `%s` on `%s`."
,
argument
,
value
,
self
.
rabotnik_message
)
await
message_bus
.
send
(
message
=
self
.
rabotnik_message
,
payload
=
{
argument
:
value
})
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment