简体   繁体   English

从.yaml文件运行python命令

[英]Run a python command from a .yaml file

I have a python project working locally which runs under the UNIX command format of: python main.py arg1 arg2 etc. 我有一个在本地工作的python项目,该项目在UNIX命令格式下运行:python main.py arg1 arg2等。

I want to export my folder to the Google App Engine, so I did the small tutorial to make "Hello World" run on my App. 我想将文件夹导出到Google App Engine,所以我做了一个小教程,以使“ Hello World”在我的App上运行。 I read the app.yaml file but can't seem to figure out how to add an app.yaml to my project that runs my Python command. 我阅读了app.yaml文件,但似乎无法弄清楚如何将app.yaml添加到运行Python命令的项目中。

EDIT: 编辑:

runtime: python27
api_version: 1
threadsafe: true

command: ["/bin/sh", "-c"]
args: ["python webXMLPARSER.py www.reitmans.com 2016-12-01 2016-12-08"]

The short answer - you cannot do that. 简短的答案-您不能这样做。

The long one now. 现在很长。

GAE (standard) app code is not designed to run as a standalone app. GAE(标准)应用程序代码并非旨在作为独立应用程序运行。 It is merely a collection of config files and code snippets designed to work together with and complement the GAE infra code (live or SDK) in order to operate as an app. 它只是配置文件和代码片段的集合,旨在与GAE基础代码(实时或SDK)配合使用并对其进行补充,以便作为应用程序运行。

To run the app locally one must do it through the SDK's development server, see Using the Local Development Server for details. 要在本地运行该应用程序,必须通过SDK的开发服务器进行操作,有关详细信息,请参见使用本地开发服务器

Also: 也:

  • GAE apps are fundamentally web server apps, they get requests and return responses, they don't actually execute arbitrary python cmds. GAE应用程序本质上是Web服务器应用程序,它们获取请求并返回响应,它们实际上并不执行任意python cmds。 Your attempted config is invalid, see app.yaml Reference . 您尝试的配置无效,请参阅app.yaml参考

  • the GAE sandbox has significant restrictions when it comes to what the app can do, in particular launching other processes is not allowed. 对于应用程序可以执行的操作,GAE沙箱具有明显的限制,特别是不允许启动其他进程。 See The sandbox . 请参阅沙箱

First, you have to instruct to run a shell, and then pass arguments to the shell like python something.py args1 args2. 首先,您必须指示运行shell,然后将参数传递给shell,例如python something.py args1 args2。

command: bash -c "python something.py args1 args2"

You should try Dockerfiles 1 , they have a more intuitive way of running commads: 您应该尝试使用Dockerfiles 1 ,它们具有更直观的运行命令的方式:

CMD ["python", "something.py", "args1", "args2"] 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM