Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
workspaces
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
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
ssa
workspaces
Merge requests
!188
fixing download capability
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
fixing download capability
notification_service_work
into
main
Overview
0
Commits
3
Pipelines
4
Changes
16
Merged
Charlotte Hausman
requested to merge
notification_service_work
into
main
3 years ago
Overview
0
Commits
3
Pipelines
4
Changes
16
Expand
0
0
Merge request reports
Compare
main
version 3
3032923d
3 years ago
version 2
70f47cf8
3 years ago
version 1
0649e37e
3 years ago
main (base)
and
latest version
latest version
b1c5a8b0
3 commits,
3 years ago
version 3
3032923d
2 commits,
3 years ago
version 2
70f47cf8
1 commit,
3 years ago
version 1
0649e37e
2 commits,
3 years ago
16 files
+
1134
−
229
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
16
Search (e.g. *.vue) (Ctrl+P)
apps/cli/executables/datafetcher/datafetcher/datafetcher.py
+
22
−
45
Options
@@ -3,23 +3,16 @@
"""
Module for the command line interface to data-fetcher.
"""
import
logging
import
os
import
sys
from
argparse
import
Namespace
from
pathlib
import
Path
# pylint: disable=C0103, E0402, E0611, R0902, R0903, W0703, W1203
from
typing
import
List
,
Dict
from
datafetcher.errors
import
(
MissingSettingsException
,
NoProfileException
,
FileErrorException
,
)
from
datafetcher.errors
import
MissingSettingsException
,
NoProfileException
from
datafetcher.project_fetcher
import
ParallelFetcher
from
.locations_report
import
LocationsReport
from
.utilities
import
parse_args
,
get_capo_settings
,
path_is_accessible
from
.utilities
import
get_arg_parser
,
get_capo_settings
,
path_is_accessible
_APPLICATION_NAME
=
"
datafetcher
"
@@ -48,45 +41,40 @@ class DataFetcher:
"""
def
__init__
(
self
,
args_in
:
List
[
str
],
df_capo_settings
:
Dict
):
# TODO Some Fine Day: refactor to reduce cognitive complexity
def
__init__
(
self
,
args
:
Namespace
,
df_capo_settings
:
dict
):
self
.
usage
=
self
.
_build_usage_message
()
if
args
_in
is
None
or
df_capo_settings
is
None
:
if
args
is
None
or
df_capo_settings
is
None
:
raise
MissingSettingsException
()
args
=
parse_args
(
args_in
)
self
.
args
=
args
self
.
settings
=
df_capo_settings
try
:
self
.
verbose
=
args
.
verbose
self
.
verbose
=
self
.
args
.
verbose
except
AttributeError
:
# we don't care; --verbose will be dropped later in WS-179
pass
# required arguments
if
hasattr
(
args
,
"
profile
"
):
self
.
profile
=
args
.
profile
else
:
if
"
CAPO_PROFILE
"
in
os
.
environ
.
keys
():
self
.
profile
=
os
.
environ
[
"
CAPO_PROFILE
"
]
else
:
raise
NoProfileException
(
"
Capo profile is required
"
)
self
.
profile
=
args
.
profile
if
self
.
profile
is
None
:
raise
NoProfileException
()
self
.
output_dir
=
args
.
output_dir
if
self
.
output_dir
is
None
:
raise
MissingSettingsException
(
"
output directory option is missing
"
)
self
.
output_dir
=
Path
(
self
.
output_dir
)
if
not
self
.
output_dir
.
is_dir
()
or
not
path_is_accessible
(
self
.
output_dir
):
raise
FileErrorException
(
f
"
output location
{
self
.
output_dir
}
inaccessible or not found
"
)
output_dir
=
Path
(
self
.
output_dir
)
if
not
output_dir
.
is_dir
()
or
not
path_is_accessible
(
output_dir
):
raise
MissingSettingsException
(
f
"
output location
{
self
.
output_dir
}
inaccessible or not found
"
)
if
args
.
location_file
is
not
None
:
if
args
.
product_locator
is
not
None
:
raise
MissingSettingsException
(
"
required: location file OR product locator -- not both
"
)
self
.
location_file
=
Path
(
args
.
location_file
)
self
.
product_locator
=
None
self
.
location_file
=
args
.
location_file
elif
args
.
product_locator
is
not
None
:
self
.
product_locator
=
args
.
product_locator
self
.
location_file
=
None
else
:
raise
MissingSettingsException
(
"
you must specify either a location file or a product locator
"
@@ -120,16 +108,12 @@ class DataFetcher:
:return:
"""
fetcher
=
ParallelFetcher
(
self
.
output_dir
,
self
.
is_dry
,
self
.
force
,
self
.
settings
,
self
.
servers_report
)
fetcher
=
ParallelFetcher
(
self
.
args
,
self
.
settings
,
self
.
servers_report
)
fetcher
.
run
()
def
_get_locations
(
self
):
capo_settings
=
get_capo_settings
(
self
.
profile
)
if
self
.
product_locator
:
return
LocationsReport
(
self
.
product_locator
,
capo_settings
)
return
LocationsReport
(
self
.
location_file
,
capo_settings
)
return
LocationsReport
(
self
.
args
,
capo_settings
)
def
main
():
@@ -139,16 +123,9 @@ def main():
logging
.
basicConfig
(
level
=
logging
.
DEBUG
)
args
=
sys
.
argv
profile
=
None
if
"
--profile
"
in
args
:
for
i
in
range
(
0
,
len
(
args
)):
if
args
[
i
]
==
"
--profile
"
:
profile
=
args
[
i
+
1
]
break
if
not
profile
:
profile
=
os
.
environ
[
"
CAPO_PROFILE
"
]
settings
=
get_capo_settings
(
profile
)
args
=
get_arg_parser
().
parse_args
()
settings
=
get_capo_settings
(
args
.
profile
)
DataFetcher
(
args
,
settings
).
run
()
Loading