Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
A
aliyun-python-sdk-core
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张允禹
aliyun-python-sdk-core
Commits
76082e7c
Commit
76082e7c
authored
Jun 26, 2017
by
张允禹
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
py3
parent
5dc8cb75
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
56 additions
and
57 deletions
+56
-57
exceptions.py
aliyunsdkcore/acs_exception/exceptions.py
+1
-1
oss_signature_composer.py
aliyunsdkcore/auth/oss_signature_composer.py
+5
-5
roa_signature_composer.py
aliyunsdkcore/auth/roa_signature_composer.py
+7
-7
rpc_signature_composer.py
aliyunsdkcore/auth/rpc_signature_composer.py
+5
-5
url_encoder.py
aliyunsdkcore/auth/url_encoder.py
+5
-5
client.py
aliyunsdkcore/client.py
+2
-2
format_type.py
aliyunsdkcore/http/format_type.py
+6
-6
http_request.py
aliyunsdkcore/http/http_request.py
+1
-1
http_response.py
aliyunsdkcore/http/http_response.py
+7
-7
region_provider.py
aliyunsdkcore/profile/region_provider.py
+5
-5
request.py
aliyunsdkcore/request.py
+6
-7
parameter_helper.py
aliyunsdkcore/utils/parameter_helper.py
+6
-6
No files found.
aliyunsdkcore/acs_exception/exceptions.py
View file @
76082e7c
...
@@ -27,7 +27,7 @@ Created on 6/15/2015
...
@@ -27,7 +27,7 @@ Created on 6/15/2015
@author: alex jiang
@author: alex jiang
"""
"""
import
error_type
from
.
import
error_type
class
ClientException
(
Exception
):
class
ClientException
(
Exception
):
...
...
aliyunsdkcore/auth/oss_signature_composer.py
View file @
76082e7c
...
@@ -23,10 +23,10 @@ import sys
...
@@ -23,10 +23,10 @@ import sys
parentdir
=
os
.
path
.
dirname
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
)))
parentdir
=
os
.
path
.
dirname
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
)))
sys
.
path
.
insert
(
0
,
parentdir
)
sys
.
path
.
insert
(
0
,
parentdir
)
import
roa_signature_composer
from
.
import
roa_signature_composer
import
sha_hmac1
as
mac1
from
.
import
sha_hmac1
as
mac1
from
..utils
import
parameter_helper
as
helper
from
..utils
import
parameter_helper
as
helper
import
urllib
import
urllib
.request
,
urllib
.
parse
,
urllib
.
error
ACCEPT
=
"Accept"
ACCEPT
=
"Accept"
CONTENT_MD5
=
"Content-MD5"
CONTENT_MD5
=
"Content-MD5"
...
@@ -50,7 +50,7 @@ def refresh_sign_parameters(
...
@@ -50,7 +50,7 @@ def refresh_sign_parameters(
def
__build_query_string
(
uri
,
queries
):
def
__build_query_string
(
uri
,
queries
):
sorted_map
=
sorted
(
queries
.
items
(
),
key
=
lambda
queries
:
queries
[
0
])
sorted_map
=
sorted
(
list
(
queries
.
items
()
),
key
=
lambda
queries
:
queries
[
0
])
if
len
(
sorted_map
)
>
0
:
if
len
(
sorted_map
)
>
0
:
uri
+=
"?"
uri
+=
"?"
for
(
k
,
v
)
in
sorted_map
:
for
(
k
,
v
)
in
sorted_map
:
...
@@ -149,7 +149,7 @@ def get_url(queries, uri_pattern, path_parameters):
...
@@ -149,7 +149,7 @@ def get_url(queries, uri_pattern, path_parameters):
uri_pattern
,
path_parameters
)
uri_pattern
,
path_parameters
)
if
not
url
.
endswith
(
"?"
):
if
not
url
.
endswith
(
"?"
):
url
+=
"?"
url
+=
"?"
url
+=
urllib
.
urlencode
(
queries
)
url
+=
urllib
.
parse
.
urlencode
(
queries
)
if
url
.
endswith
(
"?"
):
if
url
.
endswith
(
"?"
):
url
=
url
[
0
:(
len
(
url
)
-
1
)]
url
=
url
[
0
:(
len
(
url
)
-
1
)]
return
url
return
url
aliyunsdkcore/auth/roa_signature_composer.py
View file @
76082e7c
...
@@ -23,10 +23,10 @@ import sys
...
@@ -23,10 +23,10 @@ import sys
parentdir
=
os
.
path
.
dirname
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
)))
parentdir
=
os
.
path
.
dirname
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
)))
sys
.
path
.
insert
(
0
,
parentdir
)
sys
.
path
.
insert
(
0
,
parentdir
)
import
sha_hmac1
as
mac1
from
.
import
sha_hmac1
as
mac1
from
..utils
import
parameter_helper
as
helper
from
..utils
import
parameter_helper
as
helper
from
..http
import
format_type
as
FormatType
from
..http
import
format_type
as
FormatType
import
urllib
import
urllib
.request
,
urllib
.
parse
,
urllib
.
error
ACCEPT
=
"Accept"
ACCEPT
=
"Accept"
CONTENT_MD5
=
"Content-MD5"
CONTENT_MD5
=
"Content-MD5"
...
@@ -90,7 +90,7 @@ def compose_string_to_sign(
...
@@ -90,7 +90,7 @@ def compose_string_to_sign(
def
replace_occupied_parameters
(
uri_pattern
,
paths
):
def
replace_occupied_parameters
(
uri_pattern
,
paths
):
result
=
uri_pattern
result
=
uri_pattern
if
paths
is
not
None
:
if
paths
is
not
None
:
for
(
key
,
value
)
in
paths
.
items
(
):
for
(
key
,
value
)
in
list
(
paths
.
items
()
):
target
=
"["
+
key
+
"]"
target
=
"["
+
key
+
"]"
result
=
result
.
replace
(
target
,
value
)
result
=
result
.
replace
(
target
,
value
)
return
result
return
result
...
@@ -102,10 +102,10 @@ def replace_occupied_parameters(uri_pattern, paths):
...
@@ -102,10 +102,10 @@ def replace_occupied_parameters(uri_pattern, paths):
def
build_canonical_headers
(
headers
,
header_begin
):
def
build_canonical_headers
(
headers
,
header_begin
):
result
=
""
result
=
""
unsort_map
=
dict
()
unsort_map
=
dict
()
for
(
key
,
value
)
in
headers
.
ite
rite
ms
():
for
(
key
,
value
)
in
headers
.
items
():
if
key
.
lower
()
.
find
(
header_begin
)
>=
0
:
if
key
.
lower
()
.
find
(
header_begin
)
>=
0
:
unsort_map
[
key
.
lower
()]
=
value
unsort_map
[
key
.
lower
()]
=
value
sort_map
=
sorted
(
unsort_map
.
iteritems
(
),
key
=
lambda
d
:
d
[
0
])
sort_map
=
sorted
(
iter
(
unsort_map
.
items
()
),
key
=
lambda
d
:
d
[
0
])
for
(
key
,
value
)
in
sort_map
:
for
(
key
,
value
)
in
sort_map
:
result
+=
key
+
":"
+
value
result
+=
key
+
":"
+
value
result
+=
HEADER_SEPARATOR
result
+=
HEADER_SEPARATOR
...
@@ -121,7 +121,7 @@ def __build_query_string(uri, queries):
...
@@ -121,7 +121,7 @@ def __build_query_string(uri, queries):
if
len
(
uri_parts
)
>
1
and
uri_parts
[
1
]
is
not
None
:
if
len
(
uri_parts
)
>
1
and
uri_parts
[
1
]
is
not
None
:
queries
[
uri_parts
[
1
]]
=
None
queries
[
uri_parts
[
1
]]
=
None
query_builder
=
uri_parts
[
0
]
query_builder
=
uri_parts
[
0
]
sorted_map
=
sorted
(
queries
.
items
(
),
key
=
lambda
queries
:
queries
[
0
])
sorted_map
=
sorted
(
list
(
queries
.
items
()
),
key
=
lambda
queries
:
queries
[
0
])
if
len
(
sorted_map
)
>
0
:
if
len
(
sorted_map
)
>
0
:
query_builder
+=
"?"
query_builder
+=
"?"
for
(
k
,
v
)
in
sorted_map
:
for
(
k
,
v
)
in
sorted_map
:
...
@@ -188,7 +188,7 @@ def get_url(uri_pattern, queries, path_parameters):
...
@@ -188,7 +188,7 @@ def get_url(uri_pattern, queries, path_parameters):
url
+=
replace_occupied_parameters
(
uri_pattern
,
path_parameters
)
url
+=
replace_occupied_parameters
(
uri_pattern
,
path_parameters
)
if
not
url
.
endswith
(
"?"
):
if
not
url
.
endswith
(
"?"
):
url
+=
"?"
url
+=
"?"
url
+=
urllib
.
urlencode
(
queries
)
url
+=
urllib
.
parse
.
urlencode
(
queries
)
if
url
.
endswith
(
"?"
):
if
url
.
endswith
(
"?"
):
url
=
url
[
0
:(
len
(
url
)
-
1
)]
url
=
url
[
0
:(
len
(
url
)
-
1
)]
return
url
return
url
aliyunsdkcore/auth/rpc_signature_composer.py
View file @
76082e7c
...
@@ -23,8 +23,8 @@ import sys
...
@@ -23,8 +23,8 @@ import sys
parentdir
=
os
.
path
.
dirname
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
)))
parentdir
=
os
.
path
.
dirname
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
)))
sys
.
path
.
insert
(
0
,
parentdir
)
sys
.
path
.
insert
(
0
,
parentdir
)
import
sha_hmac1
as
mac1
from
.
import
sha_hmac1
as
mac1
import
urllib
import
urllib
.request
,
urllib
.
parse
,
urllib
.
error
from
..utils
import
parameter_helper
as
helper
from
..utils
import
parameter_helper
as
helper
...
@@ -55,7 +55,7 @@ def __refresh_sign_parameters(
...
@@ -55,7 +55,7 @@ def __refresh_sign_parameters(
def
__pop_standard_urlencode
(
query
):
def
__pop_standard_urlencode
(
query
):
ret
=
urllib
.
urlencode
(
query
)
ret
=
urllib
.
parse
.
urlencode
(
query
)
ret
=
ret
.
replace
(
'+'
,
'
%20
'
)
ret
=
ret
.
replace
(
'+'
,
'
%20
'
)
ret
=
ret
.
replace
(
'*'
,
'
%2
A'
)
ret
=
ret
.
replace
(
'*'
,
'
%2
A'
)
ret
=
ret
.
replace
(
'
%7
E'
,
'~'
)
ret
=
ret
.
replace
(
'
%7
E'
,
'~'
)
...
@@ -64,9 +64,9 @@ def __pop_standard_urlencode(query):
...
@@ -64,9 +64,9 @@ def __pop_standard_urlencode(query):
def
__compose_string_to_sign
(
method
,
queries
):
def
__compose_string_to_sign
(
method
,
queries
):
canonicalized_query_string
=
""
canonicalized_query_string
=
""
sorted_parameters
=
sorted
(
queries
.
items
(
),
key
=
lambda
queries
:
queries
[
0
])
sorted_parameters
=
sorted
(
list
(
queries
.
items
()
),
key
=
lambda
queries
:
queries
[
0
])
string_to_sign
=
method
+
"&
%2
F&"
+
\
string_to_sign
=
method
+
"&
%2
F&"
+
\
urllib
.
pathname2url
(
__pop_standard_urlencode
(
sorted_parameters
))
urllib
.
request
.
pathname2url
(
__pop_standard_urlencode
(
sorted_parameters
))
return
string_to_sign
return
string_to_sign
...
...
aliyunsdkcore/auth/url_encoder.py
View file @
76082e7c
...
@@ -18,7 +18,7 @@
...
@@ -18,7 +18,7 @@
# under the License.
# under the License.
# coding=utf-8
# coding=utf-8
import
urllib
import
urllib
.request
,
urllib
.
parse
,
urllib
.
error
import
sys
import
sys
"""
"""
...
@@ -36,12 +36,12 @@ def get_encode_str(params):
...
@@ -36,12 +36,12 @@ def get_encode_str(params):
:param params: dict parameters
:param params: dict parameters
:return: string
:return: string
"""
"""
list_params
=
sorted
(
params
.
iteritems
(
),
key
=
lambda
d
:
d
[
0
])
list_params
=
sorted
(
iter
(
params
.
items
()
),
key
=
lambda
d
:
d
[
0
])
encode_str
=
urllib
.
urlencode
(
list_params
)
encode_str
=
urllib
.
parse
.
urlencode
(
list_params
)
if
sys
.
stdin
.
encoding
is
None
:
if
sys
.
stdin
.
encoding
is
None
:
res
=
urllib
.
quote
(
encode_str
.
decode
(
'cp936'
)
.
encode
(
'utf8'
),
''
)
res
=
urllib
.
parse
.
quote
(
encode_str
.
decode
(
'cp936'
)
.
encode
(
'utf8'
),
''
)
else
:
else
:
res
=
urllib
.
quote
(
res
=
urllib
.
parse
.
quote
(
encode_str
.
decode
(
encode_str
.
decode
(
sys
.
stdin
.
encoding
)
.
encode
(
'utf8'
),
''
)
sys
.
stdin
.
encoding
)
.
encode
(
'utf8'
),
''
)
res
=
res
.
replace
(
"+"
,
"
%20
"
)
res
=
res
.
replace
(
"+"
,
"
%20
"
)
...
...
aliyunsdkcore/client.py
View file @
76082e7c
...
@@ -20,7 +20,7 @@
...
@@ -20,7 +20,7 @@
# coding=utf-8
# coding=utf-8
import
os
import
os
import
sys
import
sys
import
http
lib
import
http
.client
import
warnings
import
warnings
warnings
.
filterwarnings
(
"once"
,
category
=
DeprecationWarning
)
warnings
.
filterwarnings
(
"once"
,
category
=
DeprecationWarning
)
...
@@ -252,7 +252,7 @@ class AcsClient:
...
@@ -252,7 +252,7 @@ class AcsClient:
# data instead
# data instead
pass
pass
if
status
!=
http
lib
.
OK
:
if
status
!=
http
.
client
.
OK
:
server_error_code
,
server_error_message
=
self
.
_parse_error_info_from_response_body
(
server_error_code
,
server_error_message
=
self
.
_parse_error_info_from_response_body
(
body
)
body
)
raise
ServerException
(
raise
ServerException
(
...
...
aliyunsdkcore/http/format_type.py
View file @
76082e7c
...
@@ -45,9 +45,9 @@ def map_accept_to_format(accept):
...
@@ -45,9 +45,9 @@ def map_accept_to_format(accept):
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
print
map_format_to_accept
(
XML
)
print
(
map_format_to_accept
(
XML
)
)
print
map_format_to_accept
(
JSON
)
print
(
map_format_to_accept
(
JSON
)
)
print
map_format_to_accept
(
RAW
)
print
(
map_format_to_accept
(
RAW
)
)
print
map_accept_to_format
(
"application/xml"
)
print
(
map_accept_to_format
(
"application/xml"
)
)
print
map_accept_to_format
(
"text/xml"
)
print
(
map_accept_to_format
(
"text/xml"
)
)
print
map_accept_to_format
(
"application/json"
)
print
(
map_accept_to_format
(
"application/json"
)
)
aliyunsdkcore/http/http_request.py
View file @
76082e7c
...
@@ -23,7 +23,7 @@ import sys
...
@@ -23,7 +23,7 @@ import sys
parentdir
=
os
.
path
.
dirname
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
)))
parentdir
=
os
.
path
.
dirname
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
)))
sys
.
path
.
insert
(
0
,
parentdir
)
sys
.
path
.
insert
(
0
,
parentdir
)
import
format_type
from
.
import
format_type
from
..utils
import
parameter_helper
as
helper
from
..utils
import
parameter_helper
as
helper
...
...
aliyunsdkcore/http/http_response.py
View file @
76082e7c
...
@@ -17,10 +17,10 @@
...
@@ -17,10 +17,10 @@
# coding=utf-8
# coding=utf-8
__author__
=
'alex jiang'
__author__
=
'alex jiang'
import
http
lib
import
http
.client
from
http_request
import
HttpRequest
from
.
http_request
import
HttpRequest
import
protocol_type
as
PT
from
.
import
protocol_type
as
PT
class
HttpResponse
(
HttpRequest
):
class
HttpResponse
(
HttpRequest
):
...
@@ -72,7 +72,7 @@ class HttpResponse(HttpRequest):
...
@@ -72,7 +72,7 @@ class HttpResponse(HttpRequest):
if
self
.
__port
is
None
or
self
.
__port
==
""
:
if
self
.
__port
is
None
or
self
.
__port
==
""
:
self
.
__port
=
80
self
.
__port
=
80
try
:
try
:
self
.
__connection
=
http
lib
.
HTTPConnection
(
self
.
__connection
=
http
.
client
.
HTTPConnection
(
self
.
get_host
(),
self
.
__port
)
self
.
get_host
(),
self
.
__port
)
self
.
__connection
.
connect
()
self
.
__connection
.
connect
()
self
.
__connection
.
request
(
self
.
__connection
.
request
(
...
@@ -89,7 +89,7 @@ class HttpResponse(HttpRequest):
...
@@ -89,7 +89,7 @@ class HttpResponse(HttpRequest):
if
self
.
__port
is
None
or
self
.
__port
==
""
:
if
self
.
__port
is
None
or
self
.
__port
==
""
:
self
.
__port
=
80
self
.
__port
=
80
try
:
try
:
self
.
__connection
=
http
lib
.
HTTPConnection
(
self
.
__connection
=
http
.
client
.
HTTPConnection
(
self
.
get_host
(),
self
.
__port
)
self
.
get_host
(),
self
.
__port
)
self
.
__connection
.
connect
()
self
.
__connection
.
connect
()
self
.
__connection
.
request
(
self
.
__connection
.
request
(
...
@@ -107,7 +107,7 @@ class HttpResponse(HttpRequest):
...
@@ -107,7 +107,7 @@ class HttpResponse(HttpRequest):
self
.
__port
=
443
self
.
__port
=
443
try
:
try
:
self
.
__port
=
443
self
.
__port
=
443
self
.
__connection
=
http
lib
.
HTTPSConnection
(
self
.
__connection
=
http
.
client
.
HTTPSConnection
(
self
.
get_host
(),
self
.
get_host
(),
self
.
__port
,
self
.
__port
,
cert_file
=
self
.
__cert_file
,
cert_file
=
self
.
__cert_file
,
...
@@ -128,7 +128,7 @@ class HttpResponse(HttpRequest):
...
@@ -128,7 +128,7 @@ class HttpResponse(HttpRequest):
self
.
__port
=
443
self
.
__port
=
443
try
:
try
:
self
.
__port
=
443
self
.
__port
=
443
self
.
__connection
=
http
lib
.
HTTPSConnection
(
self
.
__connection
=
http
.
client
.
HTTPSConnection
(
self
.
get_host
(),
self
.
get_host
(),
self
.
__port
,
self
.
__port
,
cert_file
=
self
.
__cert_file
,
cert_file
=
self
.
__cert_file
,
...
...
aliyunsdkcore/profile/region_provider.py
View file @
76082e7c
...
@@ -132,8 +132,8 @@ def convert_dict_to_endpointsxml(mdict):
...
@@ -132,8 +132,8 @@ def convert_dict_to_endpointsxml(mdict):
content
+=
'</RegionIds>
\n
'
+
'<Products>
\n
'
content
+=
'</RegionIds>
\n
'
+
'<Products>
\n
'
for
item
in
products
:
for
item
in
products
:
content
+=
'<Product>
\n
'
content
+=
'<Product>
\n
'
content
+=
'<ProductName>'
+
item
.
keys
(
)[
0
]
+
'</ProductName>
\n
'
content
+=
'<ProductName>'
+
list
(
item
.
keys
()
)[
0
]
+
'</ProductName>
\n
'
content
+=
'<DomainName>'
+
item
[
item
.
keys
(
)[
0
]]
+
'</DomainName>
\n
'
content
+=
'<DomainName>'
+
item
[
list
(
item
.
keys
()
)[
0
]]
+
'</DomainName>
\n
'
content
+=
'</Product>
\n
'
content
+=
'</Product>
\n
'
content
+=
'</Products>'
content
+=
'</Products>'
content
+=
endfix
content
+=
endfix
...
@@ -144,8 +144,8 @@ def convert_dict_to_endpointsxml(mdict):
...
@@ -144,8 +144,8 @@ def convert_dict_to_endpointsxml(mdict):
try
:
try
:
f
.
write
(
''
.
join
(
content
))
f
.
write
(
''
.
join
(
content
))
except
Exception
as
e
:
except
Exception
as
e
:
print
e
print
(
e
)
print
"Please confirm you has use sudo + cmd"
print
(
"Please confirm you has use sudo + cmd"
)
finally
:
finally
:
f
.
close
()
f
.
close
()
...
@@ -160,5 +160,5 @@ def _createFile(filename):
...
@@ -160,5 +160,5 @@ def _createFile(filename):
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
print
find_product_domain
(
'cn-hangzhou'
,
'Rds'
)
print
(
find_product_domain
(
'cn-hangzhou'
,
'Rds'
)
)
modify_point
(
'ecs'
,
'cn-beijing-2'
,
'ecs.aliyuncs.com'
)
modify_point
(
'ecs'
,
'cn-beijing-2'
,
'ecs.aliyuncs.com'
)
aliyunsdkcore/request.py
View file @
76082e7c
...
@@ -48,11 +48,10 @@ STYLE_ROA = 'ROA'
...
@@ -48,11 +48,10 @@ STYLE_ROA = 'ROA'
STYLE_OSS
=
'OSS'
STYLE_OSS
=
'OSS'
class
AcsRequest
:
class
AcsRequest
(
metaclass
=
abc
.
ABCMeta
)
:
"""
"""
Acs request base class. This class wraps up common parameters for a request.
Acs request base class. This class wraps up common parameters for a request.
"""
"""
__metaclass__
=
abc
.
ABCMeta
def
__init__
(
self
,
product
,
version
=
None
,
def
__init__
(
self
,
product
,
version
=
None
,
action_name
=
None
,
action_name
=
None
,
...
@@ -239,7 +238,7 @@ class RpcRequest(AcsRequest):
...
@@ -239,7 +238,7 @@ class RpcRequest(AcsRequest):
def
get_url
(
self
,
region_id
,
ak
,
secret
):
def
get_url
(
self
,
region_id
,
ak
,
secret
):
sign_params
=
self
.
__get_sign_params
()
sign_params
=
self
.
__get_sign_params
()
if
'RegionId'
not
in
sign_params
.
keys
(
):
if
'RegionId'
not
in
list
(
sign_params
.
keys
()
):
sign_params
[
'RegionId'
]
=
region_id
sign_params
[
'RegionId'
]
=
region_id
url
=
rpc_signer
.
get_signed_url
(
url
=
rpc_signer
.
get_signed_url
(
sign_params
,
sign_params
,
...
@@ -335,7 +334,7 @@ class RoaRequest(AcsRequest):
...
@@ -335,7 +334,7 @@ class RoaRequest(AcsRequest):
if
(
self
.
get_content
()
is
not
None
):
if
(
self
.
get_content
()
is
not
None
):
md5_str
=
md5_tool
.
get_md5_base64_str
(
self
.
get_content
())
md5_str
=
md5_tool
.
get_md5_base64_str
(
self
.
get_content
())
self
.
add_header
(
'Content-MD5'
,
md5_str
)
self
.
add_header
(
'Content-MD5'
,
md5_str
)
if
'RegionId'
not
in
sign_params
.
keys
(
):
if
'RegionId'
not
in
list
(
sign_params
.
keys
()
):
sign_params
[
'RegionId'
]
=
region_id
sign_params
[
'RegionId'
]
=
region_id
signed_headers
=
roa_signer
.
get_signature_headers
(
signed_headers
=
roa_signer
.
get_signature_headers
(
sign_params
,
sign_params
,
...
@@ -355,7 +354,7 @@ class RoaRequest(AcsRequest):
...
@@ -355,7 +354,7 @@ class RoaRequest(AcsRequest):
:return: String
:return: String
"""
"""
sign_params
=
self
.
get_query_params
()
sign_params
=
self
.
get_query_params
()
if
region_id
not
in
sign_params
.
keys
(
):
if
region_id
not
in
list
(
sign_params
.
keys
()
):
sign_params
[
'RegionId'
]
=
region_id
sign_params
[
'RegionId'
]
=
region_id
url
=
roa_signer
.
get_url
(
url
=
roa_signer
.
get_url
(
self
.
get_uri_pattern
(),
self
.
get_uri_pattern
(),
...
@@ -442,7 +441,7 @@ class OssRequest(AcsRequest):
...
@@ -442,7 +441,7 @@ class OssRequest(AcsRequest):
:return:
:return:
"""
"""
sign_params
=
self
.
get_query_params
()
sign_params
=
self
.
get_query_params
()
if
'RegionId'
not
in
sign_params
.
keys
(
):
if
'RegionId'
not
in
list
(
sign_params
.
keys
()
):
sign_params
[
'RegionId'
]
=
region_id
sign_params
[
'RegionId'
]
=
region_id
signed_headers
=
oss_signer
.
get_signature_headers
(
signed_headers
=
oss_signer
.
get_signature_headers
(
sign_params
,
sign_params
,
...
@@ -463,7 +462,7 @@ class OssRequest(AcsRequest):
...
@@ -463,7 +462,7 @@ class OssRequest(AcsRequest):
:return: String
:return: String
"""
"""
sign_params
=
self
.
get_query_params
()
sign_params
=
self
.
get_query_params
()
if
'RegionId'
not
in
sign_params
.
keys
(
):
if
'RegionId'
not
in
list
(
sign_params
.
keys
()
):
sign_params
[
'RegionId'
]
=
region_id
sign_params
[
'RegionId'
]
=
region_id
url
=
oss_signer
.
get_url
(
url
=
oss_signer
.
get_url
(
sign_params
,
sign_params
,
...
...
aliyunsdkcore/utils/parameter_helper.py
View file @
76082e7c
...
@@ -23,7 +23,7 @@ import hashlib
...
@@ -23,7 +23,7 @@ import hashlib
import
base64
import
base64
import
uuid
import
uuid
import
time
import
time
import
urllib
import
urllib
.request
,
urllib
.
parse
,
urllib
.
error
import
sys
import
sys
TIME_ZONE
=
"GMT"
TIME_ZONE
=
"GMT"
...
@@ -50,9 +50,9 @@ def md5_sum(content):
...
@@ -50,9 +50,9 @@ def md5_sum(content):
def
percent_encode
(
encodeStr
):
def
percent_encode
(
encodeStr
):
encodeStr
=
str
(
encodeStr
)
encodeStr
=
str
(
encodeStr
)
if
sys
.
stdin
.
encoding
is
None
:
if
sys
.
stdin
.
encoding
is
None
:
res
=
urllib
.
quote
(
encodeStr
.
decode
(
'cp936'
)
.
encode
(
'utf8'
),
''
)
res
=
urllib
.
parse
.
quote
(
encodeStr
.
decode
(
'cp936'
)
.
encode
(
'utf8'
),
''
)
else
:
else
:
res
=
urllib
.
quote
(
res
=
urllib
.
parse
.
quote
(
encodeStr
.
decode
(
encodeStr
.
decode
(
sys
.
stdin
.
encoding
)
.
encode
(
'utf8'
),
''
)
sys
.
stdin
.
encoding
)
.
encode
(
'utf8'
),
''
)
res
=
res
.
replace
(
'+'
,
'
%20
'
)
res
=
res
.
replace
(
'+'
,
'
%20
'
)
...
@@ -62,6 +62,6 @@ def percent_encode(encodeStr):
...
@@ -62,6 +62,6 @@ def percent_encode(encodeStr):
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
print
get_uuid
(
)
print
(
get_uuid
()
)
print
get_iso_8061_date
(
)
print
(
get_iso_8061_date
()
)
print
get_rfc_2616_date
(
)
print
(
get_rfc_2616_date
()
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment