Skip to content

Commit

Permalink
Merging new features to master branch (#196)
Browse files Browse the repository at this point in the history
* Added Dynamic Encoding Selection Based on Windows System Default

* Fixed dotnet output system dependent encoding

* Updated test_custom_make urllib3 Version

* Reformatted with black

* Rollback Changes to popen for Python 2 Support

* Added Doc Page for DotNet Output Encoding

* fix(ruby): use stdout stream to raise exceptions from bundler

- relevant error information is in stdout instead of stderr for bundler.

* chore: bump version to 1.1.0

Co-authored-by: Wilton Wang <CoshUS@users.noreply.github.com>
Co-authored-by: Sriram Madapusi Vasudevan <3770774+sriram-mv@users.noreply.github.com>
Co-authored-by: Sriram Madapusi Vasudevan <srirammv@amazon.com>
  • Loading branch information
4 people authored Sep 3, 2020
1 parent a943b1a commit c15fe76
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 7 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ typings/
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

# User-specific stuff:
.vscode

# Sensitive or high-churn files:

Expand Down
2 changes: 1 addition & 1 deletion aws_lambda_builders/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
AWS Lambda Builder Library
"""
__version__ = "1.0.0"
__version__ = "1.1.0"
RPC_PROTOCOL_VERSION = "0.3"
9 changes: 7 additions & 2 deletions aws_lambda_builders/workflows/dotnet_clipackage/dotnetcli.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import sys
import logging
import locale

from .utils import OSUtils

Expand Down Expand Up @@ -49,14 +50,18 @@ def run(self, args, cwd=None):

LOG.debug("executing dotnet: %s", invoke_dotnet)

# DotNet output is in system locale dependent encoding
# https://docs.microsoft.com/en-us/dotnet/api/system.console.outputencoding?view=netcore-3.1#remarks
# "The default code page that the console uses is determined by the system locale."
encoding = locale.getpreferredencoding()
p = self.os_utils.popen(invoke_dotnet, stdout=self.os_utils.pipe, stderr=self.os_utils.pipe, cwd=cwd)

out, err = p.communicate()

# The package command contains lots of useful information on how the package was created and
# information when the package command was not successful. For that reason the output is
# always written to the output to help developers diagnose issues.
LOG.info(out.decode("utf8").strip())
LOG.info(out.decode(encoding).strip())

if p.returncode != 0:
raise DotnetCLIExecutionError(message=err.decode("utf8").strip())
raise DotnetCLIExecutionError(message=err.decode(encoding).strip())
5 changes: 3 additions & 2 deletions aws_lambda_builders/workflows/ruby_bundler/bundler.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,10 @@ def run(self, args, cwd=None):

p = self.osutils.popen(invoke_bundler, stdout=self.osutils.pipe, stderr=self.osutils.pipe, cwd=cwd)

out, err = p.communicate()
out, _ = p.communicate()

if p.returncode != 0:
raise BundlerExecutionError(message=err.decode("utf8").strip())
# Bundler has relevant information in stdout, not stderr.
raise BundlerExecutionError(message=out.decode("utf8").strip())

return out.decode("utf8").strip()
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def test_must_build_python_project_through_makefile(self):
"chardet",
"urllib3",
"idna",
"urllib3-1.25.9.dist-info",
"urllib3-1.25.10.dist-info",
"chardet-3.0.4.dist-info",
"certifi-2020.4.5.2.dist-info",
"certifi",
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/workflows/ruby_bundler/test_bundler.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def test_returns_popen_out_decoded_if_retcode_is_0(self):

def test_raises_BundlerExecutionError_with_err_text_if_retcode_is_not_0(self):
self.popen.returncode = 1
self.popen.err = b"some error text\n\n"
self.popen.out = b"some error text\n\n"
with self.assertRaises(BundlerExecutionError) as raised:
self.under_test.run(["install", "--without", "development", "test"])
self.assertEqual(raised.exception.args[0], "Bundler Failed: some error text")
Expand Down

0 comments on commit c15fe76

Please sign in to comment.