summaryrefslogtreecommitdiff
path: root/src/leap
diff options
context:
space:
mode:
authorKali Kaneko <kali@leap.se>2018-02-14 00:42:14 +0100
committerKali Kaneko <kali@leap.se>2018-02-15 16:36:52 +0100
commit6138fb6ef700e68b16d57313d3cb85c3326c3c7d (patch)
tree09795d5c74606ab82b42826c112739b2b0c8d9e6 /src/leap
parent96ba208a00617c462cbdd2802a3c97bc6ebb28f3 (diff)
[refactor] refactor function to skip start from cli
Diffstat (limited to 'src/leap')
-rwxr-xr-xsrc/leap/bitmask/cli/bitmask_cli.py20
1 files changed, 13 insertions, 7 deletions
diff --git a/src/leap/bitmask/cli/bitmask_cli.py b/src/leap/bitmask/cli/bitmask_cli.py
index 9f5b649b..e133089d 100755
--- a/src/leap/bitmask/cli/bitmask_cli.py
+++ b/src/leap/bitmask/cli/bitmask_cli.py
@@ -137,6 +137,12 @@ OPTIONAL ARGUMENTS:
return self._send(printer=command.default_printer)
+def should_start(commands):
+ # for these commands it makes no sense to start bitmaskd
+ skip_start = ('status', 'stop')
+ return all(map(lambda item: item not in skip_start, commands))
+
+
@defer.inlineCallbacks
def execute():
cfg = Configuration(".bitmaskctl")
@@ -146,13 +152,12 @@ def execute():
cli.data = ['core', 'version']
args = None if '--noverbose' in sys.argv else ['--verbose']
- def status_timeout(args):
- raise RuntimeError('bitmaskd is not running')
-
- if 'status' in sys.arv:
- timeout_fun = status_timeout
- else:
+ if should_start(sys.argv):
timeout_fun = cli.start
+ else:
+ def status_timeout(args):
+ raise RuntimeError('bitmaskd is not running')
+ timeout_fun = status_timeout
try:
yield cli._send(
@@ -161,7 +166,8 @@ def execute():
except Exception, e:
print(Fore.RED + "ERROR: " + Fore.RESET +
"%s" % str(e))
- defer.returnValue('')
+ yield reactor.stop()
+
cli.data = []
cli.print_json = print_json