Grigoriy Petukhov committed 2aa9597

Add flexibility to files finding

Comments (0)

Files changed (1)

 import sys
 import shutil
 from datetime import datetime
-from PIL import Image
-from PIL.ExifTags import TAGS
+    from PIL import Image
+    from PIL.ExifTags import TAGS
+except ImportError:
+    import Image
+    from ExifTags import TAGS
-MOUNT_DIR = '/mnt/dcim'
+MOUNT_DIR1 = '/mnt/dcim'
+MOUNT_DIR2 = '/mnt/DCIM'
 DST_DIR = '/home/lorien/photos'
 def get_exif(fn):
     return ret
 def find_sources():
-    dirs = glob.glob(MOUNT_DIR + '/*_pana')
+    if os.path.exists(MOUNT_DIR1):
+        dirs = glob.glob(MOUNT_DIR1 + '/*')
+    elif os.path.exists(MOUNT_DIR2):
+        dirs = glob.glob(MOUNT_DIR2 + '/*')
+    else:
+        dirs = []
+    # quick workaround because I am moving to Nikon D70S
+    #dirs = glob.glob(MOUNT_DIR + '/*_pana')
     return dirs
     #pairs = [(int(x.split('/')[-1].split('_')[0]), x) for x in dirs]
     #last = sorted(pairs, key=lambda x: x[0], reverse=True)[0]
 def process_source(source):
     dates = {}
-    for fname in glob.glob(source + '/*.jpg'):
+    for fname in (glob.glob(source + '/*.jpg') +\
+                  glob.glob(source + '/*.JPG')):
         #ctime = datetime.fromtimestamp(os.stat(fname).st_ctime)
         exif = get_exif(fname)
         ctime = datetime.strptime(exif['DateTime'], '%Y:%m:%d %H:%M:%S')
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.