我试图从现有的lambda函数调用另一个lambda函数,如下所示(python 2.7)
from __future__ import print_function
import boto3
import json
lambda_client = boto3.client('lambda')
def lambda_handler(event, context):
invoke_response = lambda_client.invoke(FunctionName="teststack",
InvocationType='RequestResponse'
)
print(invoke_response)
return str(invoke_response)
Run Code Online (Sandbox Code Playgroud)
我得到的是以下的响应而不是实际的结果.当我运行teststack lambda时,它运行正常,但得到低于响应而不是teststackLambda函数返回的"test" .
{u'Payload': <botocore.response.StreamingBody object at ****>, 'ResponseMetadata': {'HTTPStatusCode': 200, 'RequestId': '******', 'HTTPHeaders': {'x-amzn-requestid': '******', 'content-length': '155', 'x-amzn-remapped-content-length': '0', 'connection': 'keep-alive', 'date': 'Sun, 17 Jul 2016 21:02:01 GMT', 'content-type': 'application/json'}}, u'StatusCode': 200}
Run Code Online (Sandbox Code Playgroud) 我写了一个烧瓶应用程序,它工作得非常好.我想将它作为可执行文件分发.尝试使用pyinstaller使用flaskScript.py dist文件夹生成.进入dist文件夹并双击我的可执行文件flaskScript,它启动我的服务器.在访问url时,localhost:9090会出现以下异常
jinja2.exceptions.TemplateNotFound
TemplateNotFound: index.html
Traceback (most recent call last)
File "/Users/george/Downloads/flaskApps/flaskScript/build/flaskScript/out00-PYZ.pyz/flask.app", line 1836, in __call__
File "/Users/george/Downloads/flaskApps/flaskScript/build/flaskScript/out00-PYZ.pyz/flask.app", line 1820, in wsgi_app
File "/Users/george/Downloads/flaskApps/flaskScript/build/flaskScript/out00-PYZ.pyz/flask.app", line 1403, in handle_exception
File "/Users/george/Downloads/flaskApps/flaskScript/build/flaskScript/out00-PYZ.pyz/flask.app", line 1817, in wsgi_app
File "/Users/george/Downloads/flaskApps/flaskScript/build/flaskScript/out00-PYZ.pyz/flask.app", line 1477, in full_dispatch_request
File "/Users/george/Downloads/flaskApps/flaskScript/build/flaskScript/out00-PYZ.pyz/flask.app", line 1381, in handle_user_exception
File "/Users/george/Downloads/flaskApps/flaskScript/build/flaskScript/out00-PYZ.pyz/flask.app", line 1475, in full_dispatch_request
File "/Users/george/Downloads/flaskApps/flaskScript/build/flaskScript/out00-PYZ.pyz/flask.app", line 1461, in dispatch_request
File "<string>", line 13, in index
File "/Users/george/Downloads/flaskApps/flaskScript/build/flaskScript/out00-PYZ.pyz/flask.templating", line 127, in render_template
File "/Users/george/Downloads/flaskApps/flaskScript/build/flaskScript/out00-PYZ.pyz/jinja2.environment", line 851, in get_or_select_template
File "/Users/george/Downloads/flaskApps/flaskScript/build/flaskScript/out00-PYZ.pyz/jinja2.environment", line 812, …Run Code Online (Sandbox Code Playgroud) 我正在尝试生成给定大小的完全随机图像.
这是我到目前为止:
<?php
$Width = 64;
$Height = 32;
$Image = imagecreate($Width, $Height);
for($Row = 1; $Row <= $Height; $Row++) {
for($Column = 1; $Column <= $Width; $Column++) {
$Red = mt_rand(0,255);
$Green = mt_rand(0,255);
$Blue = mt_rand(0,255);
$Colour = imagecolorallocate ($Image, $Red , $Green, $Blue);
imagesetpixel($Image,$Column - 1 , $Row - 1, $Colour);
}
}
header('Content-type: image/png');
imagepng($Image);
?>
Run Code Online (Sandbox Code Playgroud)
问题是在4行之后它会停止随机并填充这样的纯色

您可以使用以下命令获取 python 发行版的版本
import pkg_resources
pkg_resources.get_distribution("distro").version
Run Code Online (Sandbox Code Playgroud)
如果您知道发行版名称,那就太好了,但是我需要在运行时动态找出我的发行版名称。
# Common framework base app class, extended by each app
class App(object):
def get_app_version(self) -> str:
package_name = self.__class__.__module__.split('.')[0]
try:
return pkg_resources.get_distribution(package_name).version
except Exception:
return "development"
Run Code Online (Sandbox Code Playgroud)
这适用于应用程序包名称与分发名称相同的情况(例如requests)。然而,一旦它们不匹配(例如my-app包含 package my_app),这就会失败。
所以我需要的是发行版和它们的包之间的映射,我确定它一定存在于某个地方,因为 pip 似乎知道在调用卸载时要删除什么:
$ pip uninstall requests
Uninstalling requests-2.21.0:
Would remove:
/home/user/.virtualenvs/app/lib/python3.6/site-packages/requests-2.21.0.dist-info/*
/home/user/.virtualenvs/app/lib/python3.6/site-packages/requests/*
Run Code Online (Sandbox Code Playgroud)
如何以编程方式访问此映射?
我试图将 CloudFront 发行版放在使用基本 http 身份验证的 Yum (RPM) 存储库前面。我已经设置了带有 HTTPS 的 CloudFront 分配,从 HTTP 重定向到 HTTPS,具有以下值:
Origin: yum.mydomain.com
Origin ID: smp-yum.mydomain.com
Run Code Online (Sandbox Code Playgroud)
注意:smp-yum.mydomain.com 目前不存在,我不确定是否需要?
出于测试目的,我严格使用 abcdefgh.cloudfront.net 域。
我在尝试访问 URL 时收到以下错误:
CloudFront attempted to establish a connection with the origin, but either the attempt failed or the origin closed the connection.
Run Code Online (Sandbox Code Playgroud)
因为我知道主机已启动,并且接受来自公共互联网的连接,所以我只能假设这是由于 http 基本身份验证所致。
我还尝试通过以下方式将凭据包含到请求中
https://username:password@yum.mydomain.com/repo/url
Run Code Online (Sandbox Code Playgroud)
我想这是一个由两部分组成的问题:是否可以使用 HTTP 基本身份验证?如果是这样,是否有一些标题或我需要自定义的内容才能使其正常工作?
yum basic-authentication amazon-web-services amazon-cloudfront
有什么方法可以在 Google 图表 api 上创建垂直刻度的中断吗?
除了一个接近 300,000 的值外,我在 y 轴上有几十个数据点,大约为 600-2000;这使得所有较小的数据点几乎无法读取。我需要表示所有这些数据,并且不能选择对数刻度。
