Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

astimezone() cannot be applied to a naive datetime #982

Closed
jumping opened this issue Nov 3, 2014 · 4 comments · Fixed by boto/botocore#381
Closed

astimezone() cannot be applied to a naive datetime #982

jumping opened this issue Nov 3, 2014 · 4 comments · Fixed by boto/botocore#381
Assignees
Labels
bug This issue is a bug.

Comments

@jumping
Copy link

jumping commented Nov 3, 2014

When I run the following command, I got error message: astimezone() cannot be applied to a naive datetime.

$aws cloudwatch get-metric-statistics --metric-name CPUUtilization --start-time 2014-10-28T23:18:00 --end-time 2014-10-31T23:18:00 --period 3600 --namespace AWS/EC2 --statistics Maximum --dimensions Name=InstanceId,Value=i-80efb86d

Version

$aws --version
aws-cli/1.5.4 Python/2.7.6 Darwin/14.0.0

aws-cli Version

@santhoshdaivajna
Copy link

aws cloudwatch get-metric-statistics --metric-name CPUUtilization --start-time 2014-07-11T19:00:00 --end-time 2014-07-11T19:05:00 --period 3600 --namespace AWS/EC2 --statistics Average --dimensions Name=InstanceId,Value=i-9b2fd0b0

astimezone() cannot be applied to a naive datetime

python 2.6.8
aws-cli 1.5.4

@tomobk
Copy link

tomobk commented Nov 7, 2014

HI.
Hi. same issue.

aws --version
aws-cli/1.5.5 Python/2.6.9 Linux/3.4.68-59.97.amzn1.x86_64

But

aws cloudwatch get-metric-statistics --metric-name CPUUtilization --start-time 2014-11-04T00:00:00Z --end-time 2014-11-04T23:59:59Z --period 3600 --namespace AWS/EC2 --statistics Maximum --dimensions Name=InstanceId,Value=i-XXXXXX

OK

This issue timestamps need a 'Z' on the end for the options '--start-time' and '--end-time.

@jamesls jamesls added confirmed bug This issue is a bug. labels Nov 8, 2014
@jamesls
Copy link
Member

jamesls commented Nov 18, 2014

Adding traceback from debug log for reference:

Traceback (most recent call last):
  File "aws-cli/awscli/clidriver.py", line 207, in main
    return command_table[parsed_args.command](remaining, parsed_args)
  File "aws-cli/awscli/clidriver.py", line 359, in __call__
    return command_table[parsed_args.operation](remaining, parsed_globals)
  File "aws-cli/awscli/clidriver.py", line 494, in __call__
    self._operation_object, call_parameters, parsed_globals)
  File "aws-cli/awscli/clidriver.py", line 599, in invoke
    **parameters)
  File "botocore/botocore/operation.py", line 79, in call
    request_dict = self.build_parameters(**kwargs)
  File "botocore/botocore/operation.py", line 181, in build_parameters
    request_dict = serializer.serialize_to_request(kwargs, self._model)
  File "botocore/botocore/validate.py", line 275, in serialize_to_request
    operation_model)
  File "botocore/botocore/serialize.py", line 163, in serialize_to_request
    self._serialize(body_params, parameters, shape)
  File "botocore/botocore/serialize.py", line 177, in _serialize
    method(serialized, value, shape, prefix=prefix)
  File "botocore/botocore/serialize.py", line 186, in _serialize_type_structure
    self._serialize(serialized, value, member_shape, member_prefix)
  File "botocore/botocore/serialize.py", line 177, in _serialize
    method(serialized, value, shape, prefix=prefix)
  File "botocore/botocore/serialize.py", line 239, in _serialize_type_timestamp
    final_value = converter(datetime_obj)
  File "botocore/botocore/serialize.py", line 134, in _timestamp_iso8601
    return value.astimezone(tzutc()).strftime(timestamp_format)
ValueError: astimezone() cannot be applied to a naive datetime

@jamesls jamesls self-assigned this Nov 18, 2014
jamesls added a commit to jamesls/botocore that referenced this issue Nov 18, 2014
While we want to encourage users to provide the appropriate
timezone info, this commit adds back the previous behavior, which
was to serialize the request assuming the user meant UTC.  I double
checked, and in prior versions, we weren't sending any tzinfo at all,
whereas now, we're at least explicitly specifying the UTC suffix if
none is provided.

Fixes aws/aws-cli#982
jamesls added a commit that referenced this issue Nov 18, 2014
@jamesls
Copy link
Member

jamesls commented Nov 18, 2014

Issue is now fixed and will be available in the next release of the AWS CLI. Thanks everyone for reporting the issue.

kyleknap added a commit that referenced this issue Nov 21, 2014
* release-1.6.3: (25 commits)
  Bumping version to 1.6.3
  Update integration test
  Update changelog
  Add binary output issue to changelog
  Fix module docstring in scalarparse
  Update changelog [ci skip]
  Add customization to alter scalar parsing behavior
  Add 1012 to the CHANGELOG
  Update changelog with feature
  Update code with botocore changes
  Add read file in bytes using fileb://
  Add #1007 to the changelog
  Update CloudTrail to use bucket location constraints
  Fix issue when error response is receieved for streaming output
  Add sigv4 issue to changelog
  Add #982 to the changelog
  Add get-bucket-location fix to changelog
  Add auth resign issue to changelog
  Update changelog
  Fix always return rc of 0 for ls
  ...
thoward-godaddy pushed a commit to thoward-godaddy/aws-cli that referenced this issue Feb 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants