sylikc / pyexiftool

PyExifTool (active PyPI project) - A Python library to communicate with an instance of Phil Harvey's ExifTool command-line application. Runs one process with special -stay_open flag, and pipes data to/from. Much more efficient than running a subprocess for each command!
Other
148 stars 19 forks source link

Start instance automatically #18

Closed jangop closed 2 years ago

jangop commented 3 years ago

There is a check in execute to see if an instance is running, but it raises an exception instead of launching an instance: https://github.com/sylikc/pyexiftool/blob/1e9b4b34abac6d4294a5958494c7b1b4c1391589/exiftool/exiftool.py#L439

What is the reasoning behind requiring the user to start an instance manually? Are there situations in which doing this lazily would cause problems?

sylikc commented 3 years ago

@jangop the original behavior of the code that i'm forked from did this. I've left it as is in the current iteration

Currently, I have an active v0.5.x-py3-refactor branch ongoing which is going to change a lot of things, including this behavior, but create a class that wraps around it. See this discussion Break down Exiftool into 2+ classes, a raw Exiftool, and helper classes #10

I understand the inconvenience of using the class having to do many things manually. So as per that discussion, I'm creating the core ExifTool class which will require you to do everything manually and complain about every error under the sun it can catch... and then have a ExifToolHelper class that wraps/extends it to provide ExifTool-for-dummies experience

I invite you to participate in that discussion or look at what has been changed thus far on the branch via PR https://github.com/sylikc/pyexiftool/pull/13 , which gives you an idea where this is heading. I'm open to ideas on how to make life easier / more usability features on the extended class(es).