How to use the osxphotos.exiftool.get_exiftool_path function in osxphotos

To help you get started, we’ve selected a few osxphotos examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github RhetTbull / osxphotos / tests / test_exiftool.py View on Github external
def test_get_exiftool_path():
    import osxphotos.exiftool

    exiftool = osxphotos.exiftool.get_exiftool_path()
    assert exiftool is not None
github RhetTbull / osxphotos / tests / test_exiftool.py View on Github external
def test_exiftoolproc_exiftool():
    import osxphotos.exiftool

    exif1 = osxphotos.exiftool.ExifTool(TEST_FILE_ONE_KEYWORD)
    assert exif1._exiftoolproc.exiftool == osxphotos.exiftool.get_exiftool_path()
github RhetTbull / osxphotos / tests / test_cli.py View on Github external
"albums": {
        "Raw": 4,
        "Pumpkin Farm": 3,
        "AlbumInFolder": 2,
        "Test Album": 2,
        "I have a deleted twin": 1,
        "EmptyAlbum": 0,
    },
    "shared albums": {},
}

PERSONS_JSON = {"persons": {"Katie": 3, "Suzy": 2, "_UNKNOWN_": 1, "Maria": 2}}

# determine if exiftool installed so exiftool tests can be skipped
try:
    exiftool = get_exiftool_path()
except:
    exiftool = None


def test_osxphotos():
    import osxphotos
    from osxphotos.__main__ import cli

    runner = CliRunner()
    result = runner.invoke(cli, [])
    output = result.output

    assert result.exit_code == 0
    for line in CLI_OUTPUT_NO_SUBCOMMAND:
        assert line.strip() in output
github RhetTbull / osxphotos / tests / test_exiftool.py View on Github external
"plastic",
            "stock photo",
            "vibrant",
        ],
        "IPTC:DocumentNotes": "https://flickr.com/e/l7FkSm4f2lQkSV3CG6xlv8Sde5uF3gVu4Hf0Qk11AnU%3D",
    },
    "E9BC5C36-7CD1-40A1-A72B-8B8FAC227D51": {
        "EXIF:Make": "NIKON CORPORATION",
        "EXIF:Model": "NIKON D810",
        "IPTC:DateCreated": "2019:04:15",
    },
}
EXIF_UUID_NONE = ["A1DD1F98-2ECD-431F-9AC9-5AFEFE2D3A5C"]

try:
    exiftool = get_exiftool_path()
except:
    exiftool = None

if exiftool is None:
    pytest.skip("could not find exiftool in path", allow_module_level=True)


def test_get_exiftool_path():
    import osxphotos.exiftool

    exiftool = osxphotos.exiftool.get_exiftool_path()
    assert exiftool is not None


def test_version():
    import osxphotos.exiftool
github RhetTbull / osxphotos / osxphotos / __main__.py View on Github external
]
    if any(all(bb) for bb in exclusive):
        click.echo("Incompatible export options", err=True)
        click.echo(cli.commands["export"].get_help(ctx), err=True)
        return

    # initialize export flags
    # by default, will export all versions of photos unless skip flag is set
    (export_edited, export_bursts, export_live, export_raw) = [
        not x for x in [skip_edited, skip_bursts, skip_live, skip_raw]
    ]

    # verify exiftool installed an in path
    if exiftool:
        try:
            _ = get_exiftool_path()
        except FileNotFoundError:
            click.echo(
                "Could not find exiftool. Please download and install"
                " from https://exiftool.org/",
                err=True,
            )
            ctx.exit(2)

    isphoto = ismovie = True  # default searches for everything
    if only_movies:
        isphoto = False
    if only_photos:
        ismovie = False

    # below needed for to make CliRunner work for testing
    cli_db = cli_obj.db if cli_obj is not None else None
github RhetTbull / osxphotos / osxphotos / photoinfo / _photoinfo_exiftool.py View on Github external
def exiftool(self):
    """ Returns an ExifTool object for the photo
        requires that exiftool (https://exiftool.org/) be installed
        If exiftool not installed, logs warning and returns None
        If photo path is missing, returns None
    """
    try:
        # return the memoized instance if it exists
        return self._exiftool
    except AttributeError:
        try:
            exiftool_path = get_exiftool_path()
            if self.path is not None and os.path.isfile(self.path):
                exiftool = ExifTool(self.path)
            else:
                exiftool = None
                logging.debug(f"exiftool: missing path {self.uuid}")
        except FileNotFoundError:
            # get_exiftool_path raises FileNotFoundError if exiftool not found
            exiftool = None
            logging.warning(
                f"exiftool not in path; download and install from https://exiftool.org/"
            )

        self._exiftool = exiftool
        return self._exiftool