Skip to content

Commit

Permalink
Merge pull request #264 from QualiSystems/issue/#6927_issue_in_offlin…
Browse files Browse the repository at this point in the history
…e_mode

AB#6927
  • Loading branch information
alexquali authored Apr 12, 2022
2 parents e8306bb + 22c6655 commit 97b9e6a
Show file tree
Hide file tree
Showing 14 changed files with 121 additions and 101 deletions.
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
repos:
- repo: https://github.com/timothycrosley/isort
rev: 5.6.4
rev: 5.10.1
hooks:
- id: isort
language_version: python3.7
- repo: https://github.com/python/black
rev: 20.8b1
rev: 22.3.0
hooks:
- id: black
language_version: python3.7
- repo: https://gitlab.com/pycqa/flake8
rev: 3.8.4
- repo: https://github.com/pycqa/flake8
rev: 4.0.1
hooks:
- id: flake8
additional_dependencies: [
Expand Down
6 changes: 6 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
=======
History
=======
1.2.21 (2022-03-31)
-------------------

* 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.2.20 (2021-08-19)
-------------------
Expand Down
2 changes: 1 addition & 1 deletion shellfoundry/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def version():
)
@click.option("--all", "default_view", flag_value=NO_FILTER, help="Show all templates")
@shellfoundry_version_check(abort_if_major=True)
def list(default_view):
def list(default_view): # noqa: A001
"""Lists the available shell templates."""
ListCommandExecutor(default_view).list()

Expand Down
9 changes: 5 additions & 4 deletions shellfoundry/utilities/cloudshell_api/client_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,9 @@ def _create_client(self):
return client
except (HTTPError, Exception) as e:
if hasattr(e, "code") and e.code == 401:
raise FatalError(
"Login to CloudShell failed. "
"Please verify the credentials in the config"
)
if hasattr(e, "msg") and e.msg:
msg = e.msg
else:
msg = "Please verify the credentials in the config"
raise FatalError("Login to CloudShell failed. {}".format(msg))
raise FatalError(self.ConnectionFailureMessage)
6 changes: 5 additions & 1 deletion shellfoundry/utilities/cookiecutter_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,11 @@ def compile_template(
output_dir=output_dir,
)
except OutputDirExistsException as err:
raise ClickException(str(err))
if str(err).startswith("Error: "):
msg = str(err)[6:].strip()
else:
msg = str(err)
raise ClickException(msg)

@staticmethod
def _remove_template_info_file(shell_path):
Expand Down
14 changes: 11 additions & 3 deletions shellfoundry/utilities/template_retriever.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,19 @@ def _get_local_templates(self, template_location):
for filename in filenames:
if filename == TEMPLATE_INFO_FILE:
full_path = os.path.join(root, filename)
standard_version = self._get_standard_version_from_template(
root
)

with open(full_path, mode="r", encoding="utf8") as f:
templ_data = json.load(f)

if GEN_TWO in templ_data.get("template_name", "Undefined"):
standard_version = self._get_standard_version_from_template(
root
)
else:
standard_version = templ_data.get(
"version", templ_data.get("shell_version", "0.0.1")
)

templ_info.append(
{
"name": templ_data.get("template_name", "Undefined"),
Expand Down
4 changes: 2 additions & 2 deletions tests/test_commands/test_extend_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def test_extend_incorrect_arguments(self):

with patch("shellfoundry.commands.extend_command.TempDirContext"):
with self.assertRaisesRegex(
BadParameter, u"Check correctness of entered attributes"
BadParameter, "Check correctness of entered attributes"
):
self.tested_instance.extend("local:some_path", ("new_attribute",))

Expand Down Expand Up @@ -105,7 +105,7 @@ def test_extend_from_remote_download_failed(self):
def test_extend_not_2_gen_shell(self):
with patch("shellfoundry.commands.extend_command.TempDirContext"):
with self.assertRaisesRegex(
ClickException, u"Invalid second generation Shell."
ClickException, "Invalid second generation Shell."
):
self.tested_instance.extend("some_path", ("new_attribute",))

Expand Down
14 changes: 7 additions & 7 deletions tests/test_commands/test_install_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ def test_install_gen1_shell_cs_connection_failed(self, os_mock, shell_package_mo
# Assert
self.mock_installer.install.assert_called_once()
self.assertTrue(
str(context.exception) == u"Connection to CloudShell Server failed. "
u"Please make sure it is up and running properly."
str(context.exception) == "Connection to CloudShell Server failed. "
"Please make sure it is up and running properly."
)

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

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

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

0 comments on commit 97b9e6a

Please sign in to comment.