insanum / sncli

Simplenote CLI
MIT License
396 stars 34 forks source link

Piping is not working #48

Closed MatthiasKauer closed 6 years ago

MatthiasKauer commented 6 years ago

Hi, I am trying to pipe content to another program using the | key.

From within a note, I get the following traceback. I typed "cat" in the input field that appears on the bottom after pressing |.

Traceback (most recent call last):                                                                                                                                               
  File "/home/matt/venv/sncli/bin/sncli", line 11, in <module>
    sys.exit(main())
  File "/home/matt/venv/sncli/lib/python3.5/site-packages/simplenote_cli/sncli.py", line 1244, in main
    sncli(sync, verbose, config).gui(key)
  File "/home/matt/venv/sncli/lib/python3.5/site-packages/simplenote_cli/sncli.py", line 1032, in gui
    self.sncli_loop.run()
  File "/home/matt/venv/sncli/lib/python3.5/site-packages/urwid/main_loop.py", line 278, in run
    self._run()
  File "/home/matt/venv/sncli/lib/python3.5/site-packages/urwid/main_loop.py", line 376, in _run
    self.event_loop.run()
  File "/home/matt/venv/sncli/lib/python3.5/site-packages/urwid/main_loop.py", line 682, in run
    self._loop()
  File "/home/matt/venv/sncli/lib/python3.5/site-packages/urwid/main_loop.py", line 719, in _loop
    self._watch_files[fd]()
  File "/home/matt/venv/sncli/lib/python3.5/site-packages/urwid/raw_display.py", line 393, in <lambda>
    event_loop, callback, self.get_available_raw_input())
  File "/home/matt/venv/sncli/lib/python3.5/site-packages/urwid/raw_display.py", line 493, in parse_input
    callback(processed, processed_codes)
  File "/home/matt/venv/sncli/lib/python3.5/site-packages/urwid/main_loop.py", line 403, in _update
    self.process_input(keys)
  File "/home/matt/venv/sncli/lib/python3.5/site-packages/urwid/main_loop.py", line 503, in process_input
    k = self._topmost_widget.keypress(self.screen_size, k)
  File "/home/matt/venv/sncli/lib/python3.5/site-packages/urwid/container.py", line 1587, in keypress
    key = self.focus.keypress(tsize, key)
  File "/home/matt/venv/sncli/lib/python3.5/site-packages/simplenote_cli/user_input.py", line 22, in keypress
    self.callback_func(self.callback_func_args, self.edit_text)
  File "/home/matt/venv/sncli/lib/python3.5/site-packages/simplenote_cli/sncli.py", line 395, in gui_pipe_input
    pipe.communicate(note['content'])
  File "/usr/lib/python3.5/subprocess.py", line 1057, in communicate
    self._stdin_write(input)
  File "/usr/lib/python3.5/subprocess.py", line 1012, in _stdin_write
    self.stdin.write(input)
TypeError: a bytes-like object is required, not 'str'

Also tried "echo" on a note from the list or index viewer. Similar result.

(sncli) x AD99W matt@hp840:~/venv $ sncli
Traceback (most recent call last):
  File "/home/matt/venv/sncli/bin/sncli", line 11, in <module>
    sys.exit(main())
  File "/home/matt/venv/sncli/lib/python3.5/site-packages/simplenote_cli/sncli.py", line 1244, in main
    sncli(sync, verbose, config).gui(key)
  File "/home/matt/venv/sncli/lib/python3.5/site-packages/simplenote_cli/sncli.py", line 1032, in gui
    self.sncli_loop.run()
  File "/home/matt/venv/sncli/lib/python3.5/site-packages/urwid/main_loop.py", line 278, in run
    self._run()
  File "/home/matt/venv/sncli/lib/python3.5/site-packages/urwid/main_loop.py", line 376, in _run
    self.event_loop.run()
  File "/home/matt/venv/sncli/lib/python3.5/site-packages/urwid/main_loop.py", line 682, in run
    self._loop()
  File "/home/matt/venv/sncli/lib/python3.5/site-packages/urwid/main_loop.py", line 719, in _loop
    self._watch_files[fd]()
  File "/home/matt/venv/sncli/lib/python3.5/site-packages/urwid/raw_display.py", line 393, in <lambda>
    event_loop, callback, self.get_available_raw_input())
  File "/home/matt/venv/sncli/lib/python3.5/site-packages/urwid/raw_display.py", line 493, in parse_input
    callback(processed, processed_codes)
  File "/home/matt/venv/sncli/lib/python3.5/site-packages/urwid/main_loop.py", line 403, in _update
    self.process_input(keys)
  File "/home/matt/venv/sncli/lib/python3.5/site-packages/urwid/main_loop.py", line 503, in process_input
    k = self._topmost_widget.keypress(self.screen_size, k)
  File "/home/matt/venv/sncli/lib/python3.5/site-packages/urwid/container.py", line 1587, in keypress
    key = self.focus.keypress(tsize, key)
  File "/home/matt/venv/sncli/lib/python3.5/site-packages/simplenote_cli/user_input.py", line 22, in keypress
    self.callback_func(self.callback_func_args, self.edit_text)
  File "/home/matt/venv/sncli/lib/python3.5/site-packages/simplenote_cli/sncli.py", line 395, in gui_pipe_input
    pipe.communicate(note['content'])
  File "/usr/lib/python3.5/subprocess.py", line 1057, in communicate
    self._stdin_write(input)
  File "/usr/lib/python3.5/subprocess.py", line 1012, in _stdin_write
    self.stdin.write(input)
TypeError: a bytes-like object is required, not 'str'

I am running sncli in a virtualenv with Python 3.5 on Linux Mint 18.2 Xfce 64-bit.

Can you make sense of that? Best regards, Matthias

samuelallan72 commented 6 years ago

Can you confirm which version/commit of sncli you are running?

MatthiasKauer commented 6 years ago

Here's what I could find out after a bit of digging:

(sncli) o AD9mi matt@hp840:~/venv/sncli/lib/python3.5/site-packages/simplenote_cli $ cat __init__.py 
__productname__ = 'sncli'
__version__ = '0.1.4'
__copyright__ = "Copyright (c) 2014 Eric Davis"
__author__ = "Eric Davis"
...

Is there a version command too?

samuelallan72 commented 6 years ago

Sorry there isn't a version command (yet). So it looks like you are running the 0.1.4 release - I had a look through the log and found that a few commits after that release this piping issue was fixed (in pull request #42). You could either update to the latest git master (via pip or manually building), or wait for the next release (I see if I can get around to it soon). :)

MatthiasKauer commented 6 years ago

I have installed the latest version from master now. Piping looks good there.