Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2.2.0 'Task' object has no attribute 'hosts' #1824

Closed
ilovezfs opened this issue Jul 14, 2018 · 5 comments
Closed

2.2.0 'Task' object has no attribute 'hosts' #1824

ilovezfs opened this issue Jul 14, 2018 · 5 comments

Comments

@ilovezfs
Copy link

  test do
    (testpath/"fabfile.py").write <<~EOS
      from invoke import task
      import fabric
      @task
      def hello(c):
        c.run("echo {}".format(fabric.__version__))
    EOS
    assert_equal version.to_s, shell_output("#{bin}/fab hello").chomp
  end
bash-3.2$ cat fabfile.py 
from invoke import task
import fabric
@task
def hello(c):
  c.run("echo {}".format(fabric.__version__))
==> /usr/local/Cellar/fabric/2.2.0/bin/fab hello
Traceback (most recent call last):
  File "/usr/local/Cellar/fabric/2.2.0/bin/fab", line 11, in <module>
    load_entry_point('fabric==2.2.0', 'console_scripts', 'fab')()
  File "/usr/local/Cellar/fabric/2.2.0/libexec/lib/python2.7/site-packages/invoke/program.py", line 335, in run
    self.execute()
  File "/usr/local/Cellar/fabric/2.2.0/libexec/lib/python2.7/site-packages/invoke/program.py", line 491, in execute
    executor.execute(*self.tasks)
  File "/usr/local/Cellar/fabric/2.2.0/libexec/lib/python2.7/site-packages/invoke/executor.py", line 95, in execute
    expanded = self.expand_calls(calls)
  File "/usr/local/Cellar/fabric/2.2.0/libexec/lib/python2.7/site-packages/fabric/executor.py", line 62, in expand_calls
    cxn_params = self.normalize_hosts(cli_hosts or call.hosts)
  File "/usr/local/Cellar/fabric/2.2.0/libexec/lib/python2.7/site-packages/invoke/tasks.py", line 396, in __getattr__
    return getattr(self.task, name)
AttributeError: 'Task' object has no attribute 'hosts'
@ilovezfs ilovezfs changed the title 2.2.20 'Task' object has no attribute 'hosts' 2.2.0 'Task' object has no attribute 'hosts' Jul 14, 2018
@max-arnold
Copy link

Same here:

from invoke import task

@task
def test_task(ctx):
    ctx.run('pwd')
% pip freeze | grep -E '(fabric|invoke)'
fabric==2.2.0
invoke==1.1.0
% fab test-task

Traceback (most recent call last):
  File "/Users/user/.virtualenvs/testenv/bin/fab", line 11, in <module>
    sys.exit(program.run())
  File "/Users/user/.virtualenvs/testenv/lib/python3.6/site-packages/invoke/program.py", line 335, in run
    self.execute()
  File "/Users/user/.virtualenvs/testenv/lib/python3.6/site-packages/invoke/program.py", line 491, in execute
    executor.execute(*self.tasks)
  File "/Users/user/.virtualenvs/testenv/lib/python3.6/site-packages/invoke/executor.py", line 95, in execute
    expanded = self.expand_calls(calls)
  File "/Users/user/.virtualenvs/testenv/lib/python3.6/site-packages/fabric/executor.py", line 62, in expand_calls
    cxn_params = self.normalize_hosts(cli_hosts or call.hosts)
  File "/Users/user/.virtualenvs/testenv/lib/python3.6/site-packages/invoke/tasks.py", line 396, in __getattr__
    return getattr(self.task, name)
AttributeError: 'Task' object has no attribute 'hosts'

@ionling
Copy link

ionling commented Jul 17, 2018

Same for me with fabric2==2.2.0.

@max-arnold
Copy link

Workaround: replace from invoke import task with from fabric import task.

@bitprophet
Copy link
Member

This sounds like a big oops on my part, I didn't fully test backwards compatibility. should be an easy fix, I'll jump on it ASAP. Thanks for the reports!

bitprophet added a commit that referenced this issue Jul 18, 2018
bitprophet added a commit that referenced this issue Jul 18, 2018
bitprophet added a commit that referenced this issue Jul 18, 2018
One getattr and dozens of test/doc lines later...
@bitprophet
Copy link
Member

Grump, the actual Travis build got canceled because of later pushes, meaning the autofix commit message didn't take effect.

It's green, it's on PyPI, hooray.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants