Commit 6009199e authored by Michael Murtaugh's avatar Michael Murtaugh
Browse files

added exif + scons to requirements in setup.py

parent 464fab49
......@@ -305,7 +305,7 @@ def add_attribute_to_links (src, attrname, attrvalue):
def template_action (target, source, env):
tpath, tname = os.path.split(env.Dictionary().get("SCONS_TEMPLATE"))
rootpath = os.path.abspath(env.Dictionary().get("SCONS_ROOT"))
print (f"template_action, rootpath: {rootpath}")
jenv = jinja2.Environment(loader=jinja2.FileSystemLoader(tpath))
jenv.filters['strftime'] = lambda x, format='%Y-%m-%d %H:%M:%S': datetime.datetime.fromisoformat(x).strftime(format)
......@@ -519,10 +519,12 @@ for folder, deps in depwalk("."):
depsmeta.append(file_meta)
env.FolderMeta(target=folder_meta_path, source=deps+depsmeta)
template_path = os.environ.get("SCONS_TEMPLATE") or "templates/index.html"
env.Template(target=os.path.join(folder, "index.html"), \
source=[folder_meta_path, File(template_path)], \
SCONS_TEMPLATE=os.environ.get("SCONS_TEMPLATE") or "templates/index.html", \
SCONS_TEMPLATE=template_path, \
SCONS_ROOT=os.environ.get("SCONS_ROOT") or rootdir.abspath
)
......@@ -25,27 +25,32 @@ def get_info(path, data=None):
data['image_format'] = d['format']
data['width'] = int(d['width'])
data['height'] = int(d['height'])
with open (path, "rb") as f:
im = ExifImage(f)
if im and im.has_exif:
if hasattr(im, "datetime_original"):
data['datetime_original'] = im.datetime_original
if hasattr(im, "model"):
data['model'] = im.model
if hasattr(im, "software"):
data['software'] = im.software
if hasattr(im, "lens_model"):
data['lens_model'] = im.lens_model
if hasattr(im, "flash") and hasattr(im.flash, "flash_fired"):
data['flash'] = im.flash.flash_fired
if hasattr(im, "f_number"):
data['f_number'] = im.f_number
if hasattr(im, "focal_length"):
data['focal_length'] = im.focal_length
if hasattr(im, "orientation") and hasattr(im.orientation, 'name'):
data['orientation'] = im.orientation.name
if hasattr(im, "exposure_time"):
data['exposure_time'] = im.exposure_time
print(f"attempting to ExifImage {path}")
try:
with open (path, "rb") as f:
im = ExifImage(f)
if im and im.has_exif:
if hasattr(im, "datetime_original"):
data['datetime_original'] = im.datetime_original
if hasattr(im, "model"):
data['model'] = im.model
if hasattr(im, "software"):
data['software'] = im.software
if hasattr(im, "lens_model"):
data['lens_model'] = im.lens_model
if hasattr(im, "flash") and hasattr(im.flash, "flash_fired"):
data['flash'] = im.flash.flash_fired
if hasattr(im, "f_number"):
data['f_number'] = im.f_number
if hasattr(im, "focal_length"):
data['focal_length'] = im.focal_length
if hasattr(im, "orientation") and hasattr(im.orientation, 'name'):
data['orientation'] = im.orientation.name
if hasattr(im, "exposure_time"):
data['exposure_time'] = im.exposure_time
except Exception as e:
pass
return data
......
......@@ -3,15 +3,31 @@ import sys, subprocess, os
def main (args):
datapath = os.path.join(os.path.dirname(os.path.realpath(__file__)), "data")
sconstruct_path = os.path.join(datapath, "templates", "Sconstruct.py")
template_path = os.path.join(datapath, "templates", "index-scons.html")
if args.template:
template_path = args.template
else:
template_path = os.path.join(datapath, "templates", "index-scons.html")
if args.sconstruct:
sconstruct_path = args.sconstruct
else:
sconstruct_path = os.path.join(datapath, "templates", "Sconstruct.py")
env = os.environ.copy()
env['scons-template'] = template_path
p = subprocess.run(["scons", "-f", sconstruct_path], env=env)
env['SCONS_TEMPLATE'] = template_path
cmd = ["scons", "-f", sconstruct_path] + args.path
if args.root:
env['SCONS_ROOT'] = args.root
p = subprocess.run(cmd, env=env, cwd=args.root)
else:
# set cwd to the root when given this determines where the .scons db is
p = subprocess.run(cmd, env=env)
def add_subparser (subparsers):
p = subparsers.add_parser('smake', help='Use scons to make directory indexes')
# p.add_argument("path")
p.add_argument('--template')
p.add_argument('--sconstruct')
# usage: go to root folder
p.add_argument('--root', help='root, default .')
p.add_argument('path', nargs="*")
p.set_defaults(func=main)
if __name__ == "__main__":
......
......@@ -33,5 +33,5 @@ setup(
license='LICENSE.txt',
description='Indexalist makes directory listings',
# long_description=open('README.md').read(),
install_requires=[ "isodate","jinja2","html5lib","gitignore_parser","python-magic","markdown" ]
install_requires=[ "isodate","jinja2","html5lib","gitignore_parser","python-magic","markdown","scons","exif" ]
)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment