小编App*_*lus的帖子

time.sleep(x)不能正常工作?

好的,所以我正在制作一个有趣的小程序,我想创建一个刷新按钮,允许用户控制数据收集和显示的频率.我决定使用time.sleep(x)x作为raw_input.但它似乎没有按预期工作.它会暂停完整的脚本,然后执行所有操作.

例如:

import time

print "This now"
time.sleep(x)
print "and this after x amount of  seconds"
Run Code Online (Sandbox Code Playgroud)

所以应该在x秒之后打印第一部分然后打印第二部分.

但相反,它会在x秒后立即打印所有内容.

当我使用if语句之后,它似乎等了额外的x秒秒来打印if语句中的任何内容.

当把数据高于0的旧数据加x时,这真的会弄乱我的数据.例如,如果我输入60,那将是一整分钟的旧数据(不是现场).将它保留为0只会使控制台太多而无法读取.

知道为什么以及如何解决我的问题?

python time sleep python-2.7

7
推荐指数
1
解决办法
1万
查看次数

如何解决此Moq错误?System.Reflection.TargetParameterCountException:参数计数不匹配

我在我的nUnit测试用例中使用Moq.

这是我的测试用例的样子:

        IList<ChartFieldDepartment> coaDepartments = new List<ChartFieldDepartment>() {
                new ChartFieldDepartment { ChartFieldKey="1000", Description="Corporate Allocation"},
                new ChartFieldDepartment { ChartFieldKey="1010", Description="Contribution to Capital"}
        };

        Mock<IChartFieldRepository> mockChartFieldRepository = new Mock<IChartFieldRepository>();
        mockChartFieldRepository.Setup(x => x.RetrieveChartFieldDepartments(It.IsAny<bool>())).Returns(coaDepartments.AsQueryable);

        ChartFieldDomainService chartFieldDomainService = new ChartFieldDomainService(mockChartFieldRepository.Object);

        // this line fails! I get System.Reflection.TargetParameterCountException : Parameter count mismatch
        IQueryable<ChartFieldDepartment> departments = chartFieldDomainService.RetrieveChartFieldDepartments();
Run Code Online (Sandbox Code Playgroud)

这是我的ChartFieldDomainService:

public class ChartFieldDomainService : IChartFieldDomainService
{
    private IChartFieldRepository _chartFieldRepository = null;

    public ChartFieldDomainService(IChartFieldRepository repository)
    {
        _chartFieldRepository = repository;
    }

