Skip to content
This repository has been archived by the owner on Sep 18, 2023. It is now read-only.

Fix output awscli on Windows #235

Merged
merged 2 commits into from
Aug 6, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions mozilla_aws_cli/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@
else:
import ConfigParser as configparser

try:
from shlex import quote
except ImportError:
from pipes import quote

ZERO = datetime.timedelta(0)


Expand Down Expand Up @@ -147,12 +152,14 @@ def write_aws_cli_credentials(profile, credentials):
for cred_key, aws_key in viewitems(CREDENTIALS_TO_AWS_MAP):
if cred_key in credentials:
process = ["aws", "configure", "set",
aws_key, credentials[cred_key]]
quote(aws_key), quote(credentials[cred_key])]

if profile != "default":
process += ["--profile", profile]
process += ["--profile", quote(profile)]

_retval = subprocess.call(process)
# We have to use shell=True to function on Windows, as `aws` is
# aws.CMD there
_retval = subprocess.call(" ".join(process), shell=True)
retval = retval | _retval

logger.debug("`{}` executed with return code: {}".format(
Expand Down
4 changes: 2 additions & 2 deletions mozilla_aws_cli/cli.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from __future__ import absolute_import, print_function
from distutils.spawn import find_executable
from shutil import which
import os
import logging

Expand Down Expand Up @@ -56,7 +56,7 @@ def validate_output(ctx, param, value):
del ctx, param # we don't use these arguments
if value is None:
pass
elif value.lower() == "awscli" and not find_executable("aws"):
elif value.lower() == "awscli" and which("aws") is None:
raise click.BadParameter("AWS CLI is not detected on local system.")

return value
Expand Down