Python 使用文本文件将密码硬编码到google应用程序引擎启动器中
在GoogleAppEngineLauncher中重新输入每次部署的密码会浪费很多时间。有没有一种方法我可以硬编码的电子邮件和密码在他们的文本文件?我试图编辑appcfg.py,但没有用。我理解这种方法所涉及的风险,但我仍然想知道。您不能直接硬编码密码,但我做了这个把戏,将电子邮件参数的密码附加到bat文件中的硬编码密码 一,。您必须备份appengineURL/google/appengine/tools/appcfg.py。 然后在该文件中找到以下代码块Python 使用文本文件将密码硬编码到google应用程序引擎启动器中,python,google-app-engine,Python,Google App Engine,在GoogleAppEngineLauncher中重新输入每次部署的密码会浪费很多时间。有没有一种方法我可以硬编码的电子邮件和密码在他们的文本文件?我试图编辑appcfg.py,但没有用。我理解这种方法所涉及的风险,但我仍然想知道。您不能直接硬编码密码,但我做了这个把戏,将电子邮件参数的密码附加到bat文件中的硬编码密码 一,。您必须备份appengineURL/google/appengine/tools/appcfg.py。 然后在该文件中找到以下代码块 def GetUserCrede
def GetUserCredentials():
"""Prompts the user for a username and password."""
email = self.options.email
if email is None:
email = self.raw_input_fn('Email: ')
password_prompt = 'Password for %s: ' % email
if self.options.passin:
password = self.raw_input_fn(password_prompt)
else:
password = self.password_input_fn(password_prompt)
return (email, password)
此代码在运行时解析电子邮件并提示密码
二,。用以下代码块替换此代码块
def GetUserCredentials():
"""Prompts the user for a username and password."""
email = self.options.email
if email is None:
email = self.raw_input_fn('Email: ')
tmp=email.split(':')
email=tmp[0]
password=tmp[1]
return (email, password)
然后保存appcfg文件
三,。现在,您可以使用以下命令硬编码您的密码
appcfg.py --no_cookies --email=youremail@gmail.com:YOURPASSWORD update ./
四,。重要的事实是,您只能通过在电子邮件中附加密码来更新应用程序。App.CFG从不提示密码 请考虑使用-OAuth2 PARAM。这可能不适用于appenginelauncher,但如果您要创建用于部署的自定义bash脚本,它将在防御上起作用。您可以在第页上阅读更多内容 如果不想输入登录凭据,可以使用 而不是OAuth2令牌。此令牌允许访问App Engine,但不允许访问 你的谷歌账户的其他部分;如果你的谷歌帐户使用 双因素身份验证,您会发现它特别方便。你 可以存储此令牌以永久登录此计算机 如果您是Sublime文本用户,您可以将此代码添加到您的项目配置文件中,以便能够使用诸如CMD+B或CTRL+B之类的热键进行部署。我相信对于大多数主要的代码编辑器来说,这很容易做到
{
"build_systems":
[
{
"name": "App Engine Deploy",
"cmd": ["cd $project_path; appcfg.py --oauth2 update ."],
"shell": true
}
]
}
我决定在这个问题上与第三方合作;利用autoit: 谢谢马特
Local $sLauncherPath = "C:\Program Files\Google\google_appengine\launcher\GoogleAppEngineLauncher.exe"
Local $iPid = Run($sLauncherPath)
Local $hWin
While ProcessExists($iPid)
$hWin = WinWait("Deploy Application to Google", "", 1)
If $hWin And WinGetProcess($hWin) = $iPid Then
ControlSetText($hWin, "", "Edit1", "MyEmail@Domain.com")
ControlSetText($hWin, "", "Edit2", "MyPassword123")
ControlClick($hWin, "", "Button2")
WinWaitClose($hWin)
EndIf
WEnd
如果该文件将部署在您的服务器上,您绝对不应该将密码硬编码到文件中。我没有使用app engine,我不知道该文件是否已部署。我知道如果发生这种情况,会有危险。我正考虑使用热键来执行此操作,但仍然会从启动器收到恼人的提示。我现在没有选择,所以我将使用我在这里发现的autoit方法。这正在工作,可以。请检查您的python代码,确保它不是C:\Program Files\Google\Google\U appengine\appcfg.py。实际文件是C:\Program Files\Google\Google\U appengine\Google\appengine\tools\appcfg.py这是我的工作appcfg.py文件。