    public virtual IQueryable<ChartFieldDepartment> RetrieveChartFieldDepartments()
    {
        return _chartFieldRepository.RetrieveChartFieldDepartments(true); // …
Run Code Online (Sandbox Code Playgroud)

parameters moq

6
推荐指数
1
解决办法
4570
查看次数

CCtray无法连接到仪表板

我正在使用CCnet 1.6和cctray 1.6.在构建服务器上,托盘使用localhost正常工作.但是,我无法将托盘连接到仪表板.仪表板URL工作得很好,但当我将其放入cctray设置时,我得到500内部服务器错误.

直到我不得不将CCnet从defaultwebsite移动到它自己的网站.当我改变它时,我错过了什么吗?

谢谢,乔

cruisecontrol.net cctray

6
推荐指数
1
解决办法
4451
查看次数

旋转后UITapGestureRecognizer不会触发

我有一个TabBarController有两个选项卡.在每个标签中我都有UICollectionView,UITapGestureRecognizer每次点击时都会触发collectionView.应用程序启动后,一切正常.但如果我转向横向,TapGestureRecognizer只能在collectionView旧框架中发射.它绝对忽略了屏幕的右侧.

但是,如果我切换到另一个选项卡然后返回,它也适用于横向方向.我只是不明白我做错了什么.

这就是我改变方向模式的方法collectionView:

-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
    [super willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
    [self.cardCollectionView.collectionViewLayout invalidateLayout];
}
Run Code Online (Sandbox Code Playgroud)

objective-c ios uitapgesturerecognizer uicollectionview

5
推荐指数
1
解决办法
997
查看次数

立即更新 nuget 包及其所有依赖项

我刚刚使用 Angular 项目创建了一个新的 .net core,并且已经有一些 NuGet 包(例如“Microsoft.AspNetCore.SpaServices.Extensions”)具有可用更新。

当我尝试更新它时,出现错误,指出与另一个包“Microsoft.ApNetCore.Mvc.Abstractions”存在版本冲突,要解决此问题,我需要安装或引用“Microsoft.ApNetCore.Mvc.Abstractions” “ 2.2.0,当我尝试安装它时,会出现关于另一个依赖项的类似错误等等。

有没有办法让 nuget 立即更新/安装所有这些依赖项,而不是我一个一个地安装它们?

nuget nuget-update visual-studio-2019

5
推荐指数
1
解决办法
1万
查看次数

如何查找具有特定属性及其值的标签

我有这样的页面布局

<input id="name" class="mandotary" type="text">
<label for="name">Name must be entered</label>

<input id="code" class="mandotary" type="text">
<label for="code">Code must be entered</label>
Run Code Online (Sandbox Code Playgroud)

现在我想首先加载页面时隐藏标签元素.如果失去焦点且值为null,则应显示标签,否则应隐藏标签.我试过这个

var inputElementArray = $("input.mandotary");
$.each(inputElementArray, function(index, element){

    var id = $(element).attr("id");
    var label = $("label").attr("for", id);
   // label.hide();

    $(element).focus(function(){
        var next = $(element).next();
        $(element).next().hide();
    }); //end of focus()

    $(element).blur(function(){

        // get value of text area
        var text = $(element).val();
        if (text == "") {
            var next = $(element).next();
            $(element).next().show();
        } //end of if

    }); //end of blur()

}); //end of …
Run Code Online (Sandbox Code Playgroud)

jquery

4
推荐指数
1
解决办法
3万
查看次数

wpf阿拉伯语文本无法正确显示

我想从右到左显示一些阿拉伯文字.所以我将流向设置为RightToLeft.以下是我的计划:

<Grid x:Name="LayoutRoot" HorizontalAlignment="Left" VerticalAlignment="Top" >
    <TextBlock Margin="104,96,0,0" VerticalAlignment="Top" Height="Auto" Text="(??? ??????? ???????? 1 (?????? 12 ????"  HorizontalAlignment="Left" FontSize="20" />
</Grid>
Run Code Online (Sandbox Code Playgroud)

输出似乎不正确.紧密括号出现在不同的位置.输出结果为وقتالقاعدةالرئيسية1(بتوقيت12ساعة)

请提出建议/解决方案.

c# wpf

3
推荐指数
1
解决办法
2226
查看次数

使用RoboCopy的CCNET Exec即使使用<successExitCodes>也会失败

所以我有一个成功构建的CCNET项目,直到我包含一个RoboCopy exec任务来进行部署:

<exec>
  <executable>C:\Windows\System32\robocopy.exe</executable>
  <buildArgs>D:\CCNETProjects\$(projectname)\Builds\Latest_Build\_PublishedWebsites\$(projectname) D:\TEST_$(projectname) *.* /E /NP /XF *.config /XD config</buildArgs>
  <buildTimeoutSeconds>60</buildTimeoutSeconds>
  <successExitCodes>0,1,2,4,8,16</successExitCodes>
</exec>
Run Code Online (Sandbox Code Playgroud)

如您所见,我已包含此处列出的所有可能的退出代码; http://ss64.com/nt/robocopy-exit.html

任务成功执行(文件被复制好),构建结果显示此任务没有错误,但我的构建仍然失败!

<buildresults>
  <message>-------------------------------------------------------------------------------</message>
  <message>   ROBOCOPY     ::     Robust File Copy for Windows                              </message>
  <message>-------------------------------------------------------------------------------</message>
  <message>  Started : Wed Jun 27 19:50:45 2012</message>
  <message>   Source : D:\CCNETProjects\FieldworkReportGenerator\Builds\Latest_Build\_PublishedWebsites\FieldworkReportGenerator\</message>
  <message>     Dest : D:\TEST_FieldworkReportGenerator\</message>
  <message>    Files : *.*</message>
  <message>     </message>
  <message>Exc Files : *.config</message>
  <message>     </message>
  <message> Exc Dirs : config</message>
  <message>     </message>
  <message>  Options : *.* /S /E /COPY:DAT /NP /R:1000000 /W:30 </message>
  <message>------------------------------------------------------------------------------</message>
  <message>                    5 …
Run Code Online (Sandbox Code Playgroud)

cruisecontrol.net robocopy

3
推荐指数
1
解决办法
1228
查看次数

在哪里可以在实现相同接口的多个类中放置所需的通用逻辑?

给出以下界面:

public interface IFoo
{
    bool Foo(Person a, Person b);
}
Run Code Online (Sandbox Code Playgroud)

以及以上两种实现:

public class KungFoo : IFoo
{
    public bool Foo(Person a, Person b)
    {
        if (a.IsAmateur || b.IsAmateur) // common logic
          return true;
        return false;
    }
}

public class KongFoo : IFoo
{
    public bool Foo(Person a, Person b)
    {
        if (a.IsAmateur || b.IsAmateur) // common logic
          return false;
        return true;
    }
}
Run Code Online (Sandbox Code Playgroud)

我应该在哪里放置"通用逻辑"(如代码中所述),因此它只在一个地方(例如作为Func)并且不需要为多个实现重复(如上所述)?

请注意,上面的示例非常简单,但现实生活中的"通用逻辑"更复杂,Foo()方法做了一些有用的事情!

我希望问题很清楚(在其他地方尚未得到解答 - 我确实进行了搜索)但如果需要,可以随时向我探讨更多细节.

c# inheritance

3
推荐指数
1
解决办法
5044
查看次数

嵌入YouTube视频的问题

我开始对这段代码感到疯狂.这很简单,但它不起作用,我无法理解为什么.

我想在HTML页面中嵌入一个YouTube视频:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Title</title>
</head>

<body>
    <div style="font-family: 'NeubauGrotesk55Normal'; font-size: 32px; text-transform: uppercase; color: #0066b3; margin-left: 20px;">Add title</div>
    <div style="font-size: 16px; font-family: 'Georgia', 'Times New Roman', times, serif; color: #333333; margin-left: 20px; margin-top:20px;">Add text</div>

    <div style="margin-left: 20px; margin-top:20px;"><iframe width="853" height="480" src="//www.youtube-nocookie.com/embed/rzp7wHnX6jc?rel=0" frameborder="0" allowfullscreen></iframe></div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

任何的想法?

谢谢!

html embed youtube

3
推荐指数
1
解决办法
7620
查看次数

如何使用 Moq.Dapper 模拟 QueryMultiple

我正在编写单元测试用例,并且我成功地为 编写了单元测试用例Query。但我无法为 编写单元测试用例QueryMultiple

对于查询我是这样写的:

 IEnumerable<ClientTestPurpose> fakeTestPurposes = new 
 List<ClientTestPurpose>()
 {
      new ClientTestPurpose { PurposeID = 1, PurposeName = "Test Purpose name1"},
      new ClientTestPurpose { PurposeID = 1, PurposeName = "Test Purpose name2"},
      new ClientTestPurpose { PurposeID = 1, PurposeName = "Test Purpose name3"}
 };

 _mock.SetupDapper(x => x.Query<ClientTestPurpose>(It.IsAny<string>(), null, null, true, null, null)).Returns(fakeTestPurposes);

 var result = _libraryRepository.TestPurposes(clientModal.Id);

 Assert.IsNotNull(result);
 Assert.AreEqual(result.Count(), fakeTestPurposes.Count());   
Run Code Online (Sandbox Code Playgroud)

如何写QueryMultiple

using (var multi = _db.QueryMultiple(spName, spParams, commandType: CommandType.StoredProcedure))
{
     var totals = multi.Read<dynamic>().FirstOrDefault();
     var …
Run Code Online (Sandbox Code Playgroud)

unit-testing moq dapper

3
推荐指数
1
解决办法
1万
查看次数

如何使用AngularJS启用禁用按钮上的Bootstrap Tooltip?

我需要在禁用按钮上显示工具提示,如果使用AngularJS启用它,则将其删除.

angularjs angular-ui-bootstrap

2
推荐指数
1
解决办法
5563
查看次数