From b82f8afb271a8ccabeda144f1f333304229d2d68 Mon Sep 17 00:00:00 2001 From: Ian Fijolek Date: Wed, 4 Apr 2018 18:01:43 -0700 Subject: [PATCH] Improve makefile to avoid syncing on accident --- Makefile | 23 +++++++++++++---------- google_photo_to_vcard/build_photo_json.py | 7 +++++++ 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index 0c7b420..d24a051 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,5 @@ .PHONY: default -default: run - -.PHONY: run -run: email_to_photo.json +default: add-photos virtualenv: virtualenv_run @@ -17,14 +14,12 @@ build/email_to_photo.json: virtualenv_run build/vdirsyncer: virtualenv_run ./vdirsyncer-wrapper discover -build/vdirsyncer/status/my_contacts/contacts.items: build/vdirsyncer +build/contacts/contacts/DOWNLOADED: build/vdirsyncer ./vdirsyncer-wrapper sync - -.PHONY: sync-contacts -sync-contacts: build/vdirsyncer/status/my_contacts/contacts.items + touch build/contacts/contacts/DOWNLOADED .PHONY: khard-list -khard-list: build/vdirsyncer/status/my_contacts/contacts.items +khard-list: build/contacts/contacts/DOWNLOADED ./khard-wrapper list build/photos/DONE: build/email_to_photo.json @@ -32,6 +27,14 @@ build/photos/DONE: build/email_to_photo.json touch build/photos/DONE .PHONY: add-photos -add-photos: virtualenv_run build/email_to_photo.json build/vdirsyncer/status/my_contacts/contacts.items +add-photos: virtualenv_run build/email_to_photo.json build/contacts/contacts/DOWNLOADED mkdir -p build/photos ./virtualenv_run/bin/python -m google_photo_to_vcard.add_photo + +.PHONY: clean-build +clean-build: + rm -fr build/ + +.PHONY: sync-contacts +sync-contacts: build/vdirsyncer + ./vdirsyncer-wrapper sync diff --git a/google_photo_to_vcard/build_photo_json.py b/google_photo_to_vcard/build_photo_json.py index 1b02d68..35ae0e5 100644 --- a/google_photo_to_vcard/build_photo_json.py +++ b/google_photo_to_vcard/build_photo_json.py @@ -141,8 +141,13 @@ def main(): for person in connections: count += 1 + logging.debug('Processing %s', person.get('resourceName')) primary_photo = get_primary_photo(person) if not primary_photo: + logging.debug('No photo for person') + continue + if primary_photo.endswith('__8B/s100/photo.jpg'): + logging.debug('Skipping stupid default letter picture') continue emails = person.get('emailAddresses', []) @@ -152,6 +157,8 @@ def main(): for email in emails: email_to_photo[email['value']] = primary_photo + logging.debug('Added photos for person') + if count % 50 == 0: logging.info('Found {} photos for {} emails'.format( len(all_photos),