我正在使用Django并使用Ansible部署我的堆栈.最后,我使用Fabric来部署我的Django项目,从GitHub中提取我的代码.
我的问题:在Django的settings.py文件中处理私人设置的最佳做法是什么,例如电子邮件或S3的密码?目前,我在部署脚本结束时将settings_production.py从我的机器文件传输到生产机器,然后重新启动应用程序服务器.此文件包含我没有将settings.py作为repo的一部分放入的设置.
在我的settings.py结束时,我正在添加类似的内容
try:
from settings_production import *
except ImportError:
pass
Run Code Online (Sandbox Code Playgroud)
有没有更好的方法来做到这一点?
我想重现我运行的旧Fabric1脚本的行为
sudo('useradd -m -u --groups mygroup myuser')
Run Code Online (Sandbox Code Playgroud)
在这种情况下,远程机器(Ubuntu AWS实例)会提示我输入我的sudo密码,我可以输入它.即使错误输入后的重复提示也可以.之后,Fabric1将通过保持连接打开来保持该密码.
在我的新的Fabric 2.x脚本中,我在@task中使用
c.sudo('useradd -m -u --groups mygroup myuser')
Run Code Online (Sandbox Code Playgroud)
我仍然收到用户提示,但它不等待我的响应,我无法输入密码,并且它按预期失败
invoke.exceptions.AuthFailure: The password submitted to prompt '[sudo] password: ' was rejected
Run Code Online (Sandbox Code Playgroud)
使用--prompt-for-sudo-password参数具有相同(或无效).
我也试过了
run('sudo useradd -m -u --groups mygroup myuser')
Run Code Online (Sandbox Code Playgroud)
并收到
sudo: no tty present and no askpass program specified
Run Code Online (Sandbox Code Playgroud)
我最好不要在没有Fabric 1.x的情况下在一台完美运行的机器上设置askpass程序(除非我能从我的脚本那样做,这需要sudo,我猜).
我一直在撞墙试图使用复杂且没有完善记录的配置系统,但没有成功.
我错过了什么?如果需要额外的配置,我想知道配置文件的语法以及放置该文件的位置,以便通过fab CLI命令获取它.
我正在尝试在 ViewerResponse 事件上使用 Lambda@Edge 从 Cloudfront 响应中删除一些标头。源是一个 S3 存储桶。
我已经成功地改变了这样的标题:
exports.handler = (event, context, callback) => {
const response = event.Records[0].cf.response;
response.headers.server = [{'key': 'server', 'value': 'bunny'}];
callback(null, response);
};
Run Code Online (Sandbox Code Playgroud)
但是,将所有标题一起删除似乎不起作用,例如像这样。
exports.handler = (event, context, callback) => {
const response = event.Records[0].cf.response;
delete response.headers.server;
// or response.header.server = null;
// or response.headers.server = [{'key': 'server', 'value': null}];
callback(null, response);
};
Run Code Online (Sandbox Code Playgroud)
此代码段不会删除但将服务器标头从 更改server: AmazonS3为server: CloudFront。所以我假设服务器标头可能是强制性的并且会自动填充。但我也无法删除 CloudFront 生成的其他标头。在 lambda 测试窗格中,该函数按预期工作。所以在 Lambda 函数完成后会发生一些事情。
作为背景,我想更改标题,因为该站点在重要客户的网络中被阻止,并显示它是在线存储或备份位置的消息。
我错过了什么?
我用 python 制作了一些模块,我想在我的组织内部分发它们。这些模块已经存储在 BitBucket 中。
例如,有没有办法使用“pip install”来分发它们?
什么是正确的方法?
什么是boto3相当于:
import boto
conn = boto.connect_ec2()
addresses = conn.get_all_addresses()
Run Code Online (Sandbox Code Playgroud)
(返回所有弹性IP地址)
import boto3
ec2 = boto3.resource('ec2')
addresses = ec2.????
Run Code Online (Sandbox Code Playgroud)
我对于似乎适用于VPC设置的概括感到有点困惑.
到目前为止我发现的是:
import boto3
client = boto3.client('ec2')
print client.describe_addresses()
Run Code Online (Sandbox Code Playgroud)
此响应似乎不包含关联状态.
我正在使用Google EarthEngine Python API。我有一个图像集合(MODIS),想提取一个包含每个时间步长区域平均NDVI的时间序列。
目前,我正在迭代单个图像并提取每个图像的值。喜欢
feature_geometry = {
'type': 'MultiPolygon',
'coordinates': [[[
[-120, 35],
[-120.001, 35],
[-120.001, 35.001],
[-120, 35.001],
[-120, 35]
]]]
}
ee.Initialize()
feature = ee.Feature(feature_geometry)
collection = ee.ImageCollection(
'MODIS/006/MOD13Q1').filterDate('2017-01-01', '2017-05-01')
images = [
item.get('id') for item in collection.getInfo().get('features')]
for image in images:
print(ee.Image(image).reduceRegion(
ee.Reducer.mean(), feature.geometry()).getInfo()['NDVI'])
Run Code Online (Sandbox Code Playgroud)
的问题:是否有一种方式来获得同样的结果在一个单一的请求EarthEngine,因为我往往会碰到请求限制。
python ×5
fabric ×2
amazon-s3 ×1
aws-lambda ×1
boto3 ×1
deployment ×1
django ×1
javascript ×1
pip ×1
security ×1
setuptools ×1
sudo ×1