Improve makefile to avoid syncing on accident

This commit is contained in:
IamTheFij 2018-04-04 18:01:43 -07:00
parent 47916aafd7
commit b82f8afb27
2 changed files with 20 additions and 10 deletions

View File

@ -1,8 +1,5 @@
.PHONY: default .PHONY: default
default: run default: add-photos
.PHONY: run
run: email_to_photo.json
virtualenv: virtualenv_run virtualenv: virtualenv_run
@ -17,14 +14,12 @@ build/email_to_photo.json: virtualenv_run
build/vdirsyncer: virtualenv_run build/vdirsyncer: virtualenv_run
./vdirsyncer-wrapper discover ./vdirsyncer-wrapper discover
build/vdirsyncer/status/my_contacts/contacts.items: build/vdirsyncer build/contacts/contacts/DOWNLOADED: build/vdirsyncer
./vdirsyncer-wrapper sync ./vdirsyncer-wrapper sync
touch build/contacts/contacts/DOWNLOADED
.PHONY: sync-contacts
sync-contacts: build/vdirsyncer/status/my_contacts/contacts.items
.PHONY: khard-list .PHONY: khard-list
khard-list: build/vdirsyncer/status/my_contacts/contacts.items khard-list: build/contacts/contacts/DOWNLOADED
./khard-wrapper list ./khard-wrapper list
build/photos/DONE: build/email_to_photo.json build/photos/DONE: build/email_to_photo.json
@ -32,6 +27,14 @@ build/photos/DONE: build/email_to_photo.json
touch build/photos/DONE touch build/photos/DONE
.PHONY: add-photos .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 mkdir -p build/photos
./virtualenv_run/bin/python -m google_photo_to_vcard.add_photo ./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

View File

@ -141,8 +141,13 @@ def main():
for person in connections: for person in connections:
count += 1 count += 1
logging.debug('Processing %s', person.get('resourceName'))
primary_photo = get_primary_photo(person) primary_photo = get_primary_photo(person)
if not primary_photo: 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 continue
emails = person.get('emailAddresses', []) emails = person.get('emailAddresses', [])
@ -152,6 +157,8 @@ def main():
for email in emails: for email in emails:
email_to_photo[email['value']] = primary_photo email_to_photo[email['value']] = primary_photo
logging.debug('Added photos for person')
if count % 50 == 0: if count % 50 == 0:
logging.info('Found {} photos for {} emails'.format( logging.info('Found {} photos for {} emails'.format(
len(all_photos), len(all_photos),