我有几个任务作为服务运行。为了启动工作人员,我使用:
def SvcDoRun(self):
logging.info('Starting {name} service ...'.format(name=self._svc_name_))
os.chdir(INSTDIR) # so that proj worker can be found
logging.info('cwd: ' + os.getcwd())
self.ReportServiceStatus(win32service.SERVICE_RUNNING)
command = '{celery_path} -A {proj_dir} worker -f "{log_path}" -l info --hostname=theService@%h'.format(
celery_path='celery',
proj_dir=PROJECTDIR,
log_path=os.path.join(INSTDIR,'celery.log'))
logging.info('command: ' + command)
args = shlex.split(command)
proc = subprocess.Popen(args)
logging.info('pid: {pid}'.format(pid=proc.pid))
self.timeout = 5000
while True:
rc = win32event.WaitForSingleObject(self.hWaitStop, self.timeout)
if rc == win32event.WAIT_OBJECT_0:
print 'Terminate'
# stop signal encountered
PROCESS_TERMINATE = 1
handle = win32api.OpenProcess(PROCESS_TERMINATE, False, proc.pid)
win32api.TerminateProcess(handle, -1)
win32api.CloseHandle(handle)
break …Run Code Online (Sandbox Code Playgroud) 使用selenium和python我有几个需要并行运行的测试.为了避免使用相同的浏览器,我添加了使用特定配置文件目录和用户数据的参数(见下文).问题是我不能同时运行它们,一个测试需要等待另一个完成.否则我从chromedriver得到以下错误:
Starting ChromeDriver 2.29.461591 (62ebf098771772160f391d75e589dc567915b233) on port 9515
Only local connections are allowed.
[0.000][SEVERE]: bind() returned an error: Only one usage of each socket address (protocol/network address/port) is normally permitted. (0x2740)
Run Code Online (Sandbox Code Playgroud)
硒设置:
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--user-data-dir=C:/ChromeProfile')
chrome_options.add_argument("--profile-directory=Profile1")#Profile2,Profile3, etc
chrome_options.add_argument('--start-maximized')
chrome_options.add_argument('--incognito')
self.driver = webdriver.Chrome(executable_path='C:/Chrome/chromedriver.exe',chrome_options=chrome_options)
Run Code Online (Sandbox Code Playgroud) 显然,unobtrusive js和ModelState错误不能同时发挥作用。我想要完成的是两件事。当ModelState发生客户端错误或客户端错误时,validation-summary-errors 类将显示该错误。
我遇到的问题是不使用助手,
<div class="validation-summary-errors" data-valmsg-summary="true">
<ul style="list-style-type:none;"></ul>
</div>
Run Code Online (Sandbox Code Playgroud)
它不会显示ModelState错误,因此我尝试使用以下代码,
代码 :
if (!ViewData.ModelState.IsValid)
{
<div class="validation-summary-errors" data-valmsg-summary="true">
<ul style="list-style-type:none;"></ul>
</div>
}
else
{
@Html.ValidationSummary()
}
Run Code Online (Sandbox Code Playgroud)
但由于助手的原因,我无法格式化输出(就像从列表中删除项目符号一样)!
这是 JavaScript :
$(document).ready(function () {
$('form').each(function () {
var theForm = $(this);
theForm.submit(function () {
if ($(this).valid()) {
if ($(this).find('.validation-summary-valid').length) {
$('.validation-summary-errors').hide();
}
} else {
if ($(this).find('.validation-summary-errors').length) {
$('.validation-summary-errors')
.addClass('alert alert-danger');
}
}
});
});
});
Run Code Online (Sandbox Code Playgroud) python ×2
asp.net-mvc ×1
c# ×1
celery ×1
css ×1
javascript ×1
jquery ×1
rabbitmq ×1
selenium ×1