havardgulldahl / jottalib

A library to access files stored at jottacloud.com.
GNU General Public License v3.0
83 stars 19 forks source link

Issues with strange file names... #125

Closed antonhagg closed 8 years ago

antonhagg commented 8 years ago

There are still some issues with character encoding...

Traceback (most recent call last): File "C:\Python27\Scripts\jotta-download-script.py", line 9, in <module> load_entry_point('jottalib==0.5.1', 'console_scripts', 'jotta-download')() File "c:\python27\lib\site-packages\jottalib\cli.py", line 392, in download if not download_jfsfile(remote_file, tofolder=_rel_folder_path, checksum=args.checksum): File "c:\python27\lib\site-packages\jottalib\cli.py", line 285, in download_jfsfile print_size(total_size, humanize=True))) as bar: File "c:\python27\lib\site-packages\clint\textui\progress.py", line 63, in __init__ self.show(0) File "c:\python27\lib\site-packages\clint\textui\progress.py", line 87, in show self.expected_size, self.etadisp)) File "c:\python27\lib\site-packages\clint\packages\colorama\ansitowin32.py", line 34, in write self.__convertor.write(text) File "c:\python27\lib\site-packages\clint\packages\colorama\ansitowin32.py", line 115, in write self.write_and_convert(text) File "c:\python27\lib\site-packages\clint\packages\colorama\ansitowin32.py", line 142, in write_and_convert self.write_plain_text(text, cursor, len(text)) File "c:\python27\lib\site-packages\clint\packages\colorama\ansitowin32.py", line 147, in write_plain_text self.wrapped.write(text[start:end]) File "c:\python27\lib\encodings\cp850.py", line 12, in encode return codecs.charmap_encode(input,errors,encoding_map) UnicodeEncodeError: 'charmap' codec can't encode character u'\u0161' in position 37: character maps to <undefined>

antonhagg commented 8 years ago

File names are:

file name="SPECIAL SURGERY - prednášky 3. ročník.doc" file name="Abdominal trauma Hošala.ppt" file name="praktiká 3. ročník.doc"

antonhagg commented 8 years ago

Think it's a problem with the ProgressBar. Quick fix was to rewrite some of the code.

       with open(topath, 'wb') as fh:
            bytes_read = 0
            puts(colored.white('Downloading: %s, size: %s \t' % (remote_object.name,print_size(total_size, humanize=True))))
            with ProgressBar(expected_size=total_size) as bar:
havardgulldahl commented 8 years ago

thanks, @antonhagg, I'll take a look