tmurph / todo-sync

Sync Emacs Org mode with Asana

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error attempting to sync RuntimeError: generator raised StopIteration

mikedmcfarland opened this issue · comments

I'm getting errors while trying to sync to and from an asana account.
I'm not sure what's relevant so ill try to provide all I can

I'm on mac osx using
Python 3.7.0 and GNU Emacs 25.3.1

I've cloned both this repo, and org mode inside ~/.emacs.d/vendor Ended up using org modes maint branch instead of master (with master I got complaints of missing functions in todo-sync otherwise)

I created a minimal config
cat ~/.emacs.d/todo-sync-config.el

;;; we need the downloaded version of Org
(add-to-list 'load-path "~/.emacs.d/vendor/todo-sync/emacs")
(add-to-list 'load-path "~/.emacs.d/vendor/org-mode/lisp")

;;; and we need to set Org agenda files
(defvar org-directory (expand-file-name "~/notes"))
(defvar org-agenda-files '("asanaTasks.org"))

also created a script for pushing tasks
cat push-home-tasks

#!/bin/bash
asanaToken=***
initFile="~/.emacs.d/todo-sync-config.el"
todo-sync asana $asanaToken org $initFile -v

However it throws a generator raised StopIteration

Get From Source:
 (ts-init)

Tag Find by Workspace:
 796042258360695

Send To Source:
 (ts-final)

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/asana/page_iterator.py", line 61, in items
    raise StopIteration
StopIteration

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/bin/todo-sync", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.7/site-packages/todo_sync/command_line.py", line 51, in main
    edit_script(b_source.get_tree(), a_source.get_tree(),
  File "/usr/local/lib/python3.7/site-packages/todo_sync/backends/asana.py", line 345, in get_all_items
    for tag in all_tags:
RuntimeError: generator raised StopIteration

Interestingly it actually edits the task file with properties
cat asanaTasks.org

* funtimes
:PROPERTIES:
:ID:       688076AD-1A48-4DE1-9F92-F8AED2659BC6
:END:
- a note

When trying to retrieve tasks I also get an error
cat retrieve-home-tasks

#!/bin/bash
asanaToken=****
initFile="~/.emacs.d/todo-sync-config.el"
todo-sync org $initFile asana $asanaToken -v
Get From Source:
 (ts-init)

Get From Source:
 (ts-get-all-headlines '(:id :title :paragraph :parent-id :todo-type :closed :deadline :filename :tags :asana_id :asana_project_id))

Send To Source:
 (ts-final)

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/pexpect/expect.py", line 111, in expect_loop
    incoming = spawn.read_nonblocking(spawn.maxread, timeout)
  File "/usr/local/lib/python3.7/site-packages/pexpect/pty_spawn.py", line 485, in read_nonblocking
    return super(spawn, self).read_nonblocking(size)
  File "/usr/local/lib/python3.7/site-packages/pexpect/spawnbase.py", line 176, in read_nonblocking
    raise EOF('End Of File (EOF). Empty string style platform.')
pexpect.exceptions.EOF: End Of File (EOF). Empty string style platform.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/todo_sync/command_line.py", line 51, in main
    edit_script(b_source.get_tree(), a_source.get_tree(),
  File "/usr/local/lib/python3.7/site-packages/todo_sync/mappers/org_to_asana.py", line 59, in <lambda>
    ['asana_id', 'asana_project_id'])
  File "/usr/local/lib/python3.7/site-packages/todo_sync/backends/org.py", line 245, in get_all_items
    elisp_string_from_list(field_list)))
  File "/usr/local/lib/python3.7/site-packages/todo_sync/helpers.py", line 46, in wrapped_fn
    return fn(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/pexpect/replwrap.py", line 95, in run_command
    if self._expect_prompt(timeout=timeout) == 1:
  File "/usr/local/lib/python3.7/site-packages/pexpect/replwrap.py", line 66, in _expect_prompt
    timeout=timeout)
  File "/usr/local/lib/python3.7/site-packages/pexpect/spawnbase.py", line 418, in expect_exact
    return exp.expect_loop(timeout)
  File "/usr/local/lib/python3.7/site-packages/pexpect/expect.py", line 117, in expect_loop
    return self.eof(e)
  File "/usr/local/lib/python3.7/site-packages/pexpect/expect.py", line 63, in eof
    raise EOF(msg)
pexpect.exceptions.EOF: End Of File (EOF). Empty string style platform.
<pexpect.pty_spawn.spawn object at 0x1027ebc88>
command: /usr/local/bin/emacs
args: [b'/usr/local/bin/emacs', b'-batch', b'-l', b'~/.emacs.d/todo-sync-config.el', b'-l', b'ts-org-interaction.el', b'--eval=(ts-repl)']
buffer (last 100 chars): ''
before (last 100 chars): 'Args out of range: "", 2, nil\r\n'
after: <class 'pexpect.exceptions.EOF'>
match: None
match_index: None
exitstatus: None
flag_eof: True
pid: 24682
child_fd: 5
closed: False
timeout: 30
delimiter: <class 'pexpect.exceptions.EOF'>
logfile: None
logfile_read: None
logfile_send: None
maxread: 2000
ignorecase: False
searchwindowsize: None
delaybeforesend: 0.05
delayafterclose: 0.1
delayafterterminate: 0.1
searcher: searcher_string:
    0: 'Lisp expression: '
    1: '[PEXPECT_PROMPT+'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/bin/todo-sync", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.7/site-packages/todo_sync/command_line.py", line 53, in main
    args.no_delete)
  File "/usr/local/lib/python3.7/site-packages/todo_sync/backends/org.py", line 211, in __exit__
    self._repl_to_source_command('(ts-final)')
  File "/usr/local/lib/python3.7/site-packages/todo_sync/helpers.py", line 46, in wrapped_fn
    return fn(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/pexpect/replwrap.py", line 88, in run_command
    self.child.sendline(cmdlines[0])
  File "/usr/local/lib/python3.7/site-packages/pexpect/pty_spawn.py", line 555, in sendline
    return self.send(s + self.linesep)
  File "/usr/local/lib/python3.7/site-packages/pexpect/pty_spawn.py", line 546, in send
    return os.write(self.child_fd, b)
OSError: [Errno 5] Input/output error

Is there something silly I'm missing?

Seconded! getting the same thing. I've just tried the 'Sync from asana to org' and get the same StopIteration error for /page_iterator.py", line 61.

Not sure what I'm missing or doing wrong though?

Sorry I'm just now seeing this! Had email notifications set incorrectly. I'll take a look and get back to you.

I can recreate the bug on my side, thanks for letting me know. I can't dig into it today, but I'll keep you posted with progress.

So I discovered that the StopIteration error is due to a bug in the upstream python-asana project. They haven't updated their codebase to comply with PEP 479, and Python 3.6 was the last python to support the pre-479 semantics.

I guess maybe it's not technically a bug? I never realized this, but it seems the python-asana developers aren't currently trying to support Python 3 at all. I just got lucky that their code works out of the box for Python up through 3.6.

I'll need to think a little more about the best way to work around this issue in the todo-sync codebase, but just wanted to give an update. I'll keep you posted.

@riaandewit @mikedmcfarland

@mikedmcfarland I just noticed your Emacs-related bug report. I can't reproduce that on my end.

Could you try running the following from the command line and let me know what happens? It should print "Success!" but I expect it'll give you an error.

/usr/local/bin/emacs -batch -l ~/.emacs.d/todo-sync-config.el -l ts-org-interaction.el --eval='(princ "Success!\n")'

Hey all. So I've decided that, since this is a bug in an upstream library that only affects Python 3.7, I'm simply not going to support 3.7 for the time being. I've updated the documentation and setup scripts to say so.

I've submitted a bug report to the python-asana project, and when/if they fix the issue I'll update the requirements and documentation.

The best thing to do is downgrade to Python 3.6 for using todo-sync.

That being said ... if you don't want to downgrade to 3.6, I've made a branch that implements a workaround. I’m in no rush to merge this branch, but I mean if python-asana never supports 3.7 then I’ll include it in a future release.

You can install the workaround branch with the following command:

$ pip install --upgrade git+https://github.com/tmurph/todo-sync.git@wrap-broken-asana#egg=todo-sync