From 35de02ba6f81ab5d6463d666bb33fe995e14b13f Mon Sep 17 00:00:00 2001 From: Jaisen Mathai Date: Mon, 12 Oct 2015 19:40:51 -0700 Subject: [PATCH] Add tests which can be run from the command line --- tests/__init__.py | 0 tests/scripts/__init__.py | 0 tests/scripts/geolocation.py | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 35 insertions(+) create mode 100644 tests/__init__.py create mode 100644 tests/scripts/__init__.py create mode 100755 tests/scripts/geolocation.py diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/scripts/__init__.py b/tests/scripts/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/scripts/geolocation.py b/tests/scripts/geolocation.py new file mode 100755 index 0000000..20e3a19 --- /dev/null +++ b/tests/scripts/geolocation.py @@ -0,0 +1,35 @@ +#!/usr/bin/env python + +import os +import shutil +import sys + +from elodie import arguments +from elodie import geolocation +from elodie.media.photo import Photo +from elodie.media.video import Video + +def main(argv): + args = arguments.parse(argv, None, ['file=','type='], './import.py --type= --file=') + + if('file' not in args): + print 'No file specified' + sys.exit(1) + + if('type' in args and args['type'] == 'photo'): + media_type = Photo + else: + media_type = Video + + media = media_type(args['file']) + metadata = media.get_metadata() + + place_name = geolocation.place_name(metadata['latitude'], metadata['longitude']) + + output = {'latitude': metadata['latitude'], 'longitude': metadata['longitude'], 'place_name': place_name} + print '%r' % output + + +if __name__ == '__main__': + main(sys.argv[1:]) + sys.exit(0)