API now connects to server lazily (#15632)

This should fix most issues with offline operation.

Fixes #14486
Fixes #13991

Alternate to #15363 and #15593
This commit is contained in:
Brian Coca
2016-04-28 23:28:02 -04:00
parent c6a14567b6
commit 941564b366
2 changed files with 43 additions and 27 deletions

View File

@@ -51,7 +51,7 @@ class GalaxyCLI(CLI):
SKIP_INFO_KEYS = ("name", "description", "readme_html", "related", "summary_fields", "average_aw_composite", "average_aw_score", "url" )
VALID_ACTIONS = ("delete", "import", "info", "init", "install", "list", "login", "remove", "search", "setup")
def __init__(self, args):
self.api = None
self.galaxy = None
@@ -146,14 +146,10 @@ class GalaxyCLI(CLI):
return True
def run(self):
super(GalaxyCLI, self).run()
# if not offline, get connect to galaxy api
if self.action in ("import","info","install","search","login","setup","delete") or \
(self.action == 'init' and not self.options.offline):
self.api = GalaxyAPI(self.galaxy)
self.api = GalaxyAPI(self.galaxy)
self.execute()
def exit_without_ignore(self, rc=1):
@@ -242,7 +238,7 @@ class GalaxyCLI(CLI):
# platforms included (but commented out), the galaxy_tags
# list, and the dependencies section
platforms = []
if not offline and self.api:
if not offline:
platforms = self.api.get_list("platforms") or []
# group the list of platforms from the api based
@@ -315,7 +311,7 @@ class GalaxyCLI(CLI):
role_info.update(install_info)
remote_data = False
if self.api:
if not self.options.offline:
remote_data = self.api.lookup_role_by_name(role, False)
if remote_data: