b3ni / Sublime-Fabric

Sublime Text plugin for running tasks Fabric / Python
MIT License
19 stars 5 forks source link

Setting a host inside of the fab file #11

Open rkpatel33 opened 9 years ago

rkpatel33 commented 9 years ago

I have this simple code which works when run from the command line, but not from the SublimeText Fabric add-in. Any ideas on the right way to solve it?

def deploy_staging():
    '''deploy to staging, ie $ fab -H staging deploy'''
    env.host_string = 'staging'
    env.host = 'staging'
    run('ls')

I get the following error in SublimeText:

Import of some modules failed. Make sure you don't need them.
[staging] run: ls
Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/fabric/main.py", line 743, in main
    *args, **kwargs
  File "/Library/Python/2.7/site-packages/fabric/tasks.py", line 405, in execute
    results['<local-only>'] = task.run(*args, **new_kwargs)
  File "/Library/Python/2.7/site-packages/fabric/tasks.py", line 171, in run
    return self.wrapped(*args, **kwargs)
  File "/Users/rishi/git/docnav/fabfile.py", line 81, in deploy_staging
    run('ls')
  File "/Library/Python/2.7/site-packages/fabric/network.py", line 578, in host_prompting_wrapper
    return func(*args, **kwargs)
  File "/Library/Python/2.7/site-packages/fabric/operations.py", line 1042, in run
    shell_escape=shell_escape)
  File "/Library/Python/2.7/site-packages/fabric/operations.py", line 909, in _run_command
    channel=default_channel(), command=wrapped_command, pty=pty,
  File "/Library/Python/2.7/site-packages/fabric/state.py", line 388, in default_channel
    chan = _open_session()
  File "/Library/Python/2.7/site-packages/fabric/state.py", line 380, in _open_session
    return connections[env.host_string].get_transport().open_session()
  File "/Library/Python/2.7/site-packages/fabric/network.py", line 118, in __getitem__
    self.connect(key)
  File "/Library/Python/2.7/site-packages/fabric/network.py", line 110, in connect
    self[key] = connect(user, host, port, sock)
  File "/Library/Python/2.7/site-packages/fabric/network.py", line 472, in connect
    raise NetworkError('Name lookup failed for %s' % host, e)
fabric.exceptions.NetworkError: Name lookup failed for staging