小编Luk*_*ger的帖子

AngularJS ng-keydown指令仅适用于<input>上下文?

我是AngularJS的新手,但到目前为止我发现它非常符合我的喜好.对于我目前的项目,我需要热键功能,很高兴看到自1.1.2版本以来它受支持.

ng-keydown指令(http://code.angularjs.org/1.1.3/docs/api/ng.directive:ngKeydown)按输入类型的预期工作,但是对于任何其他上下文(如div等)都不能使用鉴于文件说不然.

这是一个最小的例子(http://jsfiddle.net/TdXWW/12/),分别是不工作的:

<input ng-keydown="keypress($event)">
<div ng-keydown="keypress($event)">
Run Code Online (Sandbox Code Playgroud)

注意:我知道这可以用简单的jQuery(http://www.mkyong.com/jquery/how-to-check-if-an-enter-key-is-pressed-with-jquery/)来处理,但我很多更愿意了解如何在AngularJS中处理它.

hotkeys angularjs

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

从paramiko ssh exec_command连续获取输出

我正在使用paramiko在远程机器上通过ssh执行长时间运行的python脚本.工作就像一个魅力,到目前为止没有问题.

不幸的是,stdout(分别是stderr)只在脚本完成后显示!但是,由于执行时间的原因,我更倾向于在打印时输出每个新行,而不是之后.

remote = paramiko.SSHClient()
remote.set_missing_host_key_policy(paramiko.AutoAddPolicy())
remote.connect("host", username="uname", password="pwd")

# myScript produces continuous output, that I want to capture as it appears    
stdin, stdout, stderr = remote.exec_command("python myScript.py")
stdin.close()
for line in stdout.read().splitlines():
    print(line)
Run Code Online (Sandbox Code Playgroud)

怎么能实现这一目标? 注意:当然可以通过另一个ssh会话将输出传输到文件并"减少"此文件,但这非常难看,我需要一个更清洁,理想的pythonic解决方案:)

python ssh interactive stdout paramiko

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

标签 统计

angularjs ×1

hotkeys ×1

interactive ×1

paramiko ×1

python ×1

ssh ×1

stdout ×1