def cs_encode(s):
if PY2 and isinstance(s, text_type):<EOL><INDENT>s = s.encode("<STR_LIT:utf-8>")<EOL><DEDENT>return quote(s, safe="<STR_LIT:*>")<EOL>
Encode URI component like CloudStack would do before signing.

    java.net.URLEncoder.encode(s).replace('+', '%20')