~tribaal/txaws/xss-hardening

« back to all changes in this revision

Viewing changes to txaws/util.py

Merged 424018-add-keypair-support [r=jkakar] [f=424018]

This change implements three keypair methods in the EC2 client:
 1. describe_keypairs
 2. create_keypair
 3. delete_keypair

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
"""Generally useful utilities for AWS web services not specific to a service.
2
2
 
3
 
New things in this module should be of relevance to more than one of amazon's
 
3
New things in this module should be of relevance to more than one of Amazon's
4
4
services.
5
5
"""
6
6
 
72
72
    url = url.strip()
73
73
    parsed = urlparse(url)
74
74
    scheme = parsed[0]
75
 
    path = urlunparse(('', '') + parsed[2:])
 
75
    path = urlunparse(("", "") + parsed[2:])
76
76
    if defaultPort is None:
77
 
        if scheme == 'https':
 
77
        if scheme == "https":
78
78
            defaultPort = 443
79
79
        else:
80
80
            defaultPort = 80
81
81
    host, port = parsed[1], defaultPort
82
 
    if ':' in host:
83
 
        host, port = host.split(':')
 
82
    if ":" in host:
 
83
        host, port = host.split(":")
84
84
        try:
85
85
            port = int(port)
86
86
        except ValueError:
87
87
            port = defaultPort
88
 
    if path == '':
89
 
        path = '/'
 
88
    if path == "":
 
89
        path = "/"
90
90
    return scheme, host, port, path