Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(93)

Side by Side Diff: third_party/gsutil/20110627/boto/bin/cfadmin

Issue 10199002: Upgrade gsutil to 3.4 (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed comments Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 #!/usr/bin/env python
2 # Author: Chris Moyer
3 #
4 # cfadmin is similar to sdbadmin for CloudFront, it's a simple
5 # console utility to perform the most frequent tasks with CloudFront
6 #
7 def _print_distributions(dists):
8 """Internal function to print out all the distributions provided"""
9 print "%-12s %-50s %s" % ("Status", "Domain Name", "Origin")
10 print "-"*80
11 for d in dists:
12 print "%-12s %-50s %-30s" % (d.status, d.domain_name, d.origin)
13 for cname in d.cnames:
14 print " "*12, "CNAME => %s" % cname
15 print ""
16
17 def help(cf, fnc=None):
18 """Print help message, optionally about a specific function"""
19 import inspect
20 self = sys.modules['__main__']
21 if fnc:
22 try:
23 cmd = getattr(self, fnc)
24 except:
25 cmd = None
26 if not inspect.isfunction(cmd):
27 print "No function named: %s found" % fnc
28 sys.exit(2)
29 (args, varargs, varkw, defaults) = inspect.getargspec(cmd)
30 print cmd.__doc__
31 print "Usage: %s %s" % (fnc, " ".join([ "[%s]" % a for a in args[1:]]))
32 else:
33 print "Usage: cfadmin [command]"
34 for cname in dir(self):
35 if not cname.startswith("_"):
36 cmd = getattr(self, cname)
37 if inspect.isfunction(cmd):
38 doc = cmd.__doc__
39 print "\t%s - %s" % (cname, doc)
40 sys.exit(1)
41
42 def ls(cf):
43 """List all distributions and streaming distributions"""
44 print "Standard Distributions"
45 _print_distributions(cf.get_all_distributions())
46 print "Streaming Distributions"
47 _print_distributions(cf.get_all_streaming_distributions())
48
49 def invalidate(cf, origin_or_id, *paths):
50 """Create a cloudfront invalidation request"""
51 # Allow paths to be passed using stdin
52 if not paths:
53 paths = []
54 for path in sys.stdin.readlines():
55 path = path.strip()
56 if path:
57 paths.append(path)
58 dist = None
59 for d in cf.get_all_distributions():
60 if d.id == origin_or_id or d.origin.dns_name == origin_or_id:
61 dist = d
62 break
63 if not dist:
64 print "Distribution not found: %s" % origin_or_id
65 sys.exit(1)
66 cf.create_invalidation_request(dist.id, paths)
67
68 if __name__ == "__main__":
69 import boto
70 import sys
71 cf = boto.connect_cloudfront()
72 self = sys.modules['__main__']
73 if len(sys.argv) >= 2:
74 try:
75 cmd = getattr(self, sys.argv[1])
76 except:
77 cmd = None
78 args = sys.argv[2:]
79 else:
80 cmd = help
81 args = []
82 if not cmd:
83 cmd = help
84 try:
85 cmd(cf, *args)
86 except TypeError, e:
87 print e
88 help(cf, cmd.__name__)
OLDNEW
« no previous file with comments | « third_party/gsutil/20110627/boto/bin/bundle_image ('k') | third_party/gsutil/20110627/boto/bin/cq » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698