Skip to content

Commit 054496e

Browse files
committed
fix exception catching
1 parent 78a8859 commit 054496e

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

fabric_remote/tasks.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@
77
from fabric.tasks import execute
88
from fabric.main import load_fabfile
99
from fabric.tasks import WrappedCallableTask
10-
from StringIO import StringIO
1110
from . import app
1211
from .util import threadsafe_iter
1312

13+
class FabricException(Exception):
14+
pass
15+
1416

1517
class QueueIO(object):
1618

@@ -44,6 +46,8 @@ def _load_fabfile(self):
4446
)
4547
# Don't prompt me bro
4648
state.env.abort_on_prompts = True
49+
# Let us capture exceptions
50+
state.env.abort_exception = FabricException
4751

4852
def list_tasks(self):
4953
self._load_fabfile()
@@ -61,7 +65,7 @@ def _execute(self, tasks, queue):
6165
**task.get('kwargs', {})
6266
)
6367
queue.put({"results": (task, results)})
64-
except Exception as e:
68+
except FabricException as e:
6569
queue.put({"error": str(e)})
6670

6771
def run_tasks(self, tasks):

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def run_tests(self):
2727

2828
setup(
2929
name='fabric_remote',
30-
version='0.0.1',
30+
version='0.0.2',
3131
long_description=__doc__,
3232
description='REST API for Fabric',
3333
url='https://github.com/kevin1024/fabric_remote/',

tests/fixtures/fabfile.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@ def host_type():
1212
local('echo blah')
1313
time.sleep(4)
1414
local('echo blah')
15-
time.sleep(4)
1615
local('echo blah')
17-
time.sleep(4)
1816
local('echo blah')
1917
env['foo'] = 'bar'
2018
return "shit worked"

0 commit comments

Comments
 (0)