From 1e53077ab931a21d1b9802d2d1118ceae358290c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Thu, 7 Jul 2016 00:16:45 +0200 Subject: [PATCH] Add basic logging to PhotosService --- pyicloud/services/photos.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pyicloud/services/photos.py b/pyicloud/services/photos.py index 65e11aa..e10e242 100644 --- a/pyicloud/services/photos.py +++ b/pyicloud/services/photos.py @@ -1,5 +1,6 @@ import sys import json +import logging from datetime import datetime from base64 import b64decode @@ -13,6 +14,8 @@ from pyicloud.exceptions import ( from future.moves.urllib.parse import unquote from future.utils import listvalues, listitems +logger = logging.getLogger(__name__) + class PhotosService(object): """ The 'Photos' iCloud service.""" @@ -66,6 +69,7 @@ class PhotosService(object): return self.albums['All Photos'] def _fetch_asset_data_for(self, client_ids): + logger.debug("Fetching data for client IDs %s", client_ids) client_ids = [cid for cid in client_ids if cid not in self._photo_assets] @@ -131,6 +135,8 @@ class PhotoAlbum(object): return self._photo_assets def _parse_binary_feed(self, feed): + logger.debug("Parsing binary feed %s", feed) + binaryfeed = bytearray(b64decode(feed)) bitstream = ConstBitStream(binaryfeed) @@ -170,6 +176,9 @@ class PhotoAlbum(object): range_length = bitstream.read("uint:24") range_end = range_start + range_length + logger.debug("Decoding indexes [%s-%s) (length %s)", + range_start, range_end, range_length) + previous_asset_id = 0 for index in range(range_start, range_end): aspect_ratio = ASPECT_RATIOS[bitstream.read("uint:4")]