下面是我检查我的回购的代码.我想在我的厨师开发环境中开发分支.
git "/home/ubuntu/workspace/repo" do
repository "git@github.com:me/repo.git"
revision "development"
action :sync
user "root"
end
Run Code Online (Sandbox Code Playgroud)
当我看到结账分支时,我得到:
* deploy
master
Run Code Online (Sandbox Code Playgroud)
如果我在盒子上运行git checkout开发,我得到:
deploy
* development
master
Run Code Online (Sandbox Code Playgroud)
那么....我怎么得到git来检查我的厨师开发分支?
我正在使用厨师维基的例子.厨师wiki git例子
if node.chef_environment == "QA"
branch_name = "staging"
else
branch_name = "master"
end
git "/home/user/deployment" do
repository "git@github.com:gitsite/deployment.git"
revision branch_name
action :sync
user "user"
group "test"
end
Run Code Online (Sandbox Code Playgroud) 我只想在python中发送带附件的电子邮件
import smtplib, os
from email.MIMEMultipart import MIMEMultipart
from email.MIMEBase import MIMEBase
from email.MIMEText import MIMEText
from email.Utils import COMMASPACE, formatdate
from email import Encoders
def send_mail(send_from, send_to, subject, text, files=[], server="localhost"):
assert type(send_to)==list
assert type(files)==list
msg = MIMEMultipart()
msg['From'] = send_from
msg['To'] = COMMASPACE.join(send_to)
msg['Date'] = formatdate(localtime=True)
msg['Subject'] = subject
msg.attach( MIMEText(text) )
for f in files:
part = MIMEBase('application', "octet-stream")
part.set_payload( open(f,"rb").read() )
Encoders.encode_base64(part)
part.add_header('Content-Disposition', 'attachment; filename="%s"' % os.path.basename(f))
msg.attach(part)
smtp = smtplib.SMTP('smtp.gmail.com:587')
smtp.login('fu@gmail.com','fu')
smtp.sendmail(send_from, send_to, msg.as_string())
smtp.close() …Run Code Online (Sandbox Code Playgroud) 在python中,我使用以下内容:
context = zmq.Context()
socket = context.socket(zmq.PUSH)
socket.bind_to_random_port('tcp://*', min_port=6001, max_port=6004, max_tries=100)
port_selected = socket.???????
Run Code Online (Sandbox Code Playgroud)
我怎么知道选择了什么端口?我将在redis中查找工作表以供工人阅读.
我正在使用推拉模型.我需要让工人知道要连接的端口.
我必须这样做,因为我在uwsgi中使用gevent循环并指定一个普通的盲目的thows和错误,因为一个分叉.如果使用bind_to_random_port然后选择一个端口,我只是不知道哪个.
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/gevent-1.0b2-py2.7-linux-x86_64.egg/gevent/greenlet.py",
line 328, in run
result = self._run(*self.args, **self.kwargs)
File "/home/ubuntu/workspace/rtbopsConfig/rtbServers/rtbUwsgiPixelServer/uwsgiPixelServer.py",
line 43, in sendthis
socket.send(push)
File "/usr/local/lib/python2.7/dist-packages/zmq/green/core.py",
line 173, in send
self._wait_write()
File "/usr/local/lib/python2.7/dist-packages/zmq/green/core.py",
line 108, in _wait_write
assert self.__writable.ready(), "Only one greenlet can be waiting
on this event"
AssertionError: Only one greenlet can be waiting on this event
<Greenlet at 0x2d41370: sendthis('2012-07-02 04:05:15')> failed with …Run Code Online (Sandbox Code Playgroud) 我有一个看起来像这样的元组列表:
[('this', 'is'), ('is', 'the'), ('the', 'first'), ('first', 'document'), ('document', '.')]
Run Code Online (Sandbox Code Playgroud)
什么是最pythonic和有效的方式转换为每个令牌由空格分隔:
['this is', 'is the', 'the first', 'first document', 'document .']
Run Code Online (Sandbox Code Playgroud) 我得到了bson文件的数据转储.在mongo db中,存在数据库和集合.这些是对数据库中每个集合的更新.因此,在给定目录中,每个集合大约有30个bson文件.
从命令行,我使用的是ubuntu,如何追加和加载?Mongo在我的localhost上,没有用户名或密码.
谢谢
我正在使用最新版本的flask,wtforms和Flask-WTForms.
我有一个显示表单的页面,其中一个是带有选项选项的选择框,名为"A".
当应用程序启动时,一切都很好.在另一种形式中,我添加了一个名为"B"的记录.
现在,我想要的表单应该有选项框和选项A和B bot只有选项A可用.我必须杀死uWSGI并重新启动以获取wtforms来刷新数据.
那么,我错过了什么?如何让wtforms刷新数据?
这是我如何创建表单,其中getAgencyList返回要添加到选择框的选项列表.在另一个对话框中,我添加了代理商,代理商列表应该更新,而无需重新启动应用:
class createUser(Form):
"""
Users are given a default password
"""
first_name = TextField()
last_name = TextField()
email = TextField('Email', [validators.Length(min=6, max=120), validators.Email()])
user_role = SelectField(u'User Role', choices=[('1', 'User'), ('2', 'Admin')])
org_role = SelectField(u'User Role', choices=[('1', 'Agency'), ('2', 'Advertiser'),('3', 'Admin')])
agency = SelectField(u'Agency', choices=getAgencyList())
Run Code Online (Sandbox Code Playgroud) 我无法在Flask Babel中获得基本的翻译工作.
这是我的步骤.
我在一个页面中有这个 {{_("Hello")}}
我运行这个命令.
pybabel extract -F babel.cfg -o messages.pot .
Run Code Online (Sandbox Code Playgroud)然后我为德语运行此命令.
pybabel init -i messages.pot -d translations -l de
Run Code Online (Sandbox Code Playgroud)这是德语的mo文件 /app/translations/de/LC_MESSAGES/messages.po
# German translations for PROJECT.
# Copyright (C) 2012 ORGANIZATION
# This file is distributed under the same license as the PROJECT project.
# FIRST AUTHOR <EMAIL@ADDRESS>, 2012.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2012-09-24 03:36+0800\n"
"PO-Revision-Date: 2012-09-24 03:37+0800\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: de <LL@li.org>\n"
"Plural-Forms: nplurals=2; plural=(n …Run Code Online (Sandbox Code Playgroud)如何在python 2.7中获取urllib2的状态码?我不想使用请求.我需要urllib2.
request = urllib2.Request(url, headers=headers)
contents = urllib2.urlopen(request).read()
print request.getcode()
contents = json.loads(contents)
<type 'exceptions.AttributeError'>, AttributeError('getcode',), <traceback object at 0x7f6238792b48>
Run Code Online (Sandbox Code Playgroud)
谢谢
angular2-universal的维护者没有更新他们的网站:
问题1)
typings install node express body-parser serve-static express-serve-static-core mime --ambient
typings ERR! deprecated The "ambient" flag is deprecated. Please use "global" instead
Run Code Online (Sandbox Code Playgroud)
问题2)
typings install node express body-parser serve-static express-serve-static-core mime --global
typings INFO globaldependencies "express" lists global dependencies on "node" that must be installed manually
typings INFO globaldependencies "body-parser" lists global dependencies on "node" that must be installed manually
typings ERR! message Unable to find "node" ("npm") in the registry.
typings ERR! message However, we found "node" …Run Code Online (Sandbox Code Playgroud) 我正在使用lua支持构建nginx,如下所示.
export LUAJIT_LIB=/usr/local/lib/
export LUAJIT_INC=/usr/local/include/luajit-2.0/
./configure --with-http_geoip_module --with-http_stub_status_module --with-http_ssl_module --add-module=/home/ubuntu/ngx_devel_kit --add-module=/home/ubuntu/lua-nginx-module --add-module=/home/ubuntu/redis2-nginx-module --add-module=/home/ubuntu/form-input-nginx-module
make -j2
sudo make install
Run Code Online (Sandbox Code Playgroud)
似乎编译好了.
当我启动nginx时,我收到此错误
sudo /etc/init.d/nginx start
Starting nginx: /usr/local/nginx/sbin/nginx: error while loading shared libraries: libluajit-5.1.so.2: cannot open shared object file: No such file or directory
Run Code Online (Sandbox Code Playgroud)
然后我找到有问题的文件,它位于/usr/local/lib/libluajit-5.1.so.2
然后我补充说:
LD_LIBRARY_PATH=/usr/local/lib/:$LD_LIBRARY_PATH
sudo /etc/init.d/nginx start
Run Code Online (Sandbox Code Playgroud)
我仍然得到错误.我没有想法.
谢谢