Skip to content

Commit

Permalink
fix exception catching
Browse files Browse the repository at this point in the history
  • Loading branch information
kevin1024 committed Aug 9, 2014
1 parent 78a8859 commit 054496e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
8 changes: 6 additions & 2 deletions fabric_remote/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@
from fabric.tasks import execute
from fabric.main import load_fabfile
from fabric.tasks import WrappedCallableTask
from StringIO import StringIO
from . import app
from .util import threadsafe_iter

class FabricException(Exception):
pass


class QueueIO(object):

Expand Down Expand Up @@ -44,6 +46,8 @@ def _load_fabfile(self):
)
# Don't prompt me bro
state.env.abort_on_prompts = True
# Let us capture exceptions
state.env.abort_exception = FabricException

def list_tasks(self):
self._load_fabfile()
Expand All @@ -61,7 +65,7 @@ def _execute(self, tasks, queue):
**task.get('kwargs', {})
)
queue.put({"results": (task, results)})
except Exception as e:
except FabricException as e:
queue.put({"error": str(e)})

def run_tasks(self, tasks):
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def run_tests(self):

setup(
name='fabric_remote',
version='0.0.1',
version='0.0.2',
long_description=__doc__,
description='REST API for Fabric',
url='https://github.com/kevin1024/fabric_remote/',
Expand Down
2 changes: 0 additions & 2 deletions tests/fixtures/fabfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ def host_type():
local('echo blah')
time.sleep(4)
local('echo blah')
time.sleep(4)
local('echo blah')
time.sleep(4)
local('echo blah')
env['foo'] = 'bar'
return "shit worked"
Expand Down

0 comments on commit 054496e

Please sign in to comment.