Hi there,
I have a commandline script which uses optparse and pyexiv2 modules. It is
working fine through windows command line. But when I generate the .exe and
run it, it returns one of the following errors:
LookupError: unknown encoding: mbcs
or
LookupError: unknown encoding: cp850
Last week Ive made a very similar script and had no problem at all (it was
another computer). Wonder if anybody has a clue.
My setup script and my actual scripr are pasted bellow
thanks
Leo,,
==== setup script =====
from distutils.core import setup
import py2exe
import sys
# no arguments
if len(sys.argv) == 1:
sys.argv.append("py2exe")
sys.argv.append("-q")
# creates a standalone .exe file, no zip files
setup( options = {"py2exe": {"compressed": 1, "optimize": 2, "ascii": 1,
"bundle_files": 1}},
zipfile = None,
# replace myFile.py with your own code filename here ...
console = [{"script": 'extractXMP.py'}] )
=======================================================
============== extractXMP.py =============================
>
p = optparse.OptionParser(description=' Extrai os metadados XMP de um
arquivo jpg e escreve em um txt com o mesmo nome',
prog='./extractXMP.py',
version='0.1',
usage='%prog nomeDoArquivo.jpg')
p.add_option("-f", "--filter", help="especifica um arquivo com parametros de
filtro")
def extractMetaData(image):
meta = pyexiv2.ImageMetadata(image)
meta.read()
output = ''
filter = None
if options.filter :
filter = dict()
for line in open(options.filter, 'r') :
if line.strip():
key, value = [str.strip() for str in line.split(':')]
filter[key] = value
if not filter or filter.get('filename'):
chave = 'filename' if not filter else filter['filename']
output += chave + ': ' + image + '\n'
for key in meta.exif_keys :
if not filter or filter.get(key):
chave = key if not filter else filter[key]
output += chave + ': ' + meta[key].raw_value + '\n'
for key in meta.iptc_keys :
if not filter or filter.get(key):
chave = key if not filter else filter[key]
output += chave + ': '
for value in meta[key].raw_values :
output += value + '; '
output += '\n'
file = open(image + ".txt", "w")
file.write(output)
file.close()
print output
options, args = p.parse_args()
if len(args) == 1:
extractMetaData(args[0])
else:
p.print_help()
--
leogermani.pirex.com.br
leogermani.estudiolivre.org
|