Skip to content

Commit ea30f63

Browse files
author
Alexey Bogoslovskyi
committed
Fixed issue with list command in offline mode
Fixed GH issue "Uninformative error message when configured domain is incorrect #254" Fixed GH issue "'Error' word repeats twice #251"
1 parent e8306bb commit ea30f63

File tree

7 files changed

+33
-10
lines changed

7 files changed

+33
-10
lines changed

HISTORY.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
=======
22
History
33
=======
4+
1.2.21 (2022-03-31)
5+
-------------------
6+
7+
* Fixed issue with list command in offline mode
8+
* Fixed GH issue "Uninformative error message when configured domain is incorrect #254"
9+
* Fixed GH issue "'Error' word repeats twice #251"
410

511
1.2.20 (2021-08-19)
612
-------------------

shellfoundry/bootstrap.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def version():
5050
)
5151
@click.option("--all", "default_view", flag_value=NO_FILTER, help="Show all templates")
5252
@shellfoundry_version_check(abort_if_major=True)
53-
def list(default_view):
53+
def list(default_view): # noqa: A001
5454
"""Lists the available shell templates."""
5555
ListCommandExecutor(default_view).list()
5656

shellfoundry/utilities/cloudshell_api/client_wrapper.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,11 @@ def _create_client(self):
5454
return client
5555
except (HTTPError, Exception) as e:
5656
if hasattr(e, "code") and e.code == 401:
57+
if hasattr(e, "msg") and e.msg:
58+
msg = e.msg
59+
else:
60+
msg = "Please verify the credentials in the config"
5761
raise FatalError(
58-
"Login to CloudShell failed. "
59-
"Please verify the credentials in the config"
62+
"Login to CloudShell failed. {}".format(msg)
6063
)
6164
raise FatalError(self.ConnectionFailureMessage)

shellfoundry/utilities/cookiecutter_integration.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,11 @@ def compile_template(
5353
output_dir=output_dir,
5454
)
5555
except OutputDirExistsException as err:
56-
raise ClickException(str(err))
56+
if str(err).startswith("Error: "):
57+
msg = str(err)[6:].strip()
58+
else:
59+
msg = str(err)
60+
raise ClickException(msg)
5761

5862
@staticmethod
5963
def _remove_template_info_file(shell_path):

shellfoundry/utilities/template_retriever.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,20 @@ def _get_local_templates(self, template_location):
9494
for filename in filenames:
9595
if filename == TEMPLATE_INFO_FILE:
9696
full_path = os.path.join(root, filename)
97-
standard_version = self._get_standard_version_from_template(
98-
root
99-
)
97+
10098
with open(full_path, mode="r", encoding="utf8") as f:
10199
templ_data = json.load(f)
100+
101+
if GEN_TWO in templ_data.get("template_name", "Undefined"):
102+
standard_version = self._get_standard_version_from_template(
103+
root
104+
)
105+
else:
106+
standard_version = templ_data.get(
107+
"version",
108+
templ_data.get("shell_version", "0.0.1")
109+
)
110+
102111
templ_info.append(
103112
{
104113
"name": templ_data.get("template_name", "Undefined"),

tests/test_utilities/test_cloudshell_api/test_client_wrapper.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ def test_client_wrapper_raises_an_error_when_create_client_fails_after_retries_h
5858
self, api_mock
5959
):
6060
# Arrange
61-
error = HTTPError("url", 401, "not found", None, None)
61+
error_msg = "not found"
62+
error = HTTPError("url", 401, error_msg, None, None)
6263
api_mock.side_effect = [error, error]
6364

6465
# Act
@@ -68,7 +69,7 @@ def test_client_wrapper_raises_an_error_when_create_client_fails_after_retries_h
6869
# Assert
6970
self.assertEqual(
7071
context.exception.message,
71-
u"Login to CloudShell failed. Please verify the credentials in the config",
72+
u"Login to CloudShell failed. {}".format(error_msg),
7273
)
7374

7475
@patch(

version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.2.20
1+
1.2.21

0 commit comments

Comments
 (0)