本文整理汇总了Python中botocore.utils.parse_to_aware_datetime方法的典型用法代码示例。如果您正苦于以下问题:Python utils.parse_to_aware_datetime方法的具体用法?Python utils.parse_to_aware_datetime怎么用?Python utils.parse_to_aware_datetime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类botocore.utils
的用法示例。
在下文中一共展示了utils.parse_to_aware_datetime方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _run_main
# 需要导入模块: from botocore import utils [as 别名]
# 或者: from botocore.utils import parse_to_aware_datetime [as 别名]
def _run_main(self, args, parsed_globals):
signer = CloudFrontSigner(
args.key_pair_id, RSASigner(args.private_key).sign)
date_less_than = parse_to_aware_datetime(args.date_less_than)
date_greater_than = args.date_greater_than
if date_greater_than is not None:
date_greater_than = parse_to_aware_datetime(date_greater_than)
if date_greater_than is not None or args.ip_address is not None:
policy = signer.build_policy(
args.url, date_less_than, date_greater_than=date_greater_than,
ip_address=args.ip_address)
sys.stdout.write(signer.generate_presigned_url(
args.url, policy=policy))
else:
sys.stdout.write(signer.generate_presigned_url(
args.url, date_less_than=date_less_than))
return 0
示例2: _convert_timestamp_to_str
# 需要导入模块: from botocore import utils [as 别名]
# 或者: from botocore.utils import parse_to_aware_datetime [as 别名]
def _convert_timestamp_to_str(self, value):
datetime_obj = parse_to_aware_datetime(value)
converter = getattr(
self, '_timestamp_%s' % self.TIMESTAMP_FORMAT.lower())
final_value = converter(datetime_obj)
return final_value
示例3: _convert_header_value
# 需要导入模块: from botocore import utils [as 别名]
# 或者: from botocore.utils import parse_to_aware_datetime [as 别名]
def _convert_header_value(self, shape, value):
if shape.type_name == 'timestamp':
datetime_obj = parse_to_aware_datetime(value)
timestamp = calendar.timegm(datetime_obj.utctimetuple())
return self._timestamp_rfc822(timestamp)
else:
return value
示例4: _convert_timestamp_to_str
# 需要导入模块: from botocore import utils [as 别名]
# 或者: from botocore.utils import parse_to_aware_datetime [as 别名]
def _convert_timestamp_to_str(self, value, timestamp_format=None):
if timestamp_format is None:
timestamp_format = self.TIMESTAMP_FORMAT
timestamp_format = timestamp_format.lower()
datetime_obj = parse_to_aware_datetime(value)
converter = getattr(
self, '_timestamp_%s' % timestamp_format)
final_value = converter(datetime_obj)
return final_value
示例5: _convert_header_value
# 需要导入模块: from botocore import utils [as 别名]
# 或者: from botocore.utils import parse_to_aware_datetime [as 别名]
def _convert_header_value(self, shape, value):
if shape.type_name == 'timestamp':
datetime_obj = parse_to_aware_datetime(value)
timestamp = calendar.timegm(datetime_obj.utctimetuple())
timestamp_format = shape.serialization.get(
'timestampFormat', self.HEADER_TIMESTAMP_FORMAT)
return self._convert_timestamp_to_str(timestamp, timestamp_format)
elif is_json_value_header(shape):
# Serialize with no spaces after separators to save space in
# the header.
return self._get_base64(json.dumps(value, separators=(',', ':')))
else:
return value
示例6: _convert_header_value
# 需要导入模块: from botocore import utils [as 别名]
# 或者: from botocore.utils import parse_to_aware_datetime [as 别名]
def _convert_header_value(self, shape, value):
if shape.type_name == 'timestamp':
datetime_obj = parse_to_aware_datetime(value)
timestamp = calendar.timegm(datetime_obj.utctimetuple())
return self._timestamp_rfc822(timestamp)
elif is_json_value_header(shape):
# Serialize with no spaces after separators to save space in
# the header.
return self._get_base64(json.dumps(value, separators=(',', ':')))
else:
return value