Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
metadata-and-data
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
Container registry
Model registry
Operate
Environments
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
web-et-numerique
web-et-numerique-internet
data.grandlyon.com
web-portal
components
indexers
metadata-and-data
Commits
b759b074
Commit
b759b074
authored
6 years ago
by
Alessandro Cerioni
Browse files
Options
Downloads
Patches
Plain Diff
Code refactoring
parent
f2445b97
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
main.py
+82
-42
82 additions, 42 deletions
main.py
with
82 additions
and
42 deletions
main.py
+
82
−
42
View file @
b759b074
...
...
@@ -190,6 +190,31 @@ def delete_dataset_from_dest_index( the_cfg, the_uuid ):
return
def
get_metadata_records_processor
(
the_root_url
,
the_no_records_per_page
,
the_uuid_to_get
,
the_uuids_to_filter_out
=
None
,
the_username
=
None
,
the_password
=
None
):
for
record
in
get_metadata_records
(
root_url
=
the_root_url
,
no_records_per_page
=
the_no_records_per_page
,
uuid
=
the_uuid_to_get
,
the_filter
=
the_uuids_to_filter_out
,
username
=
the_username
,
password
=
the_password
):
the_uuid
=
record
[
'
geonet:info
'
][
'
uuid
'
]
if
is_locked
(
cfg
[
'
session
'
][
'
working_directory
'
],
the_uuid
):
logging
.
info
(
"
Dataset with uuid = %s is already being indexed: skipping.
"
%
the_uuid
)
continue
else
:
logging
.
info
(
"
Setting lock for dataset with uuid = %s
"
%
the_uuid
)
lock
(
cfg
[
'
session
'
][
'
working_directory
'
],
the_uuid
)
# delete_dataset_from_indices(cfg, record['geonet:info']['uuid'])
delete_dataset_from_dest_index
(
cfg
,
the_uuid
)
send_record_to_the_metadata_processor
(
cfg
,
record
)
def
main
(
cfg
):
...
...
@@ -209,48 +234,63 @@ def main(cfg):
password
=
cfg
[
'
geonetwork
'
][
'
password
'
]
del
cfg
[
'
geonetwork
'
][
'
password
'
]
# <- as this info is no longer needed
if
'
all
'
not
in
uuids_to_get
:
# get some datasets only
for
uuid_to_get
in
uuids_to_get
:
for
record
in
get_metadata_records
(
cfg
[
'
geonetwork
'
][
'
url
'
],
cfg
[
'
geonetwork
'
][
'
records_per_page
'
],
uuid
=
uuid_to_get
,
the_filter
=
uuids_to_filter_out
,
username
=
username
,
password
=
password
):
the_uuid
=
record
[
'
geonet:info
'
][
'
uuid
'
]
if
is_locked
(
cfg
[
'
session
'
][
'
working_directory
'
],
the_uuid
):
logging
.
info
(
"
Dataset with uuid = %s is already being indexed: skipping.
"
%
the_uuid
)
continue
else
:
lock
(
cfg
[
'
session
'
][
'
working_directory
'
],
the_uuid
)
# delete_dataset_from_indices(cfg, record['geonet:info']['uuid'])
delete_dataset_from_dest_index
(
cfg
,
the_uuid
)
send_record_to_the_metadata_processor
(
cfg
,
record
)
else
:
# get all the datasets
for
record
in
get_metadata_records
(
cfg
[
'
geonetwork
'
][
'
url
'
],
cfg
[
'
geonetwork
'
][
'
records_per_page
'
],
uuid
=
None
,
the_filter
=
uuids_to_filter_out
,
username
=
username
,
password
=
password
):
the_uuid
=
record
[
'
geonet:info
'
][
'
uuid
'
]
if
is_locked
(
cfg
[
'
session
'
][
'
working_directory
'
],
the_uuid
):
logging
.
info
(
"
Dataset with uuid = %s is already being indexed: skipping.
"
%
the_uuid
)
continue
else
:
lock
(
cfg
[
'
session
'
][
'
working_directory
'
],
the_uuid
)
# delete_dataset_from_indices(cfg, record['geonet:info']['uuid'])
delete_dataset_from_dest_index
(
cfg
,
record
[
'
geonet:info
'
][
'
uuid
'
])
send_record_to_the_metadata_processor
(
cfg
,
record
)
if
'
all
'
in
uuids_to_get
:
uuids_to_get
=
[
None
]
for
uuid_to_get
in
uuids_to_get
:
get_metadata_records_processor
(
the_root_url
=
cfg
[
'
geonetwork
'
][
'
url
'
],
the_no_records_per_page
=
cfg
[
'
geonetwork
'
][
'
records_per_page
'
],
the_uuid_to_get
=
uuid_to_get
,
the_uuids_to_filter_out
=
uuids_to_filter_out
,
the_username
=
username
,
the_password
=
password
)
# if 'all' not in uuids_to_get:
#
# # get some datasets only
# for uuid_to_get in uuids_to_get:
# for record in get_metadata_records( cfg['geonetwork']['url'],
# cfg['geonetwork']['records_per_page'],
# uuid=uuid_to_get,
# the_filter=uuids_to_filter_out,
# username=username, password=password ):
#
# the_uuid = record['geonet:info']['uuid']
#
# if is_locked( cfg['session']['working_directory'], the_uuid ):
# logging.info("Dataset with uuid = %s is already being indexed: skipping." % the_uuid)
# continue
# else:
# lock(cfg['session']['working_directory'], the_uuid)
#
# # delete_dataset_from_indices(cfg, record['geonet:info']['uuid'])
# delete_dataset_from_dest_index(cfg, the_uuid)
# send_record_to_the_metadata_processor(cfg, record)
#
# else:
#
# # get all the datasets
# for record in get_metadata_records( cfg['geonetwork']['url'],
# cfg['geonetwork']['records_per_page'],
# uuid=None,
# the_filter=uuids_to_filter_out,
# username=username, password=password ):
#
# the_uuid = record['geonet:info']['uuid']
#
# if is_locked( cfg['session']['working_directory'], the_uuid ):
# logging.info("Dataset with uuid = %s is already being indexed: skipping." % the_uuid)
# continue
# else:
# lock(cfg['session']['working_directory'], the_uuid)
#
# # delete_dataset_from_indices(cfg, record['geonet:info']['uuid'])
# delete_dataset_from_dest_index(cfg, record['geonet:info']['uuid'])
# send_record_to_the_metadata_processor(cfg, record)
#connection.close()
...
...
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