elodie
elodie copied to clipboard
UnicodeDecodeError when importing photos
Hi there! Thank you for this amazing software :-) It was just what I was looking for.
I've started to import a set of photos that I have with the suggested:
./elodie.py import --debug --destination=~/Pictures/organized ~/Pictures/conv
But after processing almost all, I got this error:
/home/familia/Pictures/conv/IMG_0039.JPG -> /home/familia/Pictures/organized/2015/Unknown Location/2015-07-18_16-31-41-img_0039.jpg
****** ERROR DETAILS ******
Traceback (most recent call last):
File "./elodie.py", line 345, in <module>
main()
File "/home/familia/.local/lib/python2.7/site-packages/click/core.py", line 716, in __call__
return self.main(*args, **kwargs)
File "/home/familia/.local/lib/python2.7/site-packages/click/core.py", line 696, in main
rv = self.invoke(ctx)
File "/home/familia/.local/lib/python2.7/site-packages/click/core.py", line 1060, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/home/familia/.local/lib/python2.7/site-packages/click/core.py", line 889, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/home/familia/.local/lib/python2.7/site-packages/click/core.py", line 534, in invoke
return callback(*args, **kwargs)
File "./elodie.py", line 119, in _import
result.write()
File "/home/familia/installs/elodie/elodie/result.py", line 29, in write
print(tabulate(error_result, headers=error_headers))
File "/home/familia/.local/lib/python2.7/site-packages/tabulate.py", line 1119, in tabulate
['\t'.join(map(_text_type, row)) for row in list_of_lists])
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 47: ordinal not in range(128)
I thought it was one off so I deleted the organized folder and the ~/.elodie/hash.json and started again. Same error. I then tried to just import that file but the error didn't appear so I'm guessing it's not that file but maybe the next in list ? What do you suggest ? Thank you.
Do you mind adding print(_file)
in filesystem.py
on line 324.?
Then run the command again and let me know which file it fails at. Ideally if you could send it to me then I could reproduce it. jaisen (at) githubusername (dot) com.
def process_file(self, _file, destination, media, **kwargs):
print(_file)
move = False
if('move' in kwargs):
move = kwargs['move']
Unfortunately I can no longer reproduce this :( I'm not aware of anything that has changed on the ~/Pictures/conv folder that was used for importing.
But I do notice that is a discrepancy on how much items were processed.
So I was expecting some similar like:
$ find ~/Pictures/conv -type f \( -iname "*.jpg" -o -iname "*.jpeg" -o -iname "*.png" -o -iname "*.mpg" -o -iname "*.mov" -o -iname "*.mp4" \) | wc -l
6275
And elodie output is:
****** SUMMARY ******
Metric Count
-------- -------
Success 6129
Error 80
So in total elodie processed 6209 vs 6275 of what I was expecting ? Should I raise a separate issue for this ?
I am able to reproduce this problem:
Traceback
(most recent call last): File "./elodie.py", line 345, in
main() File "/home/agrieco/.local/lib/python2.7/site-packages/click/core.py", line 716, in call return self.main(*args, **kwargs) File "/home/agrieco/.local/lib/python2.7/site-packages/click/core.py", line 696, in main rv = self.invoke(ctx) File "/home/agrieco/.local/lib/python2.7/site-packages/click/core.py", line 1060, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/home/agrieco/.local/lib/python2.7/site-packages/click/core.py", line 889, in invoke return ctx.invoke(self.callback, **ctx.params) File "/home/agrieco/.local/lib/python2.7/site-packages/click/core.py", line 534, in invoke return callback(*args, **kwargs) File "./elodie.py", line 115, in _import trash, allow_duplicates) File "./elodie.py", line 38, in import_file _file = _decode(_file) File "/home/agrieco/elodie/elodie/compatability.py", line 23, in _decode return string.decode(encoding) UnicodeDecodeError: 'ascii' codec can't decode byte 0xef in position 49: ordinal not in range(128)
It looks like an issue related to the terminal coding.
For whatever reason- my terminal was using 'ANSI_X3.4-1968' as its coding (found by printing "encoding" variable in compatability.py. I hard coded it in the code to use utf-8 and things seem fine. (return string.decode('utf-8'))
$ sudo python -c "import sys; print(sys.stdout.encoding)"
Gives me UTF-8
I added the print(_file) statement. Will report back.
It didnt print out the file... What to do?
Can you include the stack trace?
****** ERROR DETAILS ******
Traceback (most recent call last):
File "./elodie.py", line 371, in <module>
main()
File "/home/jogai/.local/lib/python2.7/site-packages/click/core.py", line 716, in __call__
return self.main(*args, **kwargs)
File "/home/jogai/.local/lib/python2.7/site-packages/click/core.py", line 696, in main
rv = self.invoke(ctx)
File "/home/jogai/.local/lib/python2.7/site-packages/click/core.py", line 1060, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/home/jogai/.local/lib/python2.7/site-packages/click/core.py", line 889, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/home/jogai/.local/lib/python2.7/site-packages/click/core.py", line 534, in invoke
return callback(*args, **kwargs)
File "./elodie.py", line 144, in _import
result.write()
File "/home/jogai/src/elodie/elodie/result.py", line 29, in write
print(tabulate(error_result, headers=error_headers))
File "/home/jogai/.local/lib/python2.7/site-packages/tabulate.py", line 1119, in tabulate
['\t'.join(map(_text_type, row)) for row in list_of_lists])
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 47: ordinal not in range(128)
I did the whole thing in batches and then I didn't encounter the error.