equal
deleted
inserted
replaced
12 # distributed under the License is distributed on an "AS IS" BASIS, |
12 # distributed under the License is distributed on an "AS IS" BASIS, |
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
14 # See the License for the specific language governing permissions and |
14 # See the License for the specific language governing permissions and |
15 # limitations under the License. |
15 # limitations under the License. |
16 |
16 |
17 """A script to generate the app.yaml from the template with an application |
17 """gen_app_yaml.py [-f] (-i | APPLICATION_NAME) |
|
18 |
|
19 A script to generate the app.yaml from the template with an application |
18 name filled in. |
20 name filled in. |
19 |
|
20 Usage: |
|
21 gen_app_yaml.py [-f] APPLICATION_NAME |
|
22 |
21 |
23 Arguments: |
22 Arguments: |
24 APPLICATION_NAME: the name to use for the application (no underscores) |
23 APPLICATION_NAME: the name to use for the application (no underscores) |
25 |
|
26 Flags: |
|
27 -f: overwrite an existing app.yaml (default=false) |
|
28 """ |
24 """ |
29 |
25 |
30 from __future__ import with_statement |
26 from __future__ import with_statement |
31 |
27 |
32 __authors__ = [ |
28 __authors__ = [ |
35 ] |
31 ] |
36 |
32 |
37 |
33 |
38 import os |
34 import os |
39 import sys |
35 import sys |
|
36 from optparse import OptionParser |
40 |
37 |
41 |
38 |
42 def generateAppYaml(application_name, force=False): |
39 def generateAppYaml(application_name, force=False): |
43 """Generate the app.yaml file. |
40 """Generate the app.yaml file. |
44 |
41 |
82 |
79 |
83 def main(args): |
80 def main(args): |
84 """Main program. |
81 """Main program. |
85 """ |
82 """ |
86 |
83 |
87 if not args: |
84 parser = OptionParser(usage=__doc__) |
88 usage("No arguments supplied.") |
85 parser.add_option("-f", "--force", action="store_true", default=False, |
|
86 help="Overwrite existing app.yaml") |
|
87 parser.add_option("-i", "--interactive", action="store_true", default=False, |
|
88 help="Ask for the application name interactively") |
89 |
89 |
90 if args[0] == '-f': |
90 options, args = parser.parse_args(args) |
91 force = True |
91 |
92 args = args[1:] |
92 if options.interactive: |
|
93 if args: |
|
94 parser.error("Cannot combine application name with -i") |
|
95 sys.stdout.write("Application name: ") |
|
96 application_name = sys.stdin.readline().strip() |
93 else: |
97 else: |
94 force = False |
98 if len(args) != 1: |
|
99 parser.error("No application name supplied.") |
|
100 application_name = args[0] |
95 |
101 |
96 if len(args) != 1: |
102 generateAppYaml(application_name, force=options.force) |
97 usage("No application name supplied.") |
|
98 |
|
99 application_name = args[0] |
|
100 generateAppYaml(application_name, force=force) |
|
101 |
|
102 |
103 |
103 if __name__ == '__main__': |
104 if __name__ == '__main__': |
104 main(sys.argv[1:]) # strip off the binary name |
105 main(sys.argv[1:]) # strip off the binary name |