Skip to content

Commit 97b9e6a

Browse files
author
Alexey Bogoslovskyi
authored
Merge pull request #264 from QualiSystems/issue/#6927_issue_in_offline_mode
AB#6927
2 parents e8306bb + 22c6655 commit 97b9e6a

File tree

14 files changed

+121
-101
lines changed

14 files changed

+121
-101
lines changed

.pre-commit-config.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
repos:
22
- repo: https://github.com/timothycrosley/isort
3-
rev: 5.6.4
3+
rev: 5.10.1
44
hooks:
55
- id: isort
66
language_version: python3.7
77
- repo: https://github.com/python/black
8-
rev: 20.8b1
8+
rev: 22.3.0
99
hooks:
1010
- id: black
1111
language_version: python3.7
12-
- repo: https://gitlab.com/pycqa/flake8
13-
rev: 3.8.4
12+
- repo: https://github.com/pycqa/flake8
13+
rev: 4.0.1
1414
hooks:
1515
- id: flake8
1616
additional_dependencies: [

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 & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,9 @@ def _create_client(self):
5454
return client
5555
except (HTTPError, Exception) as e:
5656
if hasattr(e, "code") and e.code == 401:
57-
raise FatalError(
58-
"Login to CloudShell failed. "
59-
"Please verify the credentials in the config"
60-
)
57+
if hasattr(e, "msg") and e.msg:
58+
msg = e.msg
59+
else:
60+
msg = "Please verify the credentials in the config"
61+
raise FatalError("Login to CloudShell failed. {}".format(msg))
6162
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: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,19 @@ 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", templ_data.get("shell_version", "0.0.1")
108+
)
109+
102110
templ_info.append(
103111
{
104112
"name": templ_data.get("template_name", "Undefined"),

tests/test_commands/test_extend_command.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def test_extend_incorrect_arguments(self):
4141

4242
with patch("shellfoundry.commands.extend_command.TempDirContext"):
4343
with self.assertRaisesRegex(
44-
BadParameter, u"Check correctness of entered attributes"
44+
BadParameter, "Check correctness of entered attributes"
4545
):
4646
self.tested_instance.extend("local:some_path", ("new_attribute",))
4747

@@ -105,7 +105,7 @@ def test_extend_from_remote_download_failed(self):
105105
def test_extend_not_2_gen_shell(self):
106106
with patch("shellfoundry.commands.extend_command.TempDirContext"):
107107
with self.assertRaisesRegex(
108-
ClickException, u"Invalid second generation Shell."
108+
ClickException, "Invalid second generation Shell."
109109
):
110110
self.tested_instance.extend("some_path", ("new_attribute",))
111111

tests/test_commands/test_install_command.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,8 @@ def test_install_gen1_shell_cs_connection_failed(self, os_mock, shell_package_mo
111111
# Assert
112112
self.mock_installer.install.assert_called_once()
113113
self.assertTrue(
114-
str(context.exception) == u"Connection to CloudShell Server failed. "
115-
u"Please make sure it is up and running properly."
114+
str(context.exception) == "Connection to CloudShell Server failed. "
115+
"Please make sure it is up and running properly."
116116
)
117117

118118
@patch("shellfoundry.commands.install_command.ShellPackage")
@@ -139,7 +139,7 @@ def test_install_gen1_shell_cs_login_failed(self, os_mock, shell_package_mock):
139139
self.mock_installer.install.assert_called_once()
140140
self.assertTrue(
141141
str(context.exception)
142-
== u"Login to CloudShell failed. Please verify the credentials in the config" # noqa: E501
142+
== "Login to CloudShell failed. Please verify the credentials in the config" # noqa: E501
143143
)
144144

145145
@patch("shellfoundry.commands.install_command.ShellPackage")
@@ -165,8 +165,8 @@ def test_install_gen1_shell_non_auth_http_error(self, os_mock, shell_package_moc
165165
# Assert
166166
self.mock_installer.install.assert_called_once()
167167
self.assertTrue(
168-
str(context.exception) == u"Failed to install shell. "
169-
u"CloudShell responded with: 'HTTP Error 404: Non auth error'"
168+
str(context.exception) == "Failed to install shell. "
169+
"CloudShell responded with: 'HTTP Error 404: Non auth error'"
170170
)
171171

172172
@patch("shellfoundry.commands.install_command.ShellPackage")
@@ -192,6 +192,6 @@ def test_install_gen1_shell_base_exception(self, os_mock, shell_package_mock):
192192
# Assert
193193
self.mock_installer.install.assert_called_once()
194194
self.assertTrue(
195-
str(context.exception) == u"Failed to install shell. "
196-
u"CloudShell responded with: 'Some base exception'"
195+
str(context.exception) == "Failed to install shell. "
196+
"CloudShell responded with: 'Some base exception'"
197197
)

0 commit comments

Comments
 (0)