我有一个本地的docker-registry,我想用upstart来管理.
我有以下脚本(在/etc/init/docker-registry.conf中):
description "docker registry"
author "me"
start on filesystem and started docker
stop on runlevel [!2345]
respawn
script
/usr/bin/docker.io run -a stdout --rm --name=docker-registry \
-v /var/local/docker-registry:/var/local/docker-registry \
-p 5000:5000 mysite:5000/docker-registry
end script
Run Code Online (Sandbox Code Playgroud)
sudo start docker-registry
Run Code Online (Sandbox Code Playgroud)
响应:docker-registry启动/运行,进程8620
sudo status docker-registry
Run Code Online (Sandbox Code Playgroud)
响应:docker-registry启动/运行,进程8620
sudo stop docker-registry
Run Code Online (Sandbox Code Playgroud)
响应:docker-registry停止/等待
但是,它实际上并没有停止.该过程仍然存在,容器正在运行,并且它仍然可以正常运行
它完全停止:
docker stop docker-registry
Run Code Online (Sandbox Code Playgroud)
我已经尝试将其添加到upstart脚本中:
post-stop script
docker stop docker-registry
end script
Run Code Online (Sandbox Code Playgroud)
但它只是返回: 停止:停止时作业失败
使用以下代码:
var win = new Ext.Window({
xtype: 'form',
layout: 'form',
items: [{
xtype: 'textfield',
value: 'test',
name: 'testing',
labelWidth: 200,
fieldLabel: 'This is a really, really long label here',
labelStyle: 'white-space: nowrap;'
}]
}).show();
Run Code Online (Sandbox Code Playgroud)
此标签文本与输入部分重叠(抱歉没有足够的信誉点来发布图像).
我尝试过使用各种组合的css:'cls','labelStyle','style'和'width'但它们似乎都被忽略了(至少在正确设置标签宽度方面).
我正在动态地向表单添加项目,我希望每个元素的自定义标签宽度.在其他元素上,我不希望它为标签保留默认的100px空间 - 我想要更少.这是否可以使用标准文本字段,或者我是否必须创建自定义组件才能执行此操作?
感谢您提供的任何见解.
我是编程新手,我必须做的一项任务是使用for循环和.join创建一个随机的hexdigit颜色代码生成器.我的程序是否接近你的工作方式,还是完全关闭?并且,有没有办法让随机数量的数字和字母出现在6?
import random
str = ("A","B","C","D","E","F","G","H")
seq = ("1","2","3","4","5","6", "7","8","9")
print '#',
for i in range(0,3):
letter = random.choice(str)
num = random.choice(seq)
print num.join(letter),
print letter.join(num)
Run Code Online (Sandbox Code Playgroud) 假设我有一个无法导入的模块(导入时有例外).
例如.test.py
具有以下内容:
print 1/0
Run Code Online (Sandbox Code Playgroud)
[显然,这不是我的实际文件,但它将作为一个很好的代理]
现在,在python提示符下:
>>> import test
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "test.py", line 1, in <module>
print 1/0
ZeroDivisionError: integer division or modulo by zero
>>>
Run Code Online (Sandbox Code Playgroud)
找到路径/文件位置的最佳方法是test.py
什么?
[我可以遍历Python的模块搜索路径,查看文件的每个目录,但我认为必须有一个更简单的方法......]
我是python和nltk的新手.我已将代码从https://gist.github.com/alexbowe/879414转换为下面给出的代码,以使其运行许多文档/文本块.但是我得到了以下错误
Traceback (most recent call last):
File "E:/NLP/PythonProgrames/NPExtractor/AdvanceMain.py", line 16, in <module>
result = np_extractor.extract()
File "E:\NLP\PythonProgrames\NPExtractor\NPExtractorAdvanced.py", line 67, in extract
for term in terms:
File "E:\NLP\PythonProgrames\NPExtractor\NPExtractorAdvanced.py", line 60, in get_terms
for leaf in self.leaves(tree):
TypeError: leaves() takes 1 positional argument but 2 were given
Run Code Online (Sandbox Code Playgroud)
任何人都可以帮我解决这个问题.我必须从数百万的产品评论中提取名词短语.我使用Java使用Standford NLP工具包,但它非常慢,所以我认为在python中使用nltk会更好.如果有更好的解决方案,请同时推荐.
import nltk
from nltk.corpus import stopwords
stopwords = stopwords.words('english')
grammar = r"""
NBAR:
{<NN.*|JJ>*<NN.*>} # Nouns and Adjectives, terminated with Nouns
NP:
{<NBAR>}
{<NBAR><IN><NBAR>} # Above, connected with in/of/etc...
"""
lemmatizer …
Run Code Online (Sandbox Code Playgroud) 我创建了一个Dockerfile,其中包含以下内容:
FROM ubuntu
ENV test this
Run Code Online (Sandbox Code Playgroud)
我在当前目录中构建图像:
docker build -t="test" .
Run Code Online (Sandbox Code Playgroud)
我运行此图像,只是为了确认我的环境变量已设置:
docker run -t -i <image id> /bin/bash
Run Code Online (Sandbox Code Playgroud)
我set
在正在运行的容器中输入,然后确认test=this
.
退出容器后,我使用以下两个命令导出图像:
cont=`docker run -d <image id> ls`
docker export $cont > test.tar
Run Code Online (Sandbox Code Playgroud)
然后我通过以下方式导入图像:
cat test.tar | docker import - imported
Run Code Online (Sandbox Code Playgroud)
运行新图像:
docker run -t -i <image id returned from prev cmd> /bin/bash
Run Code Online (Sandbox Code Playgroud)
我set
在这个运行容器中输入,我的环境变量不再存在
我究竟做错了什么?
我用其他命令的图像完成了这个,除环境变量之外的所有东西似乎都存在.
我有一个 Java Applet(用于浏览器),使用来自 GoDaddy 的有效代码签名证书进行签名和时间戳。代码签名证书本身将在几周后到期。我读过的所有内容都表明小程序在代码签名证书到期后仍然有效:
从这里:
如果发现时间戳,则代码签名一直有效,直到时间结束,只要代码保持不变
我想验证这实际上是真的。如果我将计算机的时钟设置更改为以后的日期,即证书过期后的日期,我会在 IE、Firefox 和 Chrome 中收到以下 Java 异常:
java.security.cert.CertificateException:java.security.cert.CertPathValidatorException:响应不可靠:其有效期间隔已过时
这是否意味着当代码签名证书到期时,小程序实际上会在几周内失败,还是这种更改计算机时钟的测试无效?任何参考方法?
我正在编写一些集成测试,涉及在uwsgi下运行的Python应用程序。
为了测试这一方面,我正在运行一个uwsgi假脱机程序,它要求主进程正在运行。
如果pytest测试失败,它将返回一个非零的退出代码,这很棒。
没有主进程,整个uwsgi进程也会返回此退出代码,因此我们的持续集成服务器会做出适当的响应。
但是,当主进程运行时,它总是以零退出代码退出-不管测试失败。
如果有一个子进程,我需要它传递子进程的第一个非零退出代码。
注意:我对模拟这个并不是很感兴趣-我需要测试这个功能。
我创建了一个Dockerized 最小,完整和可验证示例,用于说明我的问题:
Dockerfile:
FROM python:3.6.4-slim-stretch
WORKDIR /srv
RUN apt-get update \
&& apt-get install -y build-essential \
&& pip install uwsgi pytest
COPY test_app.py /srv/
CMD ['/bin/bash']
Run Code Online (Sandbox Code Playgroud)
test_app.py:
import pytest
def test_this():
assert 1==0
Run Code Online (Sandbox Code Playgroud)
给定目录中的以上两个文件,如果我在没有主进程的情况下在uwsgi 下运行此失败的测试,则以下显示返回代码:
$ docker build -t=test .
$ docker run test uwsgi --chdir /srv --pyrun /usr/local/bin/pytest
...
============================= test session starts ==============================
platform linux -- Python 3.6.4, pytest-3.3.2, py-1.5.2, pluggy-0.6.0
rootdir: /srv, inifile: …
Run Code Online (Sandbox Code Playgroud) 我想要的是一个memoization装饰器:
我已经调整了一个我看到的例子并想出了以下内容:
import functools
class Memoized(object):
"""Decorator that caches a function's return value each time it is called.
If called later with the same arguments, the cached value is returned, and
not re-evaluated.
"""
__cache = {}
def __init__(self, func):
self.func = func
self.key = (func.__module__, func.__name__)
def __call__(self, *args):
try:
return Memoized.__cache[self.key][args]
except KeyError:
value = self.func(*args)
Memoized.__cache[self.key] = {args : value}
return value
except TypeError:
# uncachable -- …
Run Code Online (Sandbox Code Playgroud) 我正在尝试将多个记录插入表中,但对每个记录使用相同的序列值.
这类似于:如何使用序列值将多行插入oracle?但是给出的答案会插入多个不同的序列号,并且我希望多个recs使用相同的序列号.
create table test1 (
col_a number,
col_b number
);
commit;
create sequence test_seq increment by 1 start with 2 minvalue 1 nocycle nocache noorder;
commit;
insert into test1 (col_a, col_b)
select a.object_id, test_seq.nextval from (
select object_id from all_objects where rownum < 5
) a;
commit;
Run Code Online (Sandbox Code Playgroud)
上面的问题是它检索并插入多个(不同的)"test_seq.nextval"值,我希望为每一行插入相同的值.
这甚至可以在直接sql中使用而不诉诸触发器(或多个sql语句)?相关问题的答案之一暗示可能不是,但我不清楚.
谢谢.
如果有帮助,我正在使用Oracle 11g.