Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "osfexport"
version = "0.2.1"
version = "0.2.2"
authors = [
{ name="Benito Matischen", email="benito.matischen@manchester.ac.uk" },
{ name="Ramiro Bravo", email="ramiro.bravo@manchester.ac.uk" },
Expand Down
22 changes: 15 additions & 7 deletions src/osfexport/exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@
import importlib.metadata
import time
import random
import logging

import click
logging.basicConfig(
level=logging.WARNING, format='%(message)s'
)


API_HOST_TEST = os.getenv('API_HOST_TEST', 'https://api.test.osf.io/v2')
Expand Down Expand Up @@ -361,7 +364,7 @@ def paginate_json_result(start, action, fail_on_first=True, **kwargs):
if fail_on_first and is_first_item or e.code == 429:
raise e
else:
click.echo("Error whilst parsing JSON page; continuing with other pages...")
logging.warning("Error whilst parsing JSON page; continuing with other pages...")
# Stop if no next link found
try:
next_link = curr_page['links']['next']
Expand Down Expand Up @@ -721,8 +724,13 @@ def get_project_data(nodes, **kwargs):
parent['data']['links']['html']
)
except (HTTPError, ValueError):
click.echo(f"Failed to load parent for {project_data['metadata']['title']}")
click.echo("Try to give a PAT beforehand using the --pat flag.", "\n")
logging.warning(
f"Failed to load parent for {project_data['metadata']['title']}"
)
logging.warning(
"Try to give a PAT beforehand using the --pat flag.",
"\n"
)

# Projects specified by ID to export also count as start nodes for PDFs
# This will be the first node in list of root nodes
Expand Down Expand Up @@ -752,10 +760,10 @@ def get_children(json_page, **kwargs):
if isinstance(e, HTTPError):
if e.code == 429:
raise e
click.echo(f"A project failed to export: {e.code}")
logging.warning(f"A project failed to export: {e.code}")
else:
click.echo("A project failed to export: Unexpected API response.")
click.echo("Continuing with exporting other projects...")
logging.warning("A project failed to export: Unexpected API response.")
logging.warning("Continuing with exporting other projects...")

return projects, root_nodes

Expand Down