Added live-ness test for plex server when chosen at config:manage
This commit is contained in:
@@ -149,6 +149,23 @@ class PlexManage implements ManageInterface
|
||||
if (true === ag_exists($map, $server)) {
|
||||
$backend = ag_set($backend, 'url', ag($map, $server));
|
||||
$backend = ag_set($backend, 'uuid', ag($uuid, $server));
|
||||
|
||||
try {
|
||||
$this->output->writeln(
|
||||
r(
|
||||
'<info>Successfully contacted the Backed. It responded with [{version}] as it\'s version.</info>',
|
||||
[
|
||||
'version' => makeBackend(ag_set($backend, 'user', '1'))->getVersion()
|
||||
]
|
||||
)
|
||||
);
|
||||
} catch (Throwable $e) {
|
||||
$this->output->writeln(r('<error>Unable to contact [{url}]. {error}</error>', [
|
||||
'url' => ag($backend, 'url'),
|
||||
'error' => $e->getMessage()
|
||||
]));
|
||||
goto re_select;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -180,12 +197,13 @@ class PlexManage implements ManageInterface
|
||||
$chosen
|
||||
);
|
||||
|
||||
$question->setValidator(function ($answer) {
|
||||
$question->setValidator(function ($answer) use ($backend) {
|
||||
if (false === isValidURL($answer)) {
|
||||
throw new RuntimeException(
|
||||
'Invalid URL was selected/given. Expecting something like http://plex:32400.'
|
||||
);
|
||||
}
|
||||
|
||||
return $answer;
|
||||
});
|
||||
|
||||
@@ -195,6 +213,23 @@ class PlexManage implements ManageInterface
|
||||
goto re_select;
|
||||
}
|
||||
|
||||
try {
|
||||
$this->output->writeln(
|
||||
r(
|
||||
'<info>Successfully contacted the Backed. It responded with [{version}] as it\'s version.</info>',
|
||||
[
|
||||
'version' => makeBackend(ag_set(ag_set($backend, 'url', $url), 'user', '1'))->getVersion()
|
||||
]
|
||||
)
|
||||
);
|
||||
} catch (Throwable $e) {
|
||||
$this->output->writeln(r('<error>Unable to contact {url}. {error}</error>', [
|
||||
'url' => $url,
|
||||
'error' => $e->getMessage()
|
||||
]));
|
||||
goto re_select;
|
||||
}
|
||||
|
||||
$backend = ag_set($backend, 'url', $url);
|
||||
})();
|
||||
$this->output->writeln('');
|
||||
|
||||
Reference in New Issue
Block a user