insanum / sncli

Simplenote CLI
MIT License
396 stars 34 forks source link

crash on edit #17

Closed stevepowell99 closed 9 years ago

stevepowell99 commented 9 years ago

hi, sncli crashes when I press e for edit. On ubuntu 14.04, 64bit.

shawnaxsom commented 9 years ago

Hi Steve, I am also on Ubuntu 14.04 64-bit, and this isn't occurring for me. Can you provide some more details?

stevepowell99 commented 9 years ago

EDITOR=/usr/bin/gedit No errors in the log file. Sorry don't understand "what screen are you on". Desktop environment is mate. Error message in terminal is:

File "/usr/local/lib/python2.7/dist-packages/urwid/raw_display.py", line 392, in event_loop, callback, self.get_available_raw_input()) File "/usr/local/lib/python2.7/dist-packages/urwid/raw_display.py", line 492, in parse_input callback(processed, processed_codes) File "/usr/local/lib/python2.7/dist-packages/urwid/main_loop.py", line 399, in _update self.process_input(keys) File "/usr/local/lib/python2.7/dist-packages/urwid/main_loop.py", line 499, in process_input k = self._topmost_widget.keypress(self.screen_size, k) File "/usr/local/lib/python2.7/dist-packages/simplenote_cli/sncli.py", line 631, in gui_frame_keypress content = self.exec_cmd_on_note(note) File "/usr/local/lib/python2.7/dist-packages/simplenote_cli/sncli.py", line 93, in exec_cmd_on_note tf = temp.tempfile_create(note if note else None, raw=raw) File "/usr/local/lib/python2.7/dist-packages/simplenote_cli/temp.py", line 21, in tempfile_create tf.write(note['content']) UnicodeEncodeError: 'ascii' codec can't encode character u'\u201c' in position 1538: ordinal not in range(128)

shawnaxsom commented 9 years ago

Thanks! It looks like you are using Unicode, and the Python "tempfile" library is being used. tempfile doesn't directly support Unicode, so sncli would need to be modified to encode the unicode string contents you are trying to save for the note. http://stackoverflow.com/questions/10490816/how-to-create-a-temporary-file-with-unicode-encoding

I may be able to try reproducing and changing that line, that shouldn't be difficult. I'm not sure if the other parts of sncli are compatible with Unicode, though. If your native language / usage doesn't require Unicode, you should be able to get around this error by switching gedit to UTF-8 encoding. http://blog.tryphon.org/alban/2008/01/14/utf-8-by-default-for-gedit/ http://askubuntu.com/questions/98036/how-to-set-encoding-in-gedit-3-2

shawnaxsom commented 9 years ago

Hi Steve,

I have committed a change in the master branch that should fix your issue.

I was able to reproduce your issue. Issue #13 is related. I also found a separate issue with Gedit where changes made in Gedit weren't being recognized by the program, resulting in a "note unchanged" message. This should be fixed as well.

Please let me know if you have any issues editing or saving still. If not I will close this issue soon.