问题列表 - 第5493页

如何使用python下载时优雅地超时

我正在下载一个包含以下代码的大量文件:

try:
    urllib.urlretrieve(url2download, destination_on_local_filesystem)
except KeyboardInterrupt:
    break
except:
    print "Timed-out or got some other exception: "+url2download
Run Code Online (Sandbox Code Playgroud)

如果在刚刚启动连接时服务器在URL url2download上超时,则会正确处理最后一个异常.但有时服务器响应,并开始下载,但服务器太慢,即使一个文件也需要几个小时,最终它会返回如下内容:

Enter username for Clients Only at albrightandomalley.com:
Enter password for  in Clients Only at albrightandomalley.com:
Run Code Online (Sandbox Code Playgroud)

并挂起(虽然如果通过浏览器下载相同的链接,则不会使用用户名/密码).

我在这种情况下的意图是 - 跳过这个文件然后转到下一个文件.问题是 - 怎么做?有没有办法在python中指定下载一个文件可以工作多长时间,如果已经花费了更多时间,请中断并继续前进?

python exception-handling download

10
推荐指数
2
解决办法
6899
查看次数

伏地魔与couchdb

我正在尝试决定是否使用voldemort或couchdb来进行即将到来的医疗项目.我想要一个具有高可用性,容错能力的存储系统,并且可以针对大量数据进行扩展.

每个人的利弊是什么?

谢谢

database couchdb voldemort

6
推荐指数
2
解决办法
4475
查看次数

Rails:处理导航的优雅方式?

现在我的导航部分看起来像这样(x10按钮)......

<% if current_controller == "territories" %>
    <li><%= link_to "Territories", {:controller => 'territories'}, :class => 'active'  %></li>
<% else %>
    <li><%= link_to "Territories", {:controller => 'territories'}  %></li>
<% end %>
<% if current_controller == "contacts"  %>
    <li><%= link_to "Contacts", {:controller => 'Contacts'}, :class => 'active'  %></li>
<% else %>
    <li><%= link_to "Contacts", {:controller => 'Contacts'}  %></li>
<% end %>
Run Code Online (Sandbox Code Playgroud)

这样做有更优雅/干燥的解决方案吗?

ruby-on-rails

12
推荐指数
1
解决办法
7876
查看次数

过滤nHibernate中的连接

我正在尝试构建一个nHibernate条件表达式来执行搜索.

给出以下数据模型:

  • 操作可以具有零个或多个会话.
  • 操作可以是零个以上的操作类型.

我想根据以下条件搜索所有会话:

  • (必填)如果操作IsActive标志为true,则IsPublished标志为true

o(可选)以及操作状态/结束日期在用户指定的日期范围内

o(可选)以及会话regionid与用户指定的id匹配的位置

o(可选)以及会话分区与用户指定的id匹配的位置

o(可选)以及Operation.OperationTypes在用户指定的类型ID列表中

我会在sql中表达这个(给定所有可选参数已提供):

SELECT     
    [Session].*
FROM         
    [OperationTypeOperation] 
LEFT OUTER JOIN
    [Operation] ON [OperationTypeOperation].[OperationId] = [Operation].[OperationId]
RIGHT OUTER JOIN
    [Session] ON [Operation].[OperationId] = [Session].[OperationId]
WHERE
    ([Operation].[IsPublished] = 1) 
AND 
    ([Operation].[IsActive] = 1) 
AND 
    ([Session].[RegionId] = 66)
AND 
    ([Session].[DivisionId] = 99)
AND 
    ([Operation].[AdvertisingStartDate] < GETDATE()) 
AND 
    ([Operation].[AdvertisingEndDate] > GETDATE()) 
AND 
    ([OperationTypeOperation].[OperationTypeId] IN (1, 2, 3))
Run Code Online (Sandbox Code Playgroud)

在我的nHibernate查询中:

