Skip to content

Commit

Permalink
Migrator script fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefano Cossu committed Oct 18, 2018
1 parent fdcbd00 commit 576a6a2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
13 changes: 8 additions & 5 deletions lakesuperior/lsup_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ def migrate(src, dest, auth, start, list_file, zero_binaries, skip_errors):
"""
Migrate an LDP repository to Lakesuperior.
This utility creates a fully functional LAKEshore repository from an
This utility creates a fully functional Lakesuperior repository from an
existing repository. The source repo can be Lakesuperior or
another LDP-compatible implementation.
Expand All @@ -208,13 +208,16 @@ def migrate(src, dest, auth, start, list_file, zero_binaries, skip_errors):
src, dest, src_auth=src_auth, start_pts=start, list_file=list_file,
zero_binaries=zero_binaries, skip_errors=skip_errors)
logger.info('Migrated {} resources.'.format(entries))
logger.info("""Migration complete. To start the new repository, from the
directory you launched this script run:
logger.info(f'''
Migration complete. A new Lakesuperior environment has been created in
{dest}. To start the new repository, run:
FCREPO_CONFIG_DIR="{}/etc" ./fcrepo
FCREPO_CONFIG_DIR="{dest}/etc" fcrepo
from the directory you launched this script in.
Make sure that the default port is not being used by another repository.
""".format(dest))
''')


admin.add_command(bootstrap)
Expand Down
10 changes: 6 additions & 4 deletions lakesuperior/migrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,11 @@ def _crawl(self, uid):
# Determine LDP type.
ldp_type = 'ldp_nr'
try:
links_rsp = rsp.headers.get('link', auth=self.auth)
links_rsp.raise_for_status()
for link in requests.utils.parse_header_links(links_rsp):
links_rsp = rsp.headers.get('link')
head_links = (
requests.utils.parse_header_links(links_rsp)
if links_rsp else None)
for link in head_links:
if (
link.get('rel') == 'type'
and (
Expand Down Expand Up @@ -269,7 +271,7 @@ def _crawl(self, uid):
uuid = str(gr.value(
URIRef(iuri), nsc['premis'].hasMessageDigest)).split(':')[-1]
fpath = self.nonrdfly.local_path(
self.nonrdfly.config['path'], uuid)
self.nonrdfly.config['location'], uuid)
makedirs(path.dirname(fpath), exist_ok=True)
with open(fpath, 'wb') as fh:
fh.write(data)
Expand Down

0 comments on commit 576a6a2

Please sign in to comment.