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
10 changes: 7 additions & 3 deletions planet/api/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import json
from .dispatch import RequestsDispatcher
from . import auth
from .exceptions import (InvalidIdentity, APIException)
from .exceptions import (InvalidIdentity, APIException, NoPermission)
from . import models
from . import filters

Expand Down Expand Up @@ -357,14 +357,18 @@ def download_quad(self, quad, callback=None):
be invoked asynchronously. Otherwise it is up to the caller to handle
the response Body.

:param asset dict: A mosaic quad representation from the API
:param quad dict: A mosaic quad representation from the API
:param callback: An optional function to aysnchronsously handle the
download. See :py:func:`planet.api.write_to_file`
:returns: :py:Class:`planet.api.models.Response` containing a
:py:Class:`planet.api.models.Body` of the asset.
:raises planet.api.exceptions.APIException: On API error.
'''
download_url = quad['_links']['download']
try:
download_url = quad['_links']['download']
except KeyError:
msg = 'You do not have download permissions for quad {}'
raise NoPermission(msg.format(quad['id']))
return self._get(download_url, models.Body, callback=callback)

def check_analytics_connection(self):
Expand Down
11 changes: 7 additions & 4 deletions planet/api/downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import threading
import time
from .utils import write_to_file
from planet.api.exceptions import RequestCancelled
from planet.api.exceptions import (RequestCancelled, NoPermission)
try:
import Queue as queue
except ImportError:
Expand Down Expand Up @@ -466,9 +466,12 @@ def _task(self, t):
def _do(self, task):
func = self._write_tracker(task, None)
writer = write_to_file(self._dest, func, overwrite=False)
self._downloads += 1
self._results.put((task, {'type': 'quad'},
self._client.download_quad(task, writer)))
try:
self._results.put((task, {'type': 'quad'},
self._client.download_quad(task, writer)))
self._downloads += 1
except NoPermission:
_info('No download permisson for %s, skipping', task['id'])


class _MosaicDownloader(_Downloader):
Expand Down