fab-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Fab-user] No hosts found - Fabric execution model: works only on relati


From: Alec Taylor
Subject: [Fab-user] No hosts found - Fabric execution model: works only on relative imports?
Date: Wed, 27 Jan 2016 16:21:13 +1100

Using Fabric outside a fabfile. `fabric.api.execute` on relative imported functions works.

Importing other installed modules fails with "No hosts found. Please specify (single) host string for connection:"

To illustrate, this works:

## foo/__init__.py

from fabric.api import execute
from bar import funtimes

domain = 'localhost'
env.user = 'bar'
env.password = 'foo'
env.hosts = [domain]

execute(funtimes)

## foo/bar.py

from fabric.api import run

def funtimes(): run('hello funtimes')

Whilst this fails:

## foo/__init__.py

from fabric.api import execute
from can.haz import funtimes

domain = 'localhost'
env.user = 'bar'
env.password = 'foo'
env.hosts = [domain]

execute(funtimes)

## can/haz.py

from fabric.api import run

def funtimes(): run('hello funtimes')

# also tried
def funtimes2(env):
    fabric.api.env = env
    run('hello funtimes2')


reply via email to

[Prev in Thread] Current Thread [Next in Thread]