public PagedResult<Session> Search(int? regionId, int? divisionId, DateTime? startDate, DateTime? endDate, IList<int> operationTypeId, int itemsPerPage, int page)
        {

            var …
Run Code Online (Sandbox Code Playgroud)

c# nhibernate

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

WCF服务连接问题 - 也许是安全性?

我正在尝试调试WCF服务.这个客户端过去能够连接,但现在我无法连接.该服务部署到服务器.我可以使用浏览器访问服务器的服务页面,然后查看生成客户端的说明.我使用svcutil重新生成了客户端代理和配置文件.

客户端启动,但第一次调用服务在1分钟超时后返回错误.同时,我可以附加到服务器上运行的服务并在那里单步执行代码.我可以看到我的客户从未注册过.此调用的服务器代码中的断点不会被命中.出于某种原因,我无法进入服务器代码(但我可以将调试器附加到服务器上的服务):

Unable to automatically step into the server. 
Connecting to the server machine 'shuttle' failed. 
Please install the Visual Studio 2008 Remote Debugger on the 
server to enable this functionality.
Run Code Online (Sandbox Code Playgroud)

远程调试器已安装并正在运行或正在运行.我在长时间超时后收到此错误:

Client is unable to finish the security negotiation within the 
configured timeout (00:00:00).  The current negotiation leg is 1 (00:00:00).
Run Code Online (Sandbox Code Playgroud)

当我设置安全模式=无,并增加超时时,错误更改为

The open operation did not complete within the allotted timeout of 00:02:00.
The time allotted to this operation may have been a portion of a 
longer timeout. …
Run Code Online (Sandbox Code Playgroud)

.net security wcf

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

如何将List绑定到ComboBox?

我想连接一个BindingSource类对象列表,然后将对象值连接到一个ComboBox.
谁能建议怎么做?

public class Country
{
    public string Name { get; set; }
    public IList<City> Cities { get; set; }

    public Country()
    {
        Cities = new List<City>();
    }
}
Run Code Online (Sandbox Code Playgroud)

是我的类,我想将其name字段绑定到BindingSource,然后可以与ComboBox关联

c# data-binding combobox winforms

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

从Linux内核中的路径获取inode

我目前正在尝试在内核函数中获取给定路径名的inode.我所有的都是完整的路径名.我尝试过这样的尝试:

user_path_at(AT_FDCWD, buffer, LOOKUP_FOLLOW, &path);
Run Code Online (Sandbox Code Playgroud)

但是,在给定的路径中的dentry无效,似乎结果.然后我想也许尝试stat()并从中获取inode数.但是,这只给了我一个数字,而不是结构inode.我不知道如何在不抓取现有inode并遍历整个inode列表的情况下将inode编号转换为inode.我甚至不知道这是否有效.但我当然不想这样做.

有没有简单的方法从内核中的char*pathname获取struct inode?

linux kernel

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

估计数据库大小

我想知道在估算数据库大小方面开发新应用程序时你做了什么.

例如,我计划推出一个网站,我很难估计我希望我的数据库增长的规模.我不希望你告诉我我的数据库的大小,但我想知道估计这个是否有一般原则.

例如,当Jeff开发StackOverflow时,他(大概)估计了他的数据库大小和增长.

我的困境是我要为我的网络应用程序提供一个托管解决方案(它在这个阶段的成本),并且最好不要通过不购买足够的SQL Server空间来为自己拍摄(他们为此收取额外费用) ).

database sql-server sizing

19
推荐指数
1
解决办法
9507
查看次数

divs在标题周围坍塌

我有一些嵌套的div:

<div id="wrapper">
  <div id="header">
    <!-- a bunch of float divs here -->
  </div>

  <div id="body">
    <div id="content">
      <!-- a bunch of html controls here -->
    </div>
  </div>
</div>
Run Code Online (Sandbox Code Playgroud)
  • 包装风格: width: 780px; margin: 20px auto; border: solid black 5px;
  • 标题样式: position: relative; min-height: 125px;
  • 身材: position: relative;
  • 内容风格: position: absolute; left: 50px; top: 0px;

我在内容div中有一堆html元素,由于某种原因,body div和包装div在标题周围折叠,如果我没有为body div设置固定高度,内容div会自行挂起.我唯一的浮动元素在标题中.

编辑:

如果我删除内容div(并直接在主体中删除html元素),主体div将停止折叠!试图理解为什么 - 猜测它是由于位置:内容div的绝对值.

任何线索为什么会发生这种情况以及如何解决?

我看了这个问题,但它似乎对我没用(或者我可能在错误的地方清理......).

html css

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

指针神秘地重置为NULL

我正在开发一款游戏,而我正在研究处理输入的部分.这里涉及三个类,有一个ProjectInstance类启动级别和东西,有一个GameController将处理输入,一个PlayerEntity将受到由控制的控件的影响GameController.在启动级别时,ProjectInstance创建了GameController,它将EvaluateControls在Step方法中调用其方法,该方法在游戏循环中调用.该EvaluateControls方法看起来有点像这样:

void CGameController::EvaluateControls(CInputBindings *pib) {
    // if no player yet
    if (gc_ppePlayer == NULL) {
        // create it
        Handle<CPlayerEntityProperties> hep = memNew(CPlayerEntityProperties);
        gc_ppePlayer = (CPlayerEntity *)hep->SpawnEntity();
        memDelete((CPlayerEntityProperties *)hep);
        ASSERT(gc_ppePlayer != NULL);
        return;
    }

    // handles controls here
}
Run Code Online (Sandbox Code Playgroud)

正确调用此函数,并且assert永远不会触发.但是,每次调用此函数时,gc_ppePlayer都将设置为NULL.正如您所看到的,它不是超出范围的局部变量.唯一gc_ppePlayer可以设置为NULL的地方是在构造函数中,或者可能在析构函数中,在调用之间都没有调用它们EvaluateControls.调试时,gc_ppePlayer在返回前收到正确的预期值.当我再次按F10并且光标位于右括号时,值将更改为0xffffffff.我在这里不知所措,怎么会发生这种情况?任何人?

c++ pointers

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