前几天看到列表里有人提起这个问题,而自己也有这个需求,今天在家里写了这个脚本,主要功能是上传几个内容相同的app到GAE上去,代码很简单。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30 #!/usr/bin/env python
#coding=utf-8
import os
def update():
cfile = ‘myapp/app.yaml’
applist = (‘app0’,‘app1’,‘app2’,‘app3’,‘app04’,<br /> ‘myapp’,)
for app in applist:
fp = open(cfile,‘r’)
lines = fp.readlines()
text = []
for loop,line in enumerate(lines):
if not loop:
line = ‘application: %s\n’ % (app)
print line
text.append(line)
texts = ‘’.join(text)
fp.close()
fp = open(cfile,‘w’)
fp.write(texts)
fp.close()
os.system(‘appcfg.py -e youremail@gmail.com update myapp’)
def main():
update()
if name=="main":
main()
说明:
1、该脚本是在appengine的根目录下的,和appcfg.py平级,如C:\Program Files\Google\google_appengine<br />2、myapp是要复制多份的GAE app目录。applist是个tulple,放置要复制的app的名字。
3、执行的命令需要用户名和密码,在命令里提前先把email地址写了。
密码在命令里找不到,我想得在代码里改了。
在C:\Program Files\Google\google_appengine\google\appengine\tools里的appcfg.py里增加一个条件改写一下密码。我在GetUserCredentials()函数里增加一个条件把密码写上。
password_prompt = ‘Password for %s: ’ % email
if self.options.passin:
password = self.raw_input_fn(password_prompt)
elif email == ‘yourname@gmail.com’:
password = ‘×××××××’
else:
password = self.password_input_fn(password_prompt)
谁有好的方法也欢迎提出改进啊,谢谢!
批量上传GAE APP的方法
批量上传GAE APP的方法
...