小编use*_*586的帖子

在python splinter网络搜寻器中设置一个timout

尝试在python中设置超时,就像在ruby中一样。

我有一个链接,当我单击它时会打开一个弹出窗口,但无法访问它,因为它会导致脚本冻结,直到我杀死它为止。我几个月来一直在尝试访问此弹出窗口,而在ruby watir-webdriver中却没有任何乐趣。

我正在尝试使对弹出窗口的调用超时,然后访问弹出窗口。

@timeout(3)
try:
b.execute_script("javascript:openMdlWindow('InvestmentDetailOptions.aspx?IDAssetType=','620','600');if(window.document.RetValue == '2'){window.parent.LoadinIframe('InvestmentDetail.aspx?FromMenu=N&IDAssetType=','Investment Details > Full View','false');}")
except Exception, e:
print 'timeout!'
Run Code Online (Sandbox Code Playgroud)

任何帮助将不胜感激。

python webautomation selenium-chromedriver splinter

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

Ruby Net-SFTP捕获和日志异常

我有一个简单的SFTP脚本,我正在测试它连接到服务器并下载文件名中具有特定日期的文件或文件.

我每隔X分钟使用rufus/scheduler来启动脚本的SFTP部分,以查看服务器上是否有新文件.

这一切似乎都有效,直到我故意强制发生错误,例如提供错误的登录凭据.然后我希望能够捕获确切的错误或异常并使用logger记录它.我没有得到错误详细信息或我没有正确使用救援:

scheduler = Rufus::Scheduler::PlainScheduler.start_new(:frequency => 3.0)
log = Logger.new('sftp.log')
log.level = Logger::INFO

begin
log.info 'starting sftp'
  Net::SFTP.start(HOST, ID, :password => PW ) do |sftp|
   sftp.dir.glob("./", "20120820*") do |entry|
     puts entry.name
     file = entry.name
     success = sftp.download!(file, file)
   end
  end   
rescue Exception => e
  puts e.message          # Human readable error
  log.error ("SFTP exception occured: " + e.message)
end
scheduler.join
Run Code Online (Sandbox Code Playgroud)

ruby net-sftp rufus-scheduler

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