Commit 26d915bc authored by Giorgos Korfiatis's avatar Giorgos Korfiatis

Factor out making server

parent 1e698899
......@@ -412,6 +412,15 @@ class AgkyraCLI(cmd.Cmd):
"""
self._start(line)
def make_server_if_needed(self):
client = self.client
if not client:
sys.stderr.write('No Agkyra daemons running, starting one')
protocol.launch_server(self.callback, self.args.debug)
sys.stderr.write(' ... ')
self.helper.wait_session_to_load()
sys.stderr.write('OK\n')
@handle_UI_error
def _start(self, line):
if self.must_help('start'):
......@@ -422,14 +431,8 @@ class AgkyraCLI(cmd.Cmd):
sys.stderr.write("Unrecognized subcommand '%s'.\n" % line)
sys.stderr.flush()
return
self.make_server_if_needed()
client = self.client
if not client:
sys.stderr.write('No Agkyra daemons running, starting one')
protocol.launch_server(self.callback, self.args.debug)
sys.stderr.write(' ... ')
self.helper.wait_session_to_load()
sys.stderr.write('OK\n')
else:
status = client.get_status()
if status['code'] == STATUS['PAUSED']:
client.start()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment