Issue #54 new

Control Log Level whith the python API

Daniel de Paula
created an issue

I can't find a way to supress some warnings I get when parsing metadata from jpeg's. This is sort of important as my code is a crawler that sweeps thousands and thousands of files and I would like to use the error output for other stuff.

The code in question is something like:

def get_exif_date(filename):
    filename, realname = unicodeFilename(filename), filename
    parser = hachoir_parser.createParser(filename, realname)
    if not parser:
        print >>stderr, "Unable to parse file"
        exit(1)
    try:
        ## THIS IS THE POINT WHERE I GET WARNINGS
        metadata = hachoir_metadata.extractMetadata(parser)
    except HachoirError, err:
        print "Metadata extraction error: %s" % unicode(err)
        metadata = None
    if not metadata:
        print "Unable to extract metadata"
        exit(1)
    return metadata.get('creation_date')

This kind of code gives warnings for any photo without gps data. The warning is like the following:

[warn] Error when calling function readGPS(): Can't get field "value_entry[1][0]" from /exif/content/ifd[2]"

I would like to propose being able to call the metadata extractor as something in the line of :

metadata = hachoir_metadata.extractMetadata(parser, loglevel='error')

If this is already possible, I apologize. But I really tried to find this on the documentation to no avail. I know there is something similar at the command line, but couldn't find the pointers to do it with python

Comments (0)

  1. Log in to comment