1
from optparse import OptionParser
4
from txaws import version
7
# XXX Once we start adding script that require conflicting options, we'll need
8
# multiple parsers and option dispatching...
9
def parse_options(usage):
10
parser = OptionParser(usage, version="%s %s" % (
11
meta.display_name, version.txaws))
13
"-a", "--access-key", dest="access_key", help="access key ID")
15
"-s", "--secret-key", dest="secret_key", help="access secret key")
17
"-r", "--region", dest="region", help="US or EU (valid for AWS only)")
19
"-U", "--url", dest="url", help="service URL/endpoint")
21
"-b", "--bucket", dest="bucket", help="name of the bucket")
23
"-o", "--object-name", dest="object_name", help="name of the object")
25
"-d", "--object-data", dest="object_data",
26
help="content data of the object")
28
"--object-file", dest="object_filename",
29
help=("the path to the file that will be saved as an object; if "
30
"provided, the --object-name and --object-data options are "
33
"-c", "--content-type", dest="content_type",
34
help="content type of the object")
35
options, args = parser.parse_args()
36
if not (options.access_key and options.secret_key):
38
"both the access key ID and the secret key must be supplied")
39
region = options.region
40
if region and region.upper() not in ["US", "EU"]:
41
parser.error("region must be one of 'US' or 'EU'")
42
return (options, args)