From 5e30f372c8cad1d7c9a2b65eeafeca08f3da1f3d Mon Sep 17 00:00:00 2001 From: Jaisen Mathai Date: Tue, 13 Oct 2015 20:55:06 -0700 Subject: [PATCH] Remove output for update.py --- import.py | 6 ++++-- adjust.py => update.py | 16 ++++++---------- 2 files changed, 10 insertions(+), 12 deletions(-) rename adjust.py => update.py (88%) diff --git a/import.py b/import.py index c45878a..17ca579 100755 --- a/import.py +++ b/import.py @@ -80,7 +80,8 @@ def main(argv): if(media_type.__name__ == 'Video'): filesystem.set_date_from_path_video(media) - process_file(current_file, destination, media) + dest_path = filesystem.process_file(current_file, destination, media, allowDuplicate=False, move=False) + print '%s -> %s' % (current_file, dest_path) # Write to the hash database every 10 iterations write_counter += 1 if(write_counter % 10 == 0): @@ -94,7 +95,8 @@ def main(argv): if(media_type.__name__ == 'Video'): filesystem.set_date_from_path_video(media) - process_file(config['file'], destination, media) + dest_path = process_file(config['file'], destination, media, allowDuplicate=False, move=False) + print '%s -> %s' % (current_file, dest_path) db.update_hash_db() else: help() diff --git a/adjust.py b/update.py similarity index 88% rename from adjust.py rename to update.py index 4f719e1..37d31e0 100755 --- a/adjust.py +++ b/update.py @@ -28,6 +28,7 @@ def parse_arguments(args): return config def main(config, args): + location_coords = None for arg in args: if(arg[:2] == '--'): continue @@ -52,19 +53,18 @@ def main(config, args): exif_metadata = pyexiv2.ImageMetadata(file_path) exif_metadata.read() if(config['location'] is not None): - location_coords = geolocation.coordinates_by_name(config['location']) + if(location_coords is None): + location_coords = geolocation.coordinates_by_name(config['location']) + if(location_coords is not None and 'latitude' in location_coords and 'longitude' in location_coords): - print 'Queueing location to exif ...', exif_metadata['Exif.GPSInfo.GPSLatitude'] = geolocation.decimal_to_dms(location_coords['latitude']) exif_metadata['Exif.GPSInfo.GPSLatitudeRef'] = pyexiv2.ExifTag('Exif.GPSInfo.GPSLatitudeRef', 'N' if location_coords['latitude'] >= 0 else 'S') exif_metadata['Exif.GPSInfo.GPSLongitude'] = geolocation.decimal_to_dms(location_coords['longitude']) exif_metadata['Exif.GPSInfo.GPSLongitudeRef'] = pyexiv2.ExifTag('Exif.GPSInfo.GPSLongitudeRef', 'E' if location_coords['longitude'] >= 0 else 'W') write = True - print 'OK' if(config['time'] is not None): time_string = config['time'] - print '%r' % time_string time_format = '%Y-%m-%d %H:%M:%S' if(re.match('^\d{4}-\d{2}-\d{2}$', time_string)): time_string = '%s 00:00:00' % time_string @@ -74,12 +74,9 @@ def main(config, args): sys.exit(1) if(time_format is not None): - print 'Queueing time to exif ...', exif_metadata['Exif.Photo.DateTimeOriginal'].value = datetime.strptime(time_string, time_format) exif_metadata['Exif.Image.DateTime'].value = datetime.strptime(time_string, time_format) - print '%r' % datetime.strptime(time_string, time_format) write = True - print 'OK' if(write == True): exif_metadata.write() @@ -89,8 +86,7 @@ def main(config, args): media = _class(file_path) dest_path = filesystem.process_file(file_path, destination, media, move=True, allowDuplicate=True) - print '%s ...' % dest_path, - print 'OK' + print '%s -> %s' % (file_path, dest_path) # If the folder we moved the file out of or its parent are empty we delete it. filesystem.delete_directory_if_empty(os.path.dirname(file_path)) @@ -98,7 +94,7 @@ def main(config, args): db = Db() filesystem = FileSystem() -args = arguments.parse(sys.argv[1:], None, ['time=','location=','process='], './adjust.py --time= --location= --process=no file1 file2...fileN') +args = arguments.parse(sys.argv[1:], None, ['time=','location=','process='], './update.py --time= --location= --process=no file1 file2...fileN') config = parse_arguments(args) if __name__ == '__main